Python torch.nn.init.orthogonal_() Examples
The following are 30
code examples of torch.nn.init.orthogonal_().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
torch.nn.init
, or try the search function
.
Example #1
Source File: networks.py From angularGAN with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func)
Example #2
Source File: networks.py From MeshCNN with MIT License | 6 votes |
def init_weights(net, init_type, init_gain): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, init_gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=init_gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=init_gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, init_gain) init.constant_(m.bias.data, 0.0) net.apply(init_func)
Example #3
Source File: train_siamrpn.py From Siamese-RPN-pytorch with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): # this will apply to each layer classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('conv')!=-1 or classname.find('Linear')!=-1): if init_type=='normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')#good for relu elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) #print('initialize network with %s' % init_type) net.apply(init_func)
Example #4
Source File: test_siamrpn.py From Siamese-RPN-pytorch with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): # this will apply to each layer classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('conv')!=-1 or classname.find('Linear')!=-1): if init_type=='normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')#good for relu elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) #print('initialize network with %s' % init_type) net.apply(init_func)
Example #5
Source File: train_siamrpn.py From Siamese-RPN-pytorch with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): # this will apply to each layer classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('conv')!=-1 or classname.find('Linear')!=-1): if init_type=='normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')#good for relu elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) #print('initialize network with %s' % init_type) net.apply(init_func)
Example #6
Source File: utils.py From dgl with Apache License 2.0 | 6 votes |
def weights_init(m): ''' Code from https://gist.github.com/jeasinema/ed9236ce743c8efaf30fa2ff732749f5 Usage: model = Model() model.apply(weight_init) ''' if isinstance(m, nn.Linear): init.xavier_normal_(m.weight.data) init.normal_(m.bias.data) elif isinstance(m, nn.GRUCell): for param in m.parameters(): if len(param.shape) >= 2: init.orthogonal_(param.data) else: init.normal_(param.data)
Example #7
Source File: networks.py From densebody_pytorch with GNU General Public License v3.0 | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func)
Example #8
Source File: BigGANdeep.py From BigGAN-PyTorch with MIT License | 6 votes |
def init_weights(self): self.param_count = 0 for module in self.modules(): if (isinstance(module, nn.Conv2d) or isinstance(module, nn.Linear) or isinstance(module, nn.Embedding)): if self.init == 'ortho': init.orthogonal_(module.weight) elif self.init == 'N02': init.normal_(module.weight, 0, 0.02) elif self.init in ['glorot', 'xavier']: init.xavier_uniform_(module.weight) else: print('Init style not recognized...') self.param_count += sum([p.data.nelement() for p in module.parameters()]) print('Param count for G''s initialized parameters: %d' % self.param_count) # Note on this forward function: we pass in a y vector which has # already been passed through G.shared to enable easy class-wise # interpolation later. If we passed in the one-hot and then ran it through # G.shared in this forward function, it would be harder to handle. # NOTE: The z vs y dichotomy here is for compatibility with not-y
Example #9
Source File: BigGANdeep.py From BigGAN-PyTorch with MIT License | 6 votes |
def init_weights(self): self.param_count = 0 for module in self.modules(): if (isinstance(module, nn.Conv2d) or isinstance(module, nn.Linear) or isinstance(module, nn.Embedding)): if self.init == 'ortho': init.orthogonal_(module.weight) elif self.init == 'N02': init.normal_(module.weight, 0, 0.02) elif self.init in ['glorot', 'xavier']: init.xavier_uniform_(module.weight) else: print('Init style not recognized...') self.param_count += sum([p.data.nelement() for p in module.parameters()]) print('Param count for D''s initialized parameters: %d' % self.param_count)
Example #10
Source File: BigGAN.py From BigGAN-PyTorch with MIT License | 6 votes |
def init_weights(self): self.param_count = 0 for module in self.modules(): if (isinstance(module, nn.Conv2d) or isinstance(module, nn.Linear) or isinstance(module, nn.Embedding)): if self.init == 'ortho': init.orthogonal_(module.weight) elif self.init == 'N02': init.normal_(module.weight, 0, 0.02) elif self.init in ['glorot', 'xavier']: init.xavier_uniform_(module.weight) else: print('Init style not recognized...') self.param_count += sum([p.data.nelement() for p in module.parameters()]) print('Param count for G''s initialized parameters: %d' % self.param_count) # Note on this forward function: we pass in a y vector which has # already been passed through G.shared to enable easy class-wise # interpolation later. If we passed in the one-hot and then ran it through # G.shared in this forward function, it would be harder to handle.
Example #11
Source File: BigGAN.py From BigGAN-PyTorch with MIT License | 6 votes |
def init_weights(self): self.param_count = 0 for module in self.modules(): if (isinstance(module, nn.Conv2d) or isinstance(module, nn.Linear) or isinstance(module, nn.Embedding)): if self.init == 'ortho': init.orthogonal_(module.weight) elif self.init == 'N02': init.normal_(module.weight, 0, 0.02) elif self.init in ['glorot', 'xavier']: init.xavier_uniform_(module.weight) else: print('Init style not recognized...') self.param_count += sum([p.data.nelement() for p in module.parameters()]) print('Param count for D''s initialized parameters: %d' % self.param_count)
Example #12
Source File: networks.py From MADAN with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func)
Example #13
Source File: mglattice.py From Chinese_NRE with MIT License | 6 votes |
def reset_parameters(self): """ Initialize parameters following the way proposed in the paper. """ init.orthogonal_(self.weight_ih.data) init.orthogonal_(self.alpha_weight_ih.data) weight_hh_data = torch.eye(self.hidden_size) weight_hh_data = weight_hh_data.repeat(1, 3) self.weight_hh.data.set_(weight_hh_data) alpha_weight_hh_data = torch.eye(self.hidden_size) alpha_weight_hh_data = alpha_weight_hh_data.repeat(1, 1) self.alpha_weight_hh.data.set_(alpha_weight_hh_data) # The bias is just set to zero vectors. if self.use_bias: init.constant_(self.bias.data, val=0) init.constant_(self.alpha_bias.data, val=0)
Example #14
Source File: init.py From DFL-CNN with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): # this will apply to each layer classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('conv')!=-1 or classname.find('Linear')!=-1): if init_type=='normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')#good for relu elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) #print('initialize network with %s' % init_type) net.apply(init_func)
Example #15
Source File: networks.py From deepsaber with GNU General Public License v3.0 | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func)
Example #16
Source File: treelstm.py From QANet-PyTorch with MIT License | 6 votes |
def reset_parameters(self): if self.use_leaf_rnn: init.kaiming_normal_(self.leaf_rnn_cell.weight_ih.data) init.orthogonal_(self.leaf_rnn_cell.weight_hh.data) init.constant_(self.leaf_rnn_cell.bias_ih.data, val=0) init.constant_(self.leaf_rnn_cell.bias_hh.data, val=0) # Set forget bias to 1 self.leaf_rnn_cell.bias_ih.data.chunk(4)[1].fill_(1) if self.bidirectional: init.kaiming_normal_(self.leaf_rnn_cell_bw.weight_ih.data) init.orthogonal_(self.leaf_rnn_cell_bw.weight_hh.data) init.constant_(self.leaf_rnn_cell_bw.bias_ih.data, val=0) init.constant_(self.leaf_rnn_cell_bw.bias_hh.data, val=0) # Set forget bias to 1 self.leaf_rnn_cell_bw.bias_ih.data.chunk(4)[1].fill_(1) else: init.kaiming_normal_(self.word_linear.weight.data) init.constant_(self.word_linear.bias.data, val=0) self.treelstm_layer.reset_parameters() init.normal_(self.comp_query.data, mean=0, std=0.01)
Example #17
Source File: networks.py From colorization-pytorch with MIT License | 6 votes |
def init_weights(net, init_type='xavier', gain=0.02): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func)
Example #18
Source File: init.py From EAST with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): # this will apply to each layer classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('conv')!=-1 or classname.find('Linear')!=-1): if init_type=='normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')#good for relu elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print("EAST <==> Prepare <==> Init Network'{}' <==> Begin".format(init_type)) net.apply(init_func)
Example #19
Source File: main_utils.py From HPLFlowNet with GNU General Public License v3.0 | 6 votes |
def init_weights_multi(m, init_type, gain=1.): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) # ---------------- Pretty sure the following functions/classes are common ----------------
Example #20
Source File: networks.py From Shift-Net_pytorch with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func)
Example #21
Source File: __init__.py From srntt-pytorch with Apache License 2.0 | 6 votes |
def init_weights(net, init_type='normal', init_gain=0.02): def init_func(m): name = m.__class__.__name__ if hasattr(m, 'weight') and ('Conv' in name or 'Linear' in name): if init_type == 'normal': init.normal_(m.weight.data, 0.0, init_gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=init_gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=init_gain) else: raise NotImplementedError( f'initialization method [{init_type}] is not implemented') if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif 'BatchNorm2d' in name: init.normal_(m.weight.data, 1.0, init_gain) init.constant_(m.bias.data, 0.0) net.apply(init_func)
Example #22
Source File: model_utils.py From ganimation_replicate with MIT License | 6 votes |
def init_weights(net, init_type='normal', gain=0.02): def init_func(m): classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: init.normal_(m.weight.data, 1.0, gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func)
Example #23
Source File: value_head.py From vel with MIT License | 5 votes |
def reset_weights(self): # init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') init.orthogonal_(self.linear_layer.weight, gain=1.0) init.constant_(self.linear_layer.bias, 0.0)
Example #24
Source File: action_head.py From vel with MIT License | 5 votes |
def reset_weights(self): init.orthogonal_(self.linear_layer.weight, gain=0.01) init.constant_(self.linear_layer.bias, 0.0)
Example #25
Source File: noisy_linear.py From vel with MIT License | 5 votes |
def reset_weights(self): init.orthogonal_(self.weight_mu, gain=math.sqrt(2)) init.constant_(self.bias_mu, 0.0) # Initialize the "random weights" to constants self.weight_sigma.data.fill_(self.initial_std_dev / math.sqrt(self.in_features)) self.bias_sigma.data.fill_(self.initial_std_dev / math.sqrt(self.out_features))
Example #26
Source File: deterministic_action_head.py From vel with MIT License | 5 votes |
def reset_weights(self): """ Initialize weights to sane defaults """ init.orthogonal_(self.linear_layer.weight, gain=0.01) init.constant_(self.linear_layer.bias, 0.0)
Example #27
Source File: q_head.py From vel with MIT License | 5 votes |
def reset_weights(self): init.orthogonal_(self.linear_layer.weight, gain=1.0) init.constant_(self.linear_layer.bias, 0.0)
Example #28
Source File: networks.py From 2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement with MIT License | 5 votes |
def init_weights(net, init_type='normal', init_gain=0.02): """Initialize network weights. Parameters: net (network) -- network to be initialized init_type (str) -- the name of an initialization method: normal | xavier | kaiming | orthogonal init_gain (float) -- scaling factor for normal, xavier and orthogonal. We use 'normal' in the original pix2pix and CycleGAN paper. But xavier and kaiming might work better for some applications. Feel free to try yourself. """ def init_func(m): # define the initialization function classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1): if init_type == 'normal': init.normal_(m.weight.data, 0.0, init_gain) elif init_type == 'xavier': init.xavier_normal_(m.weight.data, gain=init_gain) elif init_type == 'kaiming': init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') elif init_type == 'orthogonal': init.orthogonal_(m.weight.data, gain=init_gain) else: raise NotImplementedError('initialization method [%s] is not implemented' % init_type) if hasattr(m, 'bias') and m.bias is not None: init.constant_(m.bias.data, 0.0) elif classname.find('BatchNorm2d') != -1: # BatchNorm Layer's weight is not a matrix; only normal distribution applies. init.normal_(m.weight.data, 1.0, init_gain) init.constant_(m.bias.data, 0.0) print('initialize network with %s' % init_type) net.apply(init_func) # apply the initialization function <init_func>
Example #29
Source File: modules.py From deep-code-search with MIT License | 5 votes |
def init_weights(self): nn.init.uniform_(self.embedding.weight, -0.1, 0.1) nn.init.constant_(self.embedding.weight[0], 0) for name, param in self.lstm.named_parameters(): # initialize the gate weights # adopted from https://gist.github.com/jeasinema/ed9236ce743c8efaf30fa2ff732749f5 #if len(param.shape)>1: # weight_init.orthogonal_(param.data) #else: # weight_init.normal_(param.data) # adopted from fairseq if 'weight' in name or 'bias' in name: param.data.uniform_(-0.1, 0.1)
Example #30
Source File: q_distributional_head.py From vel with MIT License | 5 votes |
def reset_weights(self): init.orthogonal_(self.linear_layer.weight, gain=1.0) init.constant_(self.linear_layer.bias, 0.0)