Hello,
I’ve read nn.Module with multiple inputs, and this is more of a follow-up question here. I’m curious if there is a way to concatenate a tensor in the middle of sequential. Or in the middle of a model, for example:
def __init__(self, z_dim=10, nc=1,stim=np.random.randint(13,size=8)):
super(BetaVAE_H_wStim, self).__init__()
torch.backends.cudnn.benchmark = True
self.z_dim = z_dim
self.nc = nc
self.stim = stim
self.encoder = nn.Sequential(
nn.Conv3d(nc, 32, 3, (1,2,2), 1), # B, 32, 4, 48, 48
nn.ReLU(True),
nn.Conv3d(32, 32, 3, (1,2,2), 1), # B, 32, 2, 24, 24
nn.ReLU(True),
nn.Conv3d(32, 64, 3, 2, 1), # B, 64, 1, 12, 12
nn.ReLU(True),
nn.Conv3d(64, 64, 3, 2, 1), # B, 64, 6, 6
nn.ReLU(True),
nn.Conv3d(64, 256, 3, 2, 1), # B, 64, 6, 6
nn.ReLU(True),
View((-1,256)), # B, 256
# i want to concat here
nn.Linear(256,z_dim*2), # B, z_dim*2
)
Where my comment is is where I’m hoping to concat a numpy array of size 8 (1 axis) to my tensor in the model. It’s different from the problem posted above. I actually want those values to be fully connected to the output of this model.
Is there an easy way to do this?