question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error about mnist data shape

See original GitHub issue

when i run ‘main.py’, i got following error.

`Traceback (most recent call last):

File “Domain_Adaption/pytorch-adda/main.py”, line 41, in <module> src_encoder, src_classifier, src_data_loader) File “Domain_Adaption/pytorch-adda/core/pretrain.py”, line 32, in train_src for step, (images, labels) in enumerate(data_loader): File “/envs//lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 615, in next batch = self.collate_fn([self.dataset[i] for i in indices]) File /envs//lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 615, in <listcomp> batch = self.collate_fn([self.dataset[i] for i in indices]) File "/envs//lib/python3.6/site-packages/torchvision/datasets/mnist.py", line 95, in getitem img = self.transform(img) File "/envs//lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 60, in call img = t(img) File "/envs//lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 163, in call return F.normalize(tensor, self.mean, self.std, self.inplace) File "/envs/*/lib/python3.6/site-packages/torchvision/transforms/functional.py”, line 208, in normalize tensor.sub_(mean[:, None, None]).div_(std[:, None, None]) RuntimeError: output with shape [1, 28, 28] doesn’t match the broadcast shape [3, 28, 28] `

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
MiZhiLiangcommented, Mar 16, 2020

transforms.Normalize([0.5],[0.5]) This way in my settings can work.

0reactions
mvivekccommented, Jun 26, 2019

Downgrading torch and torchvision to 0.2.0 and 0.2.1 solved this issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dense shape error when training mnist digit dataset using ...
I think you have forgotten to convert your y_test to one-hot vectors. y_test= tf.keras.utils.to_categorical(y_test).
Read more >
Shape mismatch error when trying to train basic example ...
I fixed this error by creating my own version of imagen_pytorch.data.Dataset that converts the image to grayscale (which it already is) with 3 ......
Read more >
Tensorflow - I don't get the right shapes - `ValueError
The error occurs because of the x_test shape. In your code, you set it actually to x_train. [x_test = x_train / 255.0] Furthermore,...
Read more >
3.3. The MNIST Dataset — conx 3.7.9 documentation
The MNIST dataset contains 70,000 images of handwritten digits (zero to nine) that have been ... Input Summary: * shape : (28, 28,...
Read more >
Error loading MNIST Images - MATLAB Answers - MathWorks
I'm using the loadMNISTImages function, to load the images to my network, but I get an error in nntrain function that my train_set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found