What can I use in Pytorch to remplace caffe's weight filler
I'm writing a pytorch model based on the caffe model below. Do you know how I can write weight filler and bias filler in pytorch ?
layer {
  name: &quot;conv3&quot;
  type: &quot;Convolution&quot;
  bottom: &quot;pool2&quot;
  top: &quot;conv3&quot;
  param {
    lr_mult: 1
    decay_mult: 1
  }
  convolution_param {
    num_output: 128
    pad_h: 0
    pad_w: 1
    kernel_h: 1
    kernel_w: 3
    stride: 1
    weight_filler {
      type: &quot;gaussian&quot;
      std: 0.1
    }
    bias_filler {
      type: &quot;constant&quot;
      value: 0
    }
  }
}

Thank you

Pytorch has torch.nn.init library to help with init weights of a network.
You probably want to use nn.init.normal_ for the &quot;gaussian&quot; filler, and nn.init.constant_ for the &quot;constant&quot; filler of the bias.
You can use a function to fill the weights of a module m:
def init_weights(m):
    if type(m) == nn.Conv2d:
        torch.nn.init.normal_(m.weight, std=0.1)
        if m.bias is not None:
            torch.nn.init.constant_(m.bias, val=0)

# define the net
net = MyCaffeLikeNetwork()
# use the function to init all weights of the net
net.apply(init_weights)

For more information on weight init in pytorch you can look at this detailed answer.
