TypeError: ‘torch.Size’ object is not callable
- 问题描述
>>> bbb=torch.randn(2,3,4)
>>> bbb.shape(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'torch.Size' object is not callable
解决方法
>>> bbb.size(0)
2
或者:
>>> bbb.shape[1]
3
>>> bbb.shape[0]
2