Iterate/repeat convolution layer twice or thrice

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”


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.


1 Like

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)

      def forward(self,x):
           for i in range(1,self.num_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 :slight_smile:

Thanks Dear :slight_smile: