def testGetSaverPartitioned(self, save_partitioned, load_partitioned):
path = os.path.join(tempfile.mkdtemp(), "ckpt")
# Save checkpoint.
with self.test_session() as sess:
conv = self._create_conv(partitioned=save_partitioned, name="a")
saver = snt.get_saver(conv)
sess.run(tf.global_variables_initializer())
saver.save(sess, path)
w = tf.identity(conv.w)
w_value = sess.run(w)
# Restore checkpoint.
with self.test_session() as sess:
conv = self._create_conv(partitioned=load_partitioned, name="b")
saver = snt.get_saver(conv)
saver.restore(sess, path)
w = tf.identity(conv.w)
self.assertAllEqual(sess.run(w), w_value)
评论列表
文章目录