【问题标题】:module 'torch' has no attribute 'frombuffer' in Google Colabmodule \'torch\' has no attribute \'frombuffer\' in Google Colab
【发布时间】:2022-12-01 13:27:33
【问题描述】:
data_root = os.path.join(os.getcwd(), "data")
transform = transforms.Compose(
[
 transforms.ToTensor(),
 transforms.Normalize([0.5], [0.5]),
]
)
fashion_mnist_dataset = FashionMNIST(data_root, download = True, train = True, transform = transform)

Error Message

/usr/local/lib/python3.7/dist-packages/torchvision/datasets/mnist.py in read_sn3_pascalvincent_tensor(path, strict) 524 # we need to reverse the bytes before we can read them with torch.frombuffer(). 525 needs_byte_reversal = sys.byteorder == "little" and num_bytes_per_value > 1 --> 526 parsed = torch.frombuffer(bytearray(data), dtype=torch_type, offset=(4 * (nd + 1))) 527 if needs_byte_reversal: 528 parsed = parsed.flip(0)

AttributeError: module 'torch' has no attribute 'frombuffer'

what can i do for this err in Colab

【问题讨论】:

    标签: python-3.x pytorch


    【解决方案1】:

    I tried your code in my Google Colab by adding the codes (to import the libraries) below, but it works well without errors.

    import os
    from torchvision import transform
    from torchvision.datasets import FashionMNIST
    

    I used

    • torchvision 0.13.0+cu113
    • google-colab 1.0.0
    • Runtime GPU (when I set "None," it also works)

    Do you get errors when you also use the same codes above? Do you use another versions?

    【讨论】:

      猜你喜欢
      • 2021-10-09
      • 2022-10-19
      • 2022-12-01
      • 2019-01-08
      • 2021-08-14
      • 2020-07-09
      • 2022-08-04
      • 2015-09-26
      • 2020-11-23
      相关资源
      最近更新 更多