parameters: (self)
docstring: _initialize_weights
docstring_summary: _initialize_weights
docstring_tokens: _initialize_weights
function: def _initialize_weights(self):
          """
          _initialize_weights
          """
          def init_linear_weight(m):
              m.weight.set_data(Tensor(np.random.normal(
                  0, 0.01, m.weight.data.shape).astype("float32")))
              if m.bias is not None:
                  m.bias.set_data(
                      Tensor(np.zeros(m.bias.data.shape, dtype="float32")))
  
          for m in self.cells():
              if isinstance(m, nn.Conv2d):
                  n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
                  m.weight.set_data(Tensor(np.random.normal(0, np.sqrt(2. / n),
                                                            m.weight.data.shape).astype("float32")))
                  if m.bias is not None:
                      m.bias.data.zero_()
                  m.weight.requires_grad = True
              elif isinstance(m, nn.BatchNorm2d):
                  m.gamma.set_data(
                      Tensor(np.ones(m.gamma.data.shape, dtype="float32")))
                  m.beta.set_data(
                      Tensor(np.zeros(m.beta.data.shape, dtype="float32")))
              elif isinstance(m, nn.Dense):
                  init_linear_weight(m)
function_tokens: def _initialize_weights ( self ) : def init_linear_weight ( m ) : m . weight . set_data ( Tensor ( np . random . normal ( 0 , 0.01 , m . weight . data . shape ) . astype ( "float32" ) ) ) if m . bias is not None : m . bias . set_data ( Tensor ( np . zeros ( m . bias . data . shape , dtype = "float32" ) ) ) for m in self . cells ( ) : if isinstance ( m , nn . Conv2d ) : n = m . kernel_size [ 0 ] * m . kernel_size [ 1 ] * m . out_channels m . weight . set_data ( Tensor ( np . random . normal ( 0 , np . sqrt ( 2. / n ) , m . weight . data . shape ) . astype ( "float32" ) ) ) if m . bias is not None : m . bias . data . zero_ ( ) m . weight . requires_grad = True elif isinstance ( m , nn . BatchNorm2d ) : m . gamma . set_data ( Tensor ( np . ones ( m . gamma . data . shape , dtype = "float32" ) ) ) m . beta . set_data ( Tensor ( np . zeros ( m . beta . data . shape , dtype = "float32" ) ) ) elif isinstance ( m , nn . Dense ) : init_linear_weight ( m )