Hanjun-Dai / cvb

Code for Coupled Variational Bayes via Optimization Embedding
10 stars 3 forks source link

problem of running mnist dataset #1

Open HaidYi opened 5 years ago

HaidYi commented 5 years ago

Hello maintainers,

When I used the mnist dataset shared with dropbox to train the model, I got an error. The command I used is ./run_parametric_opt.sh in the directory of mnist and traceback is

Namespace(arch='cnn', batch_size=100, binary=1, ctx='gpu', data_mean=0.0, data_std=1.0, dropbox='../../dropbox', epoch_save=1, gnorm_lambda=0.0, gnorm_type='lp1', hidden_dim=128, img_size=32, init_model_dump=None, inner_opt='RMSprop', latent_dim=32, learning_rate=0.0001, log_file='./result/log.txt', mda_decay_factor=0.5, mda_lr=0.001, min_mda_lr=1e-06, n_classes=10, n_dist=20, num_epochs=20, pcd=0, rbm_model='bernoulli', save_dir='./result', saved_model=None, seed=1, test_batch_size=100, test_is=0, unroll_steps=3, unroll_test=1, vis_num=0)
0it [00:00, ?it/s]Traceback (most recent call last):
  File "mnist_parametric_opt.py", line 221, in <module>
    test_loss = test(epoch)
  File "mnist_parametric_opt.py", line 111, in test
    for i, (data, _) in tqdm(enumerate(test_loader)):
  File "/opt/anaconda2/lib/python2.7/site-packages/tqdm/_tqdm.py", line 979, in __iter__
    for obj in iterable:
  File "/opt/anaconda2/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 560, in __next__
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/home/haidyi/models/research/cvb/cvb/mnist/mnist_common.py", line 192, in __getitem__
    img = self.transform(img)
  File "/opt/anaconda2/lib/python2.7/site-packages/torchvision/transforms/transforms.py", line 61, in __call__
    img = t(img)
  File "/opt/anaconda2/lib/python2.7/site-packages/torchvision/transforms/transforms.py", line 164, in __call__
    return F.normalize(tensor, self.mean, self.std, self.inplace)
  File "/opt/anaconda2/lib/python2.7/site-packages/torchvision/transforms/functional.py", line 208, in normalize
    tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: output with shape [1, 32, 32] doesn't match the broadcast shape [3, 32, 32]

Can you help me address this problem?

Thank you by advance for your help.

Hanjun-Dai commented 5 years ago

Hi,

I just run the script and it seems working properly.

I'm using: torch==1.0.0 torchvision=0.2.1

HaidYi commented 5 years ago

Hi,

I just run the script and it seems working properly.

I'm using: torch==1.0.0 torchvision=0.2.1

Thank you for your quick answer. My environment is

python=2.7.16 torch==1.1.0 torchvision==0.3.0

I am not sure whether it is because some apis are changed from 0.2.1 to 0.3.0. I will try to use docker to create the same environment and try again.