如何使用`tf.train.Saver`类在Tensorflow中保存和恢复模型?

时间:2017-11-19 14:35:08

标签: tensorflow

我刚刚使用Tensorflow训练了一个模型,我想保存它并在以后恢复它。我在Tensorflow的官方文档中阅读了Saving and Restoring page,我偶然发现以下代码来保存模型

&

但我无法理解import { Pipe, PipeTransform } from '@angular/core'; import {unescape} from 'lodash'; @Pipe({ name: 'unescape' }) export class UnescapePipe implements PipeTransform { transform(value: any, args?: any): any { return unescape(value); } }列表和export_dir = ... ... builder = tf.saved_model_builder.SavedModelBuilder(export_dir) with tf.Session(graph=tf.Graph()) as sess: ... builder.add_meta_graph_and_variables(sess, [tag_constants.TRAINING], signature_def_map=foo_signatures, assets_collection=foo_assets) ... # Add a second MetaGraphDef for inference. with tf.Session(graph=tf.Graph()) as sess: ... builder.add_meta_graph([tag_constants.SERVING]) ... builder.save() 列表是什么。

1 个答案:

答案 0 :(得分:1)

它们似乎只是用于识别您要恢复的 For Each ctrl As Control In Controls If TypeOf ctrl Is Button Then If ctrl.Tag.ToString.Contains(BT) = True Then CType(ctrl, Button).ForeColor = Color.LimeGreen Else CType(ctrl, Button).ForeColor = Color.White End If End If Next End Sub 。现有代码为MetaGraphDefSERVINGTRAINING,但您可以使用GPU等内容定义自己的代码。