andreasveit/triplet-network-pytorch

Invalid Index of 0-dim tensor

Opened this issue · 2 comments

losses.update(loss_triplet.data[0], data1.size(0))

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

@soulslicer change
'losses.update(loss_triplet.data[0], data1.size(0))'

to
'losses.update(loss_triplet.data, data1.size(0))'
change data[0] to data in all of the code

rafis commented

or to .data.item()