TypeError: ‘int‘ object is not callable

数据加载的时候遇到TypeError: 'int' object is not callable
原因:数据不是Tensor类型的而是np.array或其他类型的。
print("pred.size(0)", pred.shape[0])     # np.array
#for batch_index in range(pred.size(0)):   # tensor size()  
	pass
for batch_index in range(pred.shape[0]):
	pass

#或者将pred转为tensor

猜你喜欢

转载自blog.csdn.net/weixin_40437821/article/details/113742230