Hi I am new to Pytorch, appreciated if you can help
I do two clsss classification.
My train.size() is (100L, 37L), labels.size() is (100L,),
but when I reshape to x, x will be (5L, 20L, 37L)(I set sequence_length=20),
then outputs.size() is (20L, 2L) , y.size() is (100L,).
If I set sequence_length=1, I can run it but there is no meaning to do it.
How can I reshape the y so the y(label) can coresspoding to output?
Thank you very much.
//Train the Model
for epoch in range(num_epochs):
for i, (train, labels) in enumerate(train_loader):
x = Variable(train.view(-1, sequence_length, input_size))
y = Variable(labels)
outputs = rnn(x)
loss = criterion(outputs, y)
optimizer.zero_grad()
loss.backward()
optimizer.step()
if (i + 1) % 20 == 0:
print ('Epoch [%d/%d], Step [%d/%d], Loss: %.4f'
% (epoch + 1, num_epochs, i + 1, len(trainDataset) // batch_size, loss.data[0]))