Last active
          October 16, 2017 05:08 
        
      - 
      
 - 
        
Save jesuscast/42a2aae76b5f02e28bdfd1e76bb36f77 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
jesuscast revised this gist
Oct 16, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,4 +34,5 @@ def exp(): p.start() p.join() assert p.exitcode != 0, "Child process call to qr did not fail" assert p.exitcode == -11, "The error is not a segmentation fault %s" % p.exitcode print("Child process call to QR failed as expected")  - 
        
jesuscast revised this gist
Oct 16, 2017 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,11 +23,12 @@ def exp(): flattened = get_flattened(tensor) # It should fail if being called # in a child process. return torch.qr(flattened) if __name__=="__main__": # First call result = exp() assert result is not None, "Oops, it should have not failed here" # Now create child process. p = mp.Process(target=exp) p.start()  - 
        
jesuscast revised this gist
Oct 16, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ def get_flattened(tensor): return flattened def get_mat(): """ This is what we send when during the initialization """ wc_dim = 200 mat = nn.utils.weight_norm(nn.Linear(wc_dim, wc_dim, bias=False), name="weight") tensor = mat.weight.data  - 
        
jesuscast revised this gist
Oct 16, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import torch.nn as nn import multiprocessing as mp def get_flattened(tensor): """ This is just the first part of orthogonal initialization. Taken directly from https://github.com/pytorch/pytorch/blob/master/torch/nn/init.py """  - 
        
jesuscast revised this gist
Oct 16, 2017 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,19 +6,24 @@ def get_flattened(): """ This is just the first part of orthogonal initialization. Taken directly from https://github.com/pytorch/pytorch/blob/master/torch/nn/init.py """ rows = tensor.size(0) cols = tensor[0].numel() flattened = torch.Tensor(rows, cols).normal_(0, 1) return flattened def get_mat(): """ This is what we send when doing the initialization """ wc_dim = 200 mat = nn.utils.weight_norm(nn.Linear(wc_dim, wc_dim, bias=False), name="weight") tensor = mat.weight.data return tensor def exp(): tensor = get_mat() flattened = get_flattened(tensor) # It should fail if being called # in a child process. torch.qr(flattened) if __name__=="__main__": # First call  - 
        
jesuscast revised this gist
Oct 16, 2017 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,9 @@ import multiprocessing as mp def get_flattened(): """ This is just the first part of orthogonal initialization. Taken directly from https://github.com/pytorch/pytorch/blob/master/torch/nn/init.py """ wc_dim = 200 mat = nn.utils.weight_norm(nn.Linear(wc_dim, wc_dim, bias=False), name="weight") tensor = mat.weight.data  - 
        
jesuscast renamed this gist
Oct 16, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
jesuscast created this gist
Oct 16, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import torch import torch.nn as nn import multiprocessing as mp def get_flattened(): wc_dim = 200 mat = nn.utils.weight_norm(nn.Linear(wc_dim, wc_dim, bias=False), name="weight") tensor = mat.weight.data rows = tensor.size(0) cols = tensor[0].numel() flattened = torch.Tensor(rows, cols).normal_(0, 1) return flattened def exp(): # It should fail if being called # in a child process. torch.qr(get_flattened()) if __name__=="__main__": # First call exp() # Now create child process. p = mp.Process(target=exp) p.start() p.join() assert p.exitcode != 0, "Child process call to qr did not fail" print("Child process call to QR failed as expected")