使用保存的模型导出Tensorflow实验模型

时间:2020-11-10 14:29:53

标签: tensorflow tensorflow-serving

请我如何使用TensorFlow SaveModel保存该模型。

train_steps = int(0.5 + (1.0 * num_epochs * nusers) / batch_size)
    steps_in_epoch = int(0.5 + nusers / batch_size)
    print("Will train for {} steps, evaluating once every {} steps".format(train_steps, steps_in_epoch))
    def experiment_fn(output_dir):
        return tf.contrib.learn.Experiment(
            tf.contrib.factorization.WALSMatrixFactorization(
                num_rows = nusers, 
                num_cols = nitems,
                embedding_dimension = n_embeds,
                model_dir = output_dir),
            train_input_fn = read_dataset(tf.estimator.ModeKeys.TRAIN, input_path,batch_size, nitems, nusers, num_epochs,n_embeds, output_dir),
            eval_input_fn = read_dataset(tf.estimator.ModeKeys.EVAL, input_path, batch_size, nitems, nusers, num_epochs, n_embeds, output_dir),
            train_steps = train_steps,
            eval_steps = 1,
            min_eval_frequency = steps_in_epoch,
            export_strategies = tf.contrib.learn.utils.saved_model_export_utils.make_export_strategy(serving_input_fn = create_serving_input_fn(nitems, nusers))
        )

我尝试用 export_strategies=tf.export_saved_model(output_dir, serving_input_fn = create_serving_input_fn(nitems, nusers))替换export_strategies,它返回以下错误消息

AttributeError: module 'tensorflow' has no attribute 'export_saved_model

还尝试了export_strategies=tf.saved_model(output_dir, serving_input_fn = create_serving_input_fn(nitems, nusers))

TypeError: 'DeprecationWrapper' object is not callable

0 个答案:

没有答案