jlianglab / Ark

Other
17 stars 2 forks source link

ValueError: Target size must be the same as input size #2

Closed acchu99 closed 8 months ago

acchu99 commented 8 months ago

I tried training the Ark model on the Chest-X-ray-14 dataset and got the following error:

raise ValueError("Target size ({}) must be the same as input size ({})".format(target.size(), input.size()))
ValueError: Target size (torch.Size([200, 14])) must be the same as input size (torch.Size([200, 7, 7, 14]))

Based on the output, the model's prediction shape does not match the target shape.

the command I used for training is provided below:

python main_ark.py --data_set ChestXray14 --opt sgd --lr 0.3 --batch_size 200 --model swin_base --init imagenet --pretrain_epochs 200  --test_epoch 10 --momentum_teacher 0.9 --projector_features 1376

Please let me know how to resolve this issue.

acchu99 commented 8 months ago

Fixed the issue! The problem was I ran the code in the base environment without setting up a new environment for ark. Now the script runs after I ran it in a newly setup environment.