I tried to print out the summary of a simple model I created with LSTM and CNN but I got the error :AttributeError:‘tuple’ object has no attribute ‘size’.
Here is my code :
class lstmCnn_model(nn.Module):
def __init__(self):
super(lstmCnn_model, self).__init__()
self.lstm = nn.LSTM(input_size=384, hidden_size=64, batch_first=True, bidirectional=True)
self.layernorm = nn.LayerNorm(128)
self.conv = nn.Conv1d(in_channels=128, out_channels=64, kernel_size=3)
def forward(self,x):
x = x.view(x.size(0), x.size(2),-1)
x, _ = self.lstm(x)
x = self.layernorm(x)
x = self.conv(x)
print(x.shape)
return x
model = lstmCnn_model()
model.to(device)
print(model)
summary(model, input_size= (3,128,128))