小编Adi*_*tya的帖子

TensorFlow推断

我一直在研究这个问题.我发现了很多文章; 但没有一个真正只显示张量流推理作为一个简单的推论.它始终"使用服务引擎"或使用预编码/定义的图形.

问题出在这里:我有一个偶尔检查更新模型的设备.然后,它需要加载该模型并通过模型运行输入预测.

在keras这很简单:建立一个模型; 训练模型和调用model.predict().在scikit中学习同样的事情.

我能够抓住一个新模型并加载它; 我可以打印出所有的重量; 但我怎么在世界上推断它?

加载模型和打印重量的代码:

    with tf.Session() as sess:
        new_saver = tf.train.import_meta_graph(MODEL_PATH + '.meta', clear_devices=True)
        new_saver.restore(sess, MODEL_PATH)
        for var in tf.trainable_variables():
            print(sess.run(var))
Run Code Online (Sandbox Code Playgroud)

我打印出了我的所有收藏品,我有:['queue_runners','变量','损失','摘要','train_op','cond_context','trainable_variables']

我尝试使用sess.run(train_op); 然而,刚开始完整的训练课程; 这不是我想做的.我只想对我提供的不是TF记录的不同输入集进行推理.

再详细一点:

该设备可以使用C++或Python; 只要我能产生.exe.如果我想要提供系统,我可以设置一个feed dict.我用TFRecords训练过; 但在生产中,我不打算使用TFRecords; 它是一个真实/近实时系统.

感谢您的任何意见.我将样本代码发布到此repo:https://github.com/drcrook1/CIFAR10/TensorFlow,它执行所有培训和样本推断.

任何提示都非常感谢!

------------编辑-----------------我重建模型如下:

def inference(images):
    '''
    Portion of the compute graph that takes an input and converts it into a Y output
    '''
    with tf.variable_scope('Conv1') as scope:
        C_1_1 = ld.cnn_layer(images, (5, 5, 3, 32), (1, 1, 1, 1), scope, name_postfix='1') …
Run Code Online (Sandbox Code Playgroud)

c++ python tensorflow

19
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

python ×1

tensorflow ×1