如何在Tensorflow中保存多层感知器模型

时间:2018-12-17 12:16:50

标签: python-3.x tensorflow keras

我正在尝试保存以下文件,但不确定如何保存。我曾尝试在训练模型U extends之前放置 mydict = [:] // Your parameters here if let theJSONData = try? JSONSerialization.data( withJSONObject: mydict, options: []) { let theJSONText = String(data: theJSONData, encoding: .ascii) multipartFormData.append((theJSONText?.data(using: .utf8)!)!, withName: "bulkData") } ,但收到with tf.Session as sess。然后,我尝试在模型初始化位置history = model.fit_generator...上方放置ValueError: No variables to save。我是Tensorflow的新手,所以我只是想学习绳索。

任何指导都会很棒,谢谢!

with tf.Session...

1 个答案:

答案 0 :(得分:1)

来自Keras文档:

from keras.models import load_model

model.save('my_model.h5')  # creates a HDF5 file 'my_model.h5'
del model  # deletes the existing model

# returns a compiled model
# identical to the previous one
model = load_model('my_model.h5')