Open rajendra2 opened 6 years ago
Hi @rajendra2,
Call DenseNet121_1_model = DenseNet121(include_top= False, input_tensor = Input_1)
loads 'image_net' weights in tf dim ordering and kernels. (densenet121_weights_tf_dim_ordering_tf_kernels.h5)
The current release of Keras-MXNet does not support loading models trained with other backends. This is a feature that we will be working soon.
What I am observing is that when I train without weights, the training accuracy is much lower but when I train with image_net weights, accuracy is pretty good. That means TF weights are getting loaded and working fine in training.
Given Keras-MXNet does not support loading models trained with other backends, is above expected ?
Secondly, since model is being trained with MxNet backend, shouldn't model.save_weights() save it in right format which can be loaded later on with MxNet backend.
Maybe the issue is in save_weights() when 'imagenet' weights are in tf dim_order and kernel. Is that the issue you also meant?
I am having the same issue. I tried to see where the issue is. It seems like the weights are not changing during training at all:
weights_before_training=model.layers[0].get_weights()[0]
model.fit(X_train,Y_train,...)
weights_after_training=model.layers[0].get_weights()[0]
diff=numpy.sum(numpy.absolute(weights_after_training-weights_before_training))
print diff
In the above code "diff" is zero. during the training the accuracy is going up but once the training is done, I cannot access the trained weights. It seems like it loads the initial weights (before training) again.
This was a problem in keras-mxnet 1.2.2.1 as well and I was hoping that it will be resolved in keras2-mxnet.
I just ran a test with 1.2.2.1 version with squeezenet and imagenet weights. Printed the weight difference of first layer's weight. It was 0. I then replaced sequeezenet with conv/maxpool layers and different is non-zero.
I am using keras-mxnet 2.1.6.1.
I trained a model on cifar10 data using densenet121 (code below). There is no issue in training. However if I load weights to continue the training or call predict, it seems weight doesn't get loaded since training again starts from same loss/accuracy as the first time. Predict results are all nan.