lhoyer / MIC

[CVPR23] Official Implementation of MIC: Masked Image Consistency for Context-Enhanced Domain Adaptation
269 stars 40 forks source link

BatchNorm dimension mismatch #33

Open jzy95310 opened 1 year ago

jzy95310 commented 1 year ago

Dear authors,

I'm trying to reproduce the office-home experiments in the cls directory with python run_experiments.py --exp 1. However, I commented out Line 117 ('VisDA2017', 'Synthetic', 'Real'). When running the experiment, I got the following error:

[INFORMATION] The bottleneck dim is  256
[Masking] Use color augmentation.
lr_bbone: 0.0002
lr_btlnck: 0.002
Traceback (most recent call last):
  File "cdan_mcc_sdat_masking.py", line 393, in <module>
    main(args)
  File "cdan_mcc_sdat_masking.py", line 171, in main
    train(train_source_iter, train_target_iter, classifier, teacher,
  File "cdan_mcc_sdat_masking.py", line 235, in train
    pseudo_label_t, pseudo_prob_t = teacher(x_t)
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "../dalib/modules/teacher.py", line 58, in forward
    logits, _ = self.ema_model(target_img)
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "../common/modules/classifier.py", line 80, in forward
    f = self.bottleneck(f)
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
    input = module(input)
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/nn/modules/batchnorm.py", line 168, in forward
    return F.batch_norm(
  File "/hpc/home/zj63/.local/lib/python3.8/site-packages/torch/nn/functional.py", line 2282, in batch_norm
    return torch.batch_norm(
RuntimeError: running_mean should contain 197 elements not 256

Could you please give me some instructions on how to specify the hyperparameters correctly to reproduce only the office-home experiments?

Thanks and best regards

LZ-CH commented 1 year ago

Hi, have you solved this problem? I also encountered the same problem.

kaqiz commented 5 months ago

Hi, have you solved this problem? I also encountered the same problem.

jzy95310 commented 5 months ago

Hi, have you solved this problem? I also encountered the same problem.

No, I ended up using another method for benchmarking lol...