I have multiple independent neural networks that take different inputs, and I will need their output concatenated together. What might be the way to avoid loop in forward()
. Particularly, if the set of networks have the same architectures and their sizes are small, there must be a way to “stack” all networks into one, and run the forward function one time for all. But any simple way to do it? Thanks.
My current forward() function with loop is (self.net and x are two lists for networks and inputs):
def forward(self, x):
output = [self.net[i](x[i]) for i in range(len(self.net))]