When I am running the code, here is an error for the program.
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 141, in
train(epoch)
File "", line 95, in train
error, _ = model.calculate_classification_error(data, bag_label)
File "/home/huafeng/AttentionDeepMIL-master/model.py", line 60, in calculate_classification_error
error = 1. - Y_hat.eq(Y).cpu().float().mean().data[0]
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
And I have tried to change .data[0] into .data or .item(), but neither worked, could anyone give me some suggestions?
Pytorch version:1.1.0
When I am running the code, here is an error for the program.
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 141, in
train(epoch)
File "", line 95, in train
error, _ = model.calculate_classification_error(data, bag_label)
File "/home/huafeng/AttentionDeepMIL-master/model.py", line 60, in calculate_classification_error
error = 1. - Y_hat.eq(Y).cpu().float().mean().data[0]
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
And I have tried to change .data[0] into .data or .item(), but neither worked, could anyone give me some suggestions?
Pytorch version:1.1.0