繁体   English   中英

如何在tensorflow2中替换占位符?

[英]How to replace placeholder in tensorflow2?

我需要将估计器导出器代码从tensorflow 1.x转换为2并删除占位符。 有人知道如何正确地做到这一点吗?

我已经尝试过features = {'input':tf.compat.v1.placeholder(tf.float32,shape =(1,224,224,3),name =“input”)},但这不会像我一样期望

features = {'input': tf.placeholder(tf.float32, shape=(1, 224, 224, 3), name="input")}
input_fn = tf.estimator.export.build_raw_serving_input_receiver_fn(features, 1)
exported_model_path = estimator.export_savedmodel(args.model_dir, input_fn)

如果您已迁移到使用keras模型,则可以使用此模型

# model is a compiled and trained keras model
tf.saved_model.save(model, export_dir)

它会将keras模型导出为SavedModel格式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM