bs=64 # batch size
xb = x_train[0:bs] # a mini-batch from x
preds = model(xb) # predictions
preds[0], preds.shape
yb = y_train[0:bs]
loss_func(preds, yb)
IndexError Traceback(最近一次通话最近) 在()中 ----> 1 loss_func(preds,yb)
nll中的(输入,目标) 1 def nll(输入,目标): ----> 2 return -input [range(target.shape [0]),target] .mean()
IndexError:用作索引的张量必须为long,byte或bool张量