Hi, to do so the easiest way is to generate two nn.Modules. One for the green part and another one for the pink one.
To share weights you only have to instantiate the class once. To have different ways you need to instantiate classifierX and axiliary classifierX 3 times.
something like:
class GlobalNet(nn.Module):
init---
self.net_in_green = instance()
self.classifier0 = pinkinstance()
self.classifier1 = pinkinstance()
self.classifier2 = pinkinstance()
forward(inputs)----
Here you have to squeeze everything those 3 inputs into batch dimension, assuming you have a single intput it would be similar to
inputs #shape--> batch, 3, other dimensions.-..
inputs = inputs.view(-1,other dimensions)
inputs #shape (3*batch, other dimensions)
Then you apply green net
greenout = self.net_in_green(squeezed input)
Now unsqueeze them with view
output0 = self.classifier0(greenout_unsqueezed0)
output1 = self.classifier1(greenout_unsqueezed1)
output02= self.classifier2(greenout_unsqueezed2)
The same with auxiliar classifier
The only drawback is that batch normalization is also shared…
As far as I know it’s not straight forward to achieve different statistics.
Hi,
I need to design a similar network where modules in the green area should weights, but there is a feedback from the pink area to the green area. Any idea how to do that?