I cut the code because it is quite durity, Here is code for learning rate scheduler and the model use that optimizer.
initial_learning_rate = 0.001
lr_schedule = tf.keras.optimizers.schedules.ExponentialDecay(
initial_learning_rate,
decay_steps=100000,
decay_rate=0.96,
staircase=False)
opt=tf.keras.optimizers.SGD(learning_rate=lr_schedule)
and this is model save code. i saved it after model.fit
midmodel_2.save('../HY/HY_history/5fold/{}'.format(model_name2))
with open('../HY/HY_history/5fold/{}'.format(model_history_name2), 'wb') as f:
pickle.dump(history.history, f)
midmodel_2.save_weights('../HY/HY_history/5fold/{}'.format(model_weight2))
load model code is here
import keras
from keras.models import load_model
loaded_model=load_model('./mobilenetv2_epoch50_fold1_210402_Adagrad_AugNo_25_freeze_schYes.h5')
loaded_model.load_weights('./mobilenetv2_epoch50_fold1_210402_Adagrad_AugNo_25_freeze_schYesw.h5')
This is the error what i have, In this screenshot i didn't use GPU but even with gpu in console also raise same error.
Exception has occurred: ValueError
Attempt to convert a value ({'class_name': 'ExponentialDecay', 'config': {'initial_learning_rate': 0.001, 'decay_steps': 100000, 'decay_rate': 0.96, 'staircase': False, 'name': None}}) with an unsupported type (<class 'dict'>) to a Tensor.
File "D:\lab2\2021_cell\code\load_test\test.py", line 8, in <module>
`loaded_model=load_model('./mobilenetv2_epoch50_fold1_210402_Adagrad_AugNo_25_freeze_schYes.h5')`
I did convert model.h5 file to model.json by using ' tensorflowjs_converter ' but it can't load model also. Is there any way to load this without training and saving it to json format again?