josedolz / SemiDenseNet

Repository containing the code of one of the networks that we employed in the iSEG Grand MICCAI Challenge 2017, infant brain segmentation.
MIT License
55 stars 18 forks source link

Save weights of trained SemiDense model to load them in new one #2

Closed CaelynCheung1996 closed 6 years ago

CaelynCheung1996 commented 6 years ago

Hi Jose, Recently I tried to used a model trained with SemiDenseNet for transfer learning. However, I was wondering how to save weights when I trained a SemiDenseNet as .npy file you mentioned in the README file. I want to use those weights in transfer learning. Thanks!

josedolz commented 6 years ago

Hi @CaelynCheung1996

For that you need to access the weights of each layer by doing (for example):

weights_N = myLiviaNet3D.networkLayers[N].W.eval()

where N is the layer of interest. Then you can save that as .npy. For example you can use that from the startTraining.py file once you are satisfied with your training.

Jose.