| 46 | |
| 47 | |
| 48 | def tfadd_with_ckpt(out_dir): |
| 49 | x = array_ops.placeholder(dtypes.int32, name='x_hold') |
| 50 | y = variables.VariableV1(constant_op.constant([0]), name='y_saved') |
| 51 | math_ops.add(x, y, name='x_y_sum') |
| 52 | |
| 53 | init_op = variables.global_variables_initializer() |
| 54 | saver = saver_lib.Saver(write_version=saver_pb2.SaverDef.V1) |
| 55 | with session.Session() as sess: |
| 56 | sess.run(init_op) |
| 57 | sess.run(y.assign(y + 42)) |
| 58 | # Without the checkpoint, the variable won't be set to 42. |
| 59 | ckpt = os.path.join(out_dir, 'test_graph_tfadd_with_ckpt.ckpt') |
| 60 | saver.save(sess, ckpt) |
| 61 | |
| 62 | |
| 63 | def tfadd_with_ckpt_saver(out_dir): |