Hi. I am reproducing a model, depicted in the following.
I have created a simple model for it as shown below, but i need help in “How to iterate the convolutional layer twice or thrice as shown in above figure”
Hi. I am reproducing a model, depicted in the following.
Hi,
I think by the repetition, they mean having same blocks connected to each other sequentially rather than passing input to a conv layer multiple times.
In the latter case, for instance, if you have a 3-channel input, then after first conv block, you will get 64-channel tensor. Then how can one use same conv block which only accepts 3-channel input for your current tensor which has 64-channels after first iteration? Do they provided any information about it?
The reason I think they just meant to have same block is that they wanted to simply model structure in the given table. Altought you can make sure if they provided information about model size or number of parameters.
Bests
Hi,
In case of implementing repetitive blocks, you can set up an entry block and sequential repetitive blocks after the entry block. Implementing it as a module would be :
class Conv_rep(nn.Module):
def __init__(self, in_channels, out_channels,num_reps, kernel_size=3, stride=1,
padding=1, dilation=1, bias=False):
super(Conv_rep,self).__init__(in_channels, out_channels,num_reps, kernel_size,
stride, padding, dilation,bias)
self.conv_entry=nn.Conv2d(in_channels=in_channels,out_channels=out_channels,
kernel_size=kernel_size,stride=stride,padding=padding)
self.conv_rep=nn.Conv2d(in_channels=out_channels,out_channels=out_channels,
kernel_size=kernel_size,stride=stride,padding=padding)
self.num_reps=num_reps
def forward(self,x):
x_rep=self.conv_entry(x)
for i in range(1,self.num_rep):
x_rep=self.conv_rep(x_rep)
return x_rep
Note that I haven’t added activations or Batch Normalization as nothing of that sort was mentioned, but you should add them according to your model and use-case [as I see you haven’t used activations in your ‘Net’ module]
Thank Dear
Thanks Dear