keras try save and load model error

Multi tool use


keras try save and load model error
i am trying to fine tuning and save model in Keras and load model but error Value Error: You are trying to load a weight file containing 16 layers into a model with 0 layers.
i tried another model for number i made it save and load mode work without error
when i try adopt vgg16 and used it give that error
i want load model but cant load because this error any help ?
Value Error: You are trying to load a weight file containing 16 layers into a model with 0 layers.
import keras
from keras.models import Sequential,load_model,model_from_json
from keras import backend as K
from keras.layers import Activation,Conv2D,MaxPooling2D,Dropout
from keras.layers.core import Dense,Flatten
from keras.optimizers import Adam
from keras.metrics import categorical_crossentropy
from keras.layers.normalization import BatchNormalization
from keras.layers.convolutional import *
from keras.preprocessing.image import ImageDataGenerator
import matplotlib.pyplot as plt
import itertools
from sklearn.metrics import confusion_matrix
import numpy as np
train_path='dataset/train'
test_path='dataset/test'
valid_path='dataset/valid'
train_batches=ImageDataGenerator()
.flow_from_directory(train_path,batch_size=1,target_size=(224,224),classes=
['dog','cat'])
valid_batches=ImageDataGenerator()
.flow_from_directory(valid_path,batch_size=4,target_size=(224,224),classes=
['dog','cat'])
test_batches=ImageDataGenerator()
.flow_from_directory(test_path,target_size=(224,224),classes=['dog','cat'])
vgg16_model=keras.applications.vgg16.VGG16();
vgg16_model.summary()
type(vgg16_model)
model=Sequential()
for layer in vgg16_model.layers[:-1]:
model.add(layer)
for layer in model.layers:
layer.trainable=False
model.add(Dense(2,activation='softmax'))
model.compile(Adam(lr=.0001),loss='categorical_crossentropy',metrics=
['accuracy'])
model.fit_generator(train_batches,validation_data=valid_batches,epochs=1)
model.save('test.h5')
model.summary()
xx=load_model('test.h5')
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.