如何保存和加载Tensorflow版本中tf.estimator.BoostedTrees回归器的模型=';2.0.0';
我是tf.估计器.boostedtrees回归器的新手。。下面是我用来构建模型的示例代码如何保存和加载Tensorflow版本中tf.estimator.BoostedTrees回归器的模型=';2.0.0';,tensorflow,tensorflow-estimator,Tensorflow,Tensorflow Estimator,我是tf.估计器.boostedtrees回归器的新手。。下面是我用来构建模型的示例代码 n_batches = 20 est = tf.estimator.BoostedTreesRegressor(feature_columns, n_batches_per_layer=n_batches , learning_rate=0.001, n_trees=700,
n_batches = 20
est = tf.estimator.BoostedTreesRegressor(feature_columns,
n_batches_per_layer=n_batches , learning_rate=0.001, n_trees=700,
max_depth=13,
model_dir = "model", tf.config.threading.set_intra_op_parallelism_threads(60))
est.train(train_input_fn, max_steps=10)
我想保存模型。。并加载后一个模型来预测销售额
你能帮助我在TensorFlow版本2中如何做到这一点吗。。因为我找不到
谢谢根据官方消息,您的模型应该保存在
模型目录
路径中。在实例化BoostedTreesRegressionor时,请指定指向model_dir
的实际目录路径
此外,您可以使用export\u saved\u model
方法保存模型
# Saving estimator model
serving_input_fn = tf.estimator.export.build_parsing_serving_input_receiver_fn(
tf.feature_column.make_parse_example_spec(feature_columns))
export_path = estimator.export_saved_model("/dir/path/", serving_input_fn)
要加载保存的模型,可以使用保存的\u模型。加载功能如下:
#loading saved model
imported = tf.saved_model.load(export_path)
谢谢。。太棒了,您共享的代码正在运行。请检查此处提供的解决方案