tensorflow API:tf.train.Saver 与 NotFoundError: "x_x" not found in checkpoint
保存 import所需的模块, 然后建立神经网络当中的 W 和 b, 并初始化变量. import tensorflow as tf import numpy as np ## Save to file # remember to define the same dtype and shape when restore W = tf.Variable( [[1,2,3],[3,4,5]] , dtype=tf.float32, name= 'weights' ) b = tf.Variable( [[1,2,3]] , dtype=tf.float32, name= 'biases' ) # init= tf.initialize_all_variables() # tf 马上就要废弃这种写法 # 替换成下面的写法: init = tf.global_variables_initializer() 保存时, 首先要建立一个 tf.train.Saver() 用来保存, 提取变量. Saver 的例子: v1 = tf.Variable( ... , name= 'v1' ) v2 = tf.Variable( ... , name= 'v2' ) # dict形式传递 saver = tf.train.Saver({ 'v1' : v1, 'v2' : v2}) #