-
Notifications
You must be signed in to change notification settings - Fork 19.7k
Closed
Labels
To investigateLooks like a bug. It needs someone to investigate.Looks like a bug. It needs someone to investigate.
Description
I"m running into this error:
ValueError: You are trying to load a weight file containing 532 layers into a model with 526 layers.
My keras version is:
>>> keras.__version__ '2.2.4'
`Tensorflow version:
'1.12.0'`
Bascially, when the model tries to load I get this value error
ValueError: You are trying to load a weight file containing 532 layers into a model with 526 layers.
I"ve looked at this thread:
However, I"m trying to run the no_top version, so It shouldn't matter what my input vector is.
base_model(weights='imagenet', include_top=False)
Thank you.
Here is the script Im using:
################IMPORTS########################
#--Keras imports--#
from keras.applications import resnet50, xception,inception_v3,inception_resnet_v2, densenet, nasnet, imagenet_utils
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
from keras.layers import Input, Dense
from keras import backend as k
from keras.models import Model, clone_model
from keras.layers import Dense, GlobalAveragePooling2D,Dropout, BatchNormalization
from keras import optimizers
from keras.optimizers import Adam
from keras.callbacks import ModelCheckpoint,ProgbarLogger
from keras.utils import print_summary
from keras import __version__
from keras.datasets import cifar10
#--python imports--#
import os
import numpy as np
import datetime
import h5py
import json
import time
################# -- PARAMETERS -- ##################################
img_width, img_height = 480, 480
(x_train, y_train), _ = cifar10.load_data()
classes = len(y_train[0])
##------initial training parameters -----##
i_epochs = 10
i_batch_size = 20
i_steps_per_epoch = 100
i_optimizer = optimizers.SGD(lr=0.0001, momentum=0.9)
#################### MODELS ######################################
def basemodel():
base_model = nasnet.NASNetLarge(weights='imagenet', include_top=False)
preprocess = nasnet.preprocess_input
return base_model, preprocess
def full_model():
base_model, preprocess = basemodel()
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(2048, activation='relu')(x)
x = Dropout(.60)(x)
x= Dense(512, activation='relu')(x)
predictions = Dense(classes, activation='softmax')(x)
model = Model(inputs= base_model.input, outputs=predictions)
return model,preprocess
def initial_training_full():
model, preprocess = full_model()
for layer in model.layers[:-5]:
layer.trainable = False
model.compile(optimizer= i_optimizer,
loss='sparse_categorical_crossentropy', metrics = ['accuracy'])
print('Starting model training')
history = model.fit(x_train, y_train,
steps_per_epoch = i_steps_per_epoch,
epochs = i_epochs,
shuffle= True,
verbose = 1)
return history
if __name__ == "__main__":
initial_training_full()
Metadata
Metadata
Assignees
Labels
To investigateLooks like a bug. It needs someone to investigate.Looks like a bug. It needs someone to investigate.