数据加载模块中的迭代错误' numpy'没有属性' Expand_dim'
我想迭代扔火车负载,但我遇到了这个问题,在此错误中有任何帮助。
for imgs, mask in trainloader:
print(imags.shape)
print(masks.shape)
break
AttributeError Traceback (most recent call last)
<ipython-input-31-22799795e016> in <module>()
----> 1 for imgs, mask in trainloader:
2 print(imags.shape)
3 print(masks.shape)
4 break
5 frames
/usr/local/lib/python3.7/dist-packages/numpy/__init__.py in __getattr__(attr)
312
313 raise AttributeError("module {!r} has no attribute "
--> 314 "{!r}".format(__name__, attr))
315
316 def __dir__():
AttributeError: module 'numpy' has no attribute 'expand_dim'
I want to iterate throw the trainloader but I face this problem, Any help in this error .
for imgs, mask in trainloader:
print(imags.shape)
print(masks.shape)
break
AttributeError Traceback (most recent call last)
<ipython-input-31-22799795e016> in <module>()
----> 1 for imgs, mask in trainloader:
2 print(imags.shape)
3 print(masks.shape)
4 break
5 frames
/usr/local/lib/python3.7/dist-packages/numpy/__init__.py in __getattr__(attr)
312
313 raise AttributeError("module {!r} has no attribute "
--> 314 "{!r}".format(__name__, attr))
315
316 def __dir__():
AttributeError: module 'numpy' has no attribute 'expand_dim'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您正试图覆盖Pytorch中的数据加载类,并实例化了一个名为“ Trainloader”的数据。当您覆盖DataLoader类时,您会制作错字。您有expand_dim,单数,应该是expand_dims,复数。
返回到班级定义,即火车加载程序基于并更新该行以说“ Expand_dims”
It looks like you were trying to override the Dataloader class in PyTorch and instantiated one called "trainloader." When you overrode the Dataloader class you made a typo. You have expand_dim, singular, where it should be expand_dims, plural.
Go back to the class definition that trainloader is based on and update the line to say "expand_dims"