我的解决方案如下。检查
./tf
文件夹明确表示调用
model_to_estimator
将必需的文件存储在
keras
子文件夹,而
export_model
希望这些文件位于
/TF
直接文件夹,因为这是我们为
model_dir
论点:
$ tree ./tf
./tf
âââ keras
âââ checkpoint
âââ keras_model.ckpt.data-00000-of-00001
âââ keras_model.ckpt.index
âââ keras_model.ckpt.meta
1 directory, 4 files
简单的解决方法是将这些文件向上移动一个文件夹。这可以通过python实现:
import os
import shutil
from pathlib import Path
def up_one_dir(path):
"""Move all files in path up one folder, and delete the empty folder
"""
parent_dir = str(Path(path).parents[0])
for f in os.listdir(path):
shutil.move(os.path.join(path, f), parent_dir)
shutil.rmtree(path)
up_one_dir('./tf/keras')
这将使
模特儿迪尔
目录如下:
$ tree ./tf
./tf
âââ checkpoint
âââ keras_model.ckpt.data-00000-of-00001
âââ keras_model.ckpt.index
âââ keras_model.ckpt.meta
0 directories, 4 files
在
模型-对-估计量
以及
export_savedmodel
调用允许根据需要导出模型:
export_path = './export'
estimator.export_savedmodel(
export_path,
serving_input_receiver_fn=serving_input_receiver_fn())
信息:tensorflow:savedmodel写入:
/export/temp-b'1549796240'/保存的\u model.pb