DenseNet-Keras
DenseNet-Keras copied to clipboard
about the pre-train weight
Hi, Did you test the pre-train model on tensorflow backend? I got an error when use it while the theano backend works. I need a tensorflow pre-train model.
Thanks
Oh yes, I forgot to erase a line in custom_layers.py which resulted in an error. It should work now!
Hi Thanks for your attention! But again it does not work!! I think it is not related to custom_layers.py, the *.h5 weights file of tensorflow has a problem and I think you save it with the old version of tensorflow. Thanks
@Fahim7 , I think the *.h5 weights file is backward compatible. Which model did you try to run? What was the corresponding error message?
I tested it with all three models in a tensorflow backend and I got a dimension error. for example if I only load the weights of the pre-trained model (DenseNet 121 (k=32)) as follow:
model.load_weights('/weights/densenet121_weights_tf.h5',by_name = True)
I get the following error: ValueError: Dimension 0 in both shapes must be equal, but are 192 and 256 for 'Assign_41' (op: 'Assign') with input shapes: [192], [256].
while if I change the backend as theano and load a model in the theano backend, every things done well. But I want to use a tensoflow backend.
I am using Keras 2.0.5 and Tensorflow 1.2.1 and all models work fine with Tensorflow backend. What version of Keras and Tensorflow are you using?
My keras 2.0.5 and tensorflow 1.2.0
Same error with DenseNet169 TF weights.
Here is my system info:
>>> print(keras.__version__)
2.0.5
>>> print(tensorflow.__version__)
1.2.0
...
ValueError: Dimension 0 in both shapes must be equal, but are 1 and 128 for 'Assign_97' (op: 'Assign') with input shapes: [1,1,256,256], [128,256,1,1].
same problems with tensorflow 1.2.1 and keras 2.0.6
set reduction=0.5 to fix the ValueError issue when loading weights
It's also not working with reduction=0.5. Before it was giving error in 'Assign_97' and now by changing reduction=0.5 it is giving error in 'Assign_1126'
@Rabia-Metis which densenet did you run. I am doing fine with densenet121 on tensorflow 1.3 and keras 2.0.9
@taoddiao Thanks for quick reply I am using densenet161, keras 2.1.2 and tf 1.4.0 And my input shape is 224,224,3 Following is the exact wording of the error "ValueError: Dimension 1 in both shapes must be equal, but are 2 and 1000 for 'Assign_1126' (op: 'Assign') with input shapes: [2208,2], [2208,1000]."
@Rabia-Metis It is seems that you have changed the output shape classes=1000
to classes=2
. In this case, you cannot load weights directly because the weights have the output shape classes=1000
. One feasible solution is to assign weights layer by layer.
@taoddiao Oh I forgot it. Thanks for pointing it out
@Rabia-Metis your observation is correct, but how do we do that?