CuthbertCai / pytorch_DAN

An implementation of Deep Adaptation Network with pytorch
107 stars 21 forks source link

Size mis-match #3

Open ghost opened 4 years ago

ghost commented 4 years ago

RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]

CuthbertCai commented 4 years ago

RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]

I'm not sure if you meet this error when extracting features of MNIST. If so, the shape of MNIST image should be expanded from [1, 28, 28] to [3, 28, 28] in line 39 of train.py. If you meet the error in other situations, please let me know.

ghost commented 3 years ago

Actually the errors was faced while calling the dataloader. I figured out what went wrong. In the code, the MNIST dataset is single channel while loading the dataloader. However, in the params.py the "mean and "std" for MNIST dataset is [0.5,0.5,0.5] and so on. I think this array should contain only a single number for mean and std for MNIST.

Crestina2001 commented 1 year ago

Hi, I have the same problem, and how could I fix it?

doduythao commented 8 months ago

@Crestina2001 change param of mean, std from (0.5,0.5,0.5) to (0,5,) for MNIST (not for MNIST_M) and that's gonna be ok. (don't change for params.py only (because it is used for both mnist, mnist_m. So you have to fix it by that way. (I fixed by hard code), you can fix by opening another param for mnist and mnist_m separately.