xavysp / LDC

LDC: Lightweight Dense CNN for Edge Detection
133 stars 18 forks source link

Model is updating its weights when calling model.forward() on training #8

Closed dvagala closed 1 year ago

dvagala commented 1 year ago

Hey, first of all, thank you for providing the implementation for this model!

I'm trying to fine-tune a BSDS pre-trained model on my custom dataset, and I'm experiencing a little bit of weird behavior:

Issue: The model is updating its weights even when I commend out optimizer.step() or set the learning rate to 0. After a little bit of investigation I found out that the calling model.forward is causing this but only when the model is in training mode. Here:

https://github.com/xavysp/LDC/blob/5ab0bea2a6bc43c198e015bbc2d47d7b654d02fb/main.py#L52

Steps to reproduce: Load the pre-trained model with model.load_state_dict(torch.load(path, map_location=device)) and set the learning rate to 0.

Expected result: Model don't update its weights.

Please note that I'm new to ML, so maybe I'm missing something.

xavysp commented 1 year ago

Hi, let me see if I understood you. You already have trained LDC with BSDS, Now you need to fine-tune with this checkpoint of BSDS to your new training set (your own dataset) isn't it? If so I suggest you check models like BDCN, CATS, PIDINET. This models before training BSDS fine-tune with imagenet images classification checkpoint. The procedure for LDC should be similar to the models used as examples.

By the way, let me know what kind of results you get, and Are you working on edge detection?

cheers

dvagala commented 1 year ago

Hi, let me see if I understood you. You already have trained LDC with BSDS, Now you need to fine-tune with this checkpoint of BSDS to your new training set (your own dataset) isn't it?

Yes exactly

Are you working on edge detection?

I'm working on lightweight high-resolution image segmentation

If so I suggest you check models like BDCN, CATS, PIDINET.

Thank you I will check it!