I wanted to play around with RNN’s a bit, and was curious if LSTM could predict the next 2 number given a single number, e.g.
x =  y = [2, 3]
For this, I tried the following:
def create_training_data(n): x = torch.randint(0, 200, size=(n, 1), dtype=torch.float32, requires_grad=True) y = torch.cat([x+1, x+2], dim=1) return x, y x, y = create_training_data(1000) model= nn.Sequential( nn.Linear(1, 10), nn.ReLU(), nn.LSTM(input_size=10, hidden_size=10), nn.Linear(10, 2) ) loss_fn = nn.MSELoss() optimizer = torch.optim.SGD(model.parameters(), lr=0.01, momentum=0.9) train = data_utils.TensorDataset(x, y) train_dataloder = DataLoader(train, batch_size=64, shuffle=True) for batch_idx, (x, y) in enumerate(train_dataloder): res = model(x)
However, I get the error:
TypeError: linear(): argument 'input' (position 1) must be Tensor, not tuple
I do not understand why it is a tuple though, it should clearly be a tensor. What am I doing wrong?