build base and intermidiate layer help
nitzan1207 opened this issue · comments
I've encountered a couple of errors in my code I was hoping you could help me fix:
- I used get_resnet50_base and when i tried to load the weights this error popped up
ValueError: You are trying to load a weight file containing 111 layers into a model with 116 layers. - if I put get_resnet50_base as my build base, which intermidiate layer do I use?
Now I used get_resnet101_base and when i tried to load the weights, this error popped up:
ValueError: You are trying to load a weight file containing 207 layers into a model with 212 layers.
@nitzan1207 , Thanks for your interest in this repo.
-
Are you trying to load the weights from a resnet model pre-trained on another task? If so, the prediction layers for the outputs will not be in the model file, in which case you will have to use
by_name=True
in theload_weights
function. -
For resnet50 with intermediate supervision, you can use the output features of any of the blocks in stage 4 (since with output stride 16, they will already be at the output resolution), for example block c or d.
I am trying to load the weights in my prediction file, like you did in your demo.ipynb.
in the load weights function I load the file that I trained. in the config file - SAVE_MODEL_PATH = './personlab_model2.h5'
I need to load another file?
and if I put by_name=True in the load_weights function i get this problem
ValueError: Layer #334 (named "long_offsets_1"), weight <tf.Variable 'long_offsets_1/kernel:0' shape=(1, 1, 1024, 34) dtype=float32_ref> has shape (1, 1, 1024, 34), but the saved weight has shape (34, 2048, 1, 1).
The problem happened when I tried to load the weights from my model that I train.
I tried to load the weights in the prediction file like you did in the demo,
you did this:
model.load_weights('models/personlab_res101_400_r32_0510.h5')
Is this the model you trained, what is written in the SAVE_MODEL_PATH in the config file?
Or should I load another model?