Reputation: 7267
For a given image, I'm extracting ResNet features i.e. after all conv layers and global max pooling, which gives a 2048 length vector per image.
Earlier, I was using keras==2.3.1
with backend tensorflow==1.13.1
. Now, I've shifted to tensorflow==2.0.0
since keras has been merged with tensorflow. I replaced my code with tf.keras
instead of keras
.
But now the features extracted are not the same as the features extracted earlier. ResNet is a model which is independent of tensorflow/keras or even pytorch for that matter. It's functionality is predefined. Why is this difference occuring? Are there any parameters that can be tweaked to get the same functionality?
Edit 1: Adding code
from tensorflow.keras.applications.resnet50 import ResNet50, preprocess_input
resnet_model = ResNet50(include_top=False)
Upvotes: 4
Views: 909
Reputation: 969
The models themselves keep updating and the weights with better results are used. Here is the releases folder where you can see releases of different weight files. The folder linked is for keras, which is most probably also used by tf.keras. The problem you are facing is probably because of the version of library rather than method of calling the model.
For example, here you can find the keras_applications code and check the weight path which points to release v0.2(linked is keras but similarly for tensorflow.keras).
The older library versions have older links, updating the libraries also updates the paths.
Upvotes: 2