首先,我使用 tf.contrib.gan 训练了一个模型,如下所示,我能够训练模型。
tf.contrib.gan.gan_train(
train_ops,
hooks=(
[tf.train.StopAtStepHook(num_steps=FLAGS.max_number_of_steps),
tf.train.LoggingTensorHook([status_message], every_n_iter=10)] +
sync_hooks),
logdir=FLAGS.train_log_dir,
master=FLAGS.master,
is_chief=FLAGS.task == 0,
config=conf
)
然后我想评估模型。尝试通过以下方式恢复检查点时,
with tf.name_scope('inputs'):
real_images, one_hot_labels, _, num_classes = data_provider.provide_data(
FLAGS.batch_size, FLAGS.dataset_dir)
logits, end_points_des, feature, net = dcgan.discriminator(real_images)
variables_to_restore = slim.get_model_variables()
restorer = tf.train.Saver(variables_to_restore)
with tf.Session() as sess:
ckpt = tf.train.get_checkpoint_state(FLAGS.checkpoint_dir)
restorer.restore(sess, ckpt.model_checkpoint_path)
我得到了这个例外:
2018-04-11 20:05:03.304089: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key Discriminator/fully_connected_layer2/weights not found in checkpoint
2018-04-11 20:05:03.304280: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key Discriminator/conv0/BatchNorm/Discriminator/conv0/BatchNorm/moving_mean/local_step not found in checkpoint
2018-04-11 20:05:03.304484: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key Discriminator/conv0/BatchNorm/beta not found in checkpoint
2018-04-11 20:05:03.305197: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key Discriminator/fully_connected_layer2/biases not found in checkpoint
我正在使用 TF 1.7rc1