Пример #1
0
print(
    '====================================Revovering Model===================================='
)
ckpt = None
if FLAGS.last_ckpt is not None:
    ckpt = tf.train.latest_checkpoint(FLAGS.last_ckpt)
    if ckpt is not None:
        # set up save configuration
        eval_loader.restore(eval_session, ckpt)
        print('Recovering From {}'.format(ckpt))
elif FLAGS.pretrained_ckpts is not None:
    print('No previous Model Found in {}'.format(ckpt))
    # pre-train priority higher
    with eval_graph.as_default():
        eval_session.run(tf.global_variables_initializer())
        partial_restore_op = partial_restore(tf.global_variables(),
                                             FLAGS.pretrained_ckpts)
        eval_session.run(partial_restore_op)
    print('Recovering From Pretrained Model {}'.format(FLAGS.pretrained_ckpts))
else:
    print('Training From Scartch TvT')
    with eval_graph.as_default():
        eval_session.run(tf.global_variables_initializer())
print(
    '====================================RUNNING!===================================='
)

try:
    print(
        "====================================Start of Eval=============================================="
    )
    with eval_graph.as_default():
Пример #2
0
# for i in (tf.global_variables()):
#     print(i.name)
if __name__ == '__main__':
    sess = tf.Session()
    # inputs = tf.placeholder(name='inputs', shape=[16, 224, 224, 3], dtype=tf.float32)
    # inputs = tf.random_uniform((1, 224, 224, 3),dtype=tf.float32)
    inputs = tf.placeholder(shape=[1, 224, 224, 3],
                            dtype=tf.float32,
                            name='inputs')
    # in_array = sess.run(tf.Print(inputs,[inputs]))
    # np.save("input.npy",in_array)
    # np.savetxt("input.txt",in_array.reshape(224*224,3))
    with arg_scope(mobilenet_v1_arg_scope()):
        nets, end_points = mobilenet_v1(inputs)
    partial_restore_op = partial_restore(
        sess, tf.global_variables(),
        '/mnt/disk/jiabao/mobilenet_v1_1/mobilenet_v1_1.0_224.ckpt')
    sess.run(partial_restore_op)

    out_array = sess.run(nets, feed_dict={inputs: np.load('input.npy')})
    print(np.mean(out_array), np.var(out_array))
    np.savetxt("output_1.txt", out_array)

    print('=' * 8)
    # sess.run(partial_restore_op)
    # print('Recovering From Pretrained Model ')
    sess.run(tf.global_variables_initializer())
    saver = tf.train.Saver()
    saver.restore(
        sess=sess,
        save_path='/mnt/disk/jiabao/mobilenet_v1_1/mobilenet_v1_1.0_224.ckpt')