我使用keras做了一个简单的分类器,并试图将其保存并转换为tf文件,最终可以在android studio中使用它,但是在以下代码后出现错误:
from keras.models import model_from_json
from keras.models import load_model
# serialize model to JSON
# the keras model which is trained is defined as 'model' in this example
model_json = model.to_json()
with open("model_num.json", "w") as json_file:
json_file.write(model_json)
# serialize weights to HDF5
model.save_weights("model_num.h5")
错误是NameError:名称'model'未定义