数据加载模块中的迭代错误' numpy'没有属性' Expand_dim'

发布于 2025-01-26 01:19:43 字数 779 浏览 3 评论 0原文

我想迭代扔火车负载,但我遇到了这个问题,在此错误中有任何帮助。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百变从容 2025-02-02 01:19:43

看来您正试图覆盖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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文