ld-lsi
ld-lsi copied to clipboard
Confused in loading weights
#loading weights
- model_w = torch.load('Desktop/ld-lsi/res/weights/weights_erfnet_road.pth')
- new_mw = {}
- for k,w in model_w.items():
-
new_mw[k[7:]] = w
- roadnet.load_state_dict(new_mw)
roadnet.to(device)
roadnet.eval();
I am a little confused here: 1). In 1. we are loading pretrained weights of erfnet_road model, so these are the weights of the model which is mentioned in the paper (giving 76% acc on BDD100k) or these are the pretrained weights of encoder trained on ImageNet dataset? 2) so what line 3 and 4 are doing is taking each layer, omitting module word from there and taking its corresponding weights and saving them in new_mw dict and everything else remains the same then what is difference between new_mw and model_w since they both have the same weights for each layer. 3) What is the role of pretrained network (weights_erfnet_road.pth) here? What if I want to train the model from scratch i.e without using pretrained weights can I get the same results as mentioned in the paper ?
Thank You!
You are right in points 1 and 2 here. There is no difference except if you try to load model_w
directly, it does not work for some reason.
For 3, just train the network without the command roadnet.load_state_dict(new_mw)