I'm using vgg16 like this:
model = VGG16()
data, labels = ReadImages(TRAIN_DIR)
vgg16 = VGG16()
model = Sequential()
#Converting VGG16 into Sequential model
for layer in vgg16.layers[:-1]:
model.add(layer)
#Freezing all layers except last layer for transfer learning
for layer in model.layers:
layer.trainable = False
#Adding custom softmax layer
model.add(Dense(1,activation='sigmoid'))
#Compiling our model
model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])
model.fit(np.array(data), np.array(labels), batch_size=32, epochs=3)
model.save('model.h5')
and when I tried to load this model in another py file..:
model = load_model('model.h5')
I'd already tried load_weights and throws an error too
... returns this error:
ValueError: You are trying to load a weight file containing 16 layers into a model with 0 layers
What should I do to load this model to make my predictions?
versions: keras 2.2.4 tensorflow 1.14.0