I can print it but I can't use it #6018
-
It was really weird to find It shows IndexError: index 2 is out of bounds for dimension 0 with size 2 for a while it can print a. correct = 0
for i, data in enumerate(train_loader):
optimizer.zero_grad()
data = data.to(args.device)
data = data.to(args.device)
##print(data.validate())
out = model(data)
loss_0 = F.nll_loss(out, data.y)
with torch.no_grad():
loss_1_ = 1+torch.abs(F.nll_loss(out[0,:], data.y[0])-loss_0)
loss_2_ = 1+torch.abs(F.nll_loss(out[1,:], data.y[1])-loss_0)
a = data.y[2]
if i == 1:
print("data.y[2]:", data.y[2])
b = out[2,:]
loss_3_ = 1+torch.abs(F.nll_loss(b, a)-loss_0)
loss_ = loss_1_*F.nll_loss(out[0,:], data.y[0])+loss_2_*F.nll_loss(out[1,:], data.y[1])+loss_3_*F.nll_loss(out[2,:], data.y[2])
#loss = loss_.cuda()
loss = F.nll_loss(out, data.y)##,weight = loss_)
loss.backward() and it does print data.y[2] while it shows IndexError: index 2 is out of bounds for dimension 0 with size 2 on a = data.y[2].
Things's getting more wired,why it did not show size mismatch for loss_2_ etc~ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
I couldn't understand the problems. May you list your problems by point so that it may be more clear? |
Beta Was this translation helpful? Give feedback.
I couldn't understand the problems. May you list your problems by point so that it may be more clear?