Hello friends, I have a problem on my code . It gives an error below:
RuntimeError: size mismatch, m1: [1 x 1682], m2: [20 x 1682] at d:\downloads\pytorch-master-1\torch\lib\th\generic/THTensorMath.c:1238
I am putting the problematic code below . Could anyone help me ? I got crazy due to this error .
for epoch in range(1,nb_epoch +1):
train_loss = 0
s = 0.
for id_user in range(nb_users):
input = Variable(training_set[id_user]).unsqueeze(0)
target = input.clone()
if torch.sum(target.data > 0) > 0:
output = sae(input)
target.require_grad = False
output[target == 0] = 0
loss = criterion(output,target)
mean_corrector = nb_movies / float(torch.sum(target.data > 0 ) +1e-10)
loss.backward()
train_loss += np.sqrt(loss.data[0]*mean_corrector)
s += 1.
optimizer.step()
print('epoch: ’ + str(epoch) + ’ loss: ’ + str(train_loss/s))