TnsorFlow 训练结果的保存与载入

1
2
3
4
5
6
7
8
9
10
11
12
saver = tf.train.Saver({
"W_conv1":W_conv1,
"b_conv1":b_conv1,
"W_conv2":W_conv2,
"b_conv2":b_conv2,
"W_fc1":W_fc1,
"b_fc1":b_fc1,
"W_fc2":W_fc2,
"b_fc2":b_fc2,
},max_to_keep=1)
saver.save(sess, "d:\model")
#保存数据的关键代码如上
1
2
3
4
5
6
7
8
9
10
11
12
saver = tf.train.Saver({
"W_conv1":W_conv1,
"b_conv1":b_conv1,
"W_conv2":W_conv2,
"b_conv2":b_conv2,
"W_fc1":W_fc1,
"b_fc1":b_fc1,
"W_fc2":W_fc2,
"b_fc2":b_fc2,
},max_to_keep=1)
saver.restore(sess, "d:\model")
#读取数据的关键代码如上