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

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.