Open MoffD opened 5 years ago
https://drive.google.com/open?id=1xzrqP7ExTmJiZqVt0A_G6AT69EbIjEI9tUDLD1twqj8
##############################################################################
def mymodel(): inputShape= (28, 28, 3); model= Sequential() model.add(Conv2D(20, 5, padding="same", input_shape=inputShape)) model.add(Activation('relu')) model.add(Flatten()) model.add(Dense(500)) model.add(Activation('relu')) model.add(Dense(2, activation= "softmax")) return model model.fit(....) #paramaters to start training your model
################################################################################ ################################################################################
weigh= model.get_weights()
pklfile= "D:/modelweights.pkl"
try:
fpkl= open(pklfile, 'wb') #Python 3
pickle.dump(weigh, fpkl, protocol= pickle.HIGHEST_PROTOCOL)
fpkl.close()
except:
fpkl= open(pklfile, 'w') #Python 2
pickle.dump(weigh, fpkl, protocol= pickle.HIGHEST_PROTOCOL)
fpkl.close()
################################################################################ ################################################################################
pklfile= "D:/modelweights.pkl" try: f= open(pklfile) #Python 2
weigh= pickle.load(f);
f.close();
except:
f= open(pklfile, 'rb') #Python 3
weigh= pickle.load(f);
f.close();
restoredmodel= mymodel()
restoredmodel.set_weights(weigh)
################################################################################ ################################################################################
y_pred= restoredmodel.predict(X)
open this drive link and read the same above code properly:
https://drive.google.com/open?id=1xzrqP7ExTmJiZqVt0A_G6AT69EbIjEI9tUDLD1twqj8
Running the files unmodified in Python 3.6.4 on windows I get the following trace:
running
pip3 show
for the libraries:Can you tell me what versions you are using? Seems to be a known problem with Keras per: https://github.com/keras-team/keras/issues/6766 but I assume there's a version that works. Thanks!