earhian / Humpback-Whale-Identification-1st-

https://www.kaggle.com/c/humpback-whale-identification
640 stars 183 forks source link

train problems.. #2

Closed Jae-hyun closed 5 years ago

Jae-hyun commented 5 years ago

earhian, Thanks for sharing !!!

i'd like to train your model..

could you use pretrained SENET model?

if I use pretrained model, there is input channel size problem(your model: 4, imagenet: 3) in load state_dict().

How could I fix It?

earhian commented 5 years ago

i have modified pytorch source code. Could you show me your error?

Jae-hyun commented 5 years ago

Thanks for your quickly reply.

this is my error.

RuntimeError: Error(s) in loading state_dict for SENet:
        size mismatch for layer0.conv1.weight: copying a param of torch.Size([64, 4, 3, 3]) from checkpoint, where the shape is torch.Size([64, 3, 3, 3]) in current model.

How could you copy the conv1.weight(mask ch)? just copy the channel 1 or 2 or average?

earhian commented 5 years ago

I have add try-except for size mismatch.Could you show more?

Jae-hyun commented 5 years ago

sorry, this is full error

File "models/modelZoo/senet.py", line 463, in <module>
    mobilenet = senet154(pretrained='imagenet', inchannels=4).cuda()
  File "models/modelZoo/senet.py", line 396, in senet154
    initialize_pretrained_model(model, num_classes, settings)
  File "models/modelZoo/senet.py", line 378, in initialize_pretrained_model
    model.load_state_dict(model_zoo.load_url(settings['url']), strict=False)
  File "/home/torch_0.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 719, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for SENet:
        size mismatch for layer0.conv1.weight: copying a param of torch.Size([64, 4, 3, 3]) from checkpoint, where the shape is torch.Size([64, 3, 3, 3]) in current model.
earhian commented 5 years ago

vim /home/torch_0.4/lib/python3.6/site-packages/torch/nn/modules/module.py

replace raise error with print in line 719

Jae-hyun commented 5 years ago

Cooool!! Thanks!!! I can't think modify pytorch code..^^