Jingkang50 / OpenOOD

Benchmarking Generalized Out-of-Distribution Detection
MIT License
858 stars 108 forks source link

Missing required positional arguments in `_ISHTLinear.forward()` #224

Closed PQLLUX closed 8 months ago

PQLLUX commented 8 months ago

Hi, I've tried training ISH similarly to provided example in scripts/odd./imagenet_train_ish.sh, but I receive following error:

-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 69, in _wrap
    fn(i, *args)
  File "/notebooks/OpenOOD/openood/utils/launch.py", line 132, in _distributed_worker
    main_func(*args)
  File "/notebooks/OpenOOD/main.py", line 24, in main
    pipeline.run()
  File "/notebooks/OpenOOD/openood/pipelines/train_pipeline.py", line 65, in run
    net, train_metrics = trainer.train_epoch(epoch_idx)
  File "/notebooks/OpenOOD/openood/trainers/ish_trainer.py", line 63, in train_epoch
    logits_classifier, feature = self.net(data, return_feature=True)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1156, in forward
    output = self._run_ddp_forward(*inputs, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1110, in _run_ddp_forward
    return module_to_run(*inputs[0], **kwargs[0])  # type: ignore[index]
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/notebooks/OpenOOD/openood/networks/resnet50.py", line 23, in forward
    logits_cls = self.fc(feature)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/autograd/function.py", line 506, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
TypeError: _ISHTLinear.forward() missing 2 required positional arguments: 'bias' and 'dropiter'

launch command:

 PYTHONPATH='.':$PYTHONPATH python main.py  \
    --config /notebooks/OpenOOD/configs/datasets/master.yml \
    configs/networks/resnet50.yml \
    configs/pipelines/train/train_ish.yml \
    configs/preprocessors/base_preprocessor.yml \
    --network.pretrained True \
    --network.checkpoint /notebooks/OpenOOD/results/pretrained_weights/imagenet_res50_acc76.10.pth \
    --trainer.trainer_args.param 0.85 \
    --optimizer.lr 0.003 \
    --optimizer.weight_decay_fc 0.00005 \
    --optimizer.num_epochs 10 \
    --dataset.train.batch_size 256 \
    --num_gpus 2 --num_workers 4 \
    --merge_option merge \
    --seed 0

Any idea what's causing this? Was this issue present in ci/cd pipelines perhaps?

zjysteven commented 8 months ago

Hi @PQLLUX, the ISH pipeline was just recently contributed by the authors of ISH @kai422. We don't really have a ci/cd pipeline for now, but I confirm that I can reproduce this issue on my end. @kai422 Kai would you look into this?

kai422 commented 8 months ago

Sure. I will look into it shortly.

kai422 commented 8 months ago

Hello @PQLLUX, I have submitted a patch addressing this issue. @zjysteven, kindly review it for merging.

zjysteven commented 8 months ago

@PQLLUX Please pull the latest commit and try again. On my end the training works now.

PQLLUX commented 8 months ago

Thank you, all seems to be working. Thank you for the fix! Closing the issue.