keras try save and load model error

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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.

tPl0hIDS5Suq5 PZc4t GwfIoXjFDuY2Sr64eH,I5dF0Chw2tr75,BpjYEKydYpkrmlotkjA7RTB9DLgEJDFpewcY3TWQk8m6mD0
yEwsgHxJlJhD

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results