Tensorflow在训练之前从预先训练的网络获取输出

时间:2019-12-05 13:48:24

标签: python tensorflow machine-learning

如果我要从这样的文件中加载经过预训练的模型:

  curr_meta_graph_definition = tf.saved_model.loader.load(
                                           curr_session,
                                           [tf.saved_model.tag_constants.SERVING],
                                           path_to_model
                                           )

如何获取输出变量以存储在损失函数中?例如,这就是我想要做的:

 losses['dice_loss'] = dice_loss(placeholders['labels'], tf.cast(outputs['sigmoid'], tf.float32))
 fitting_op = optimizer.minimize(losses["dice_loss"])

但是,我应该如何为输出['sigmoid']获取一些变量(应该在训练模型之前就将其作为模型的输出预测?我可以使用占位符吗?

我正在这样运行模型:

 _, dice = curr_session.run([
                    fitting_op,
                    outputs['dice'],
                ], {
                    placeholders['images']: batch['images'],
                    placeholders['labels']: batch['labels'],
                    placeholders['is_training']: True,
                },)

0 个答案:

没有答案
相关问题