0

I have a following neural network architecture:

A(1x16x5x5)---\
                 -> concat(A,B) (1x32x5x5) --> Conv2D -> classification 
B(1x16x5x5)---/

Conv2D=nn.Conv2d(32,16, kernel_size = 1, stride = 1 , padding = 0)

If I want to choose branch A only for testing, then I initialized Conv2d layer like this:

 convWeights = np.ones((16,32,1,1))
 convWeights[:,16:,:,:] = 0
 myNetwork.Conv2.weight = nn.Parameter(torch.from_numpy(convWeights).float().cuda()) 
 myNetwork.Conv2.bias.data.fill_(0)

However, it didn't give the expected classification results. Therefore, I think, I have a problem with the above codes and probably I'm missing something. Shortly, how do I initialize conv2d layer so that it chooses only branch A?

Bedrick Kiq
  • 365
  • 1
  • 5
  • 14
  • "However, it didn't give the expected classification results." what do you mean by that? What are you expecting that is not happening? Also what do you mean by "choosing branch A"? You may zero-out the weights but those will still be passed to Conv2D from your diagram. – Szymon Maszke Oct 24 '20 at 13:04
  • Expected classfication results : %10 accuracy. Choosing branch A means that setting conv2d layers weight so that calculation on the next layer is only affected by the branch A. – Bedrick Kiq Oct 24 '20 at 13:56

0 Answers0