我编写了代码,我试图让它在几周内完成,问题在于输入更新无法正常工作。
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
### END CODE HERE ###
# Run the noisy input image (initial generated image) through the model. Use assign().
### START CODE HERE ### (1 line)
init_fn(sess)
sess.run(input_img.assign(inputo))
### END CODE HERE ###
for i in range(num_iterations):
generated_image,_ = sess.run([input_img,train_step])
if i%20 == 0:
Jt, Jc, Js = sess.run([Jolo, content_loss, style_losss])
模型定义在本节中完成,我已经定义了共享变量,并从tf.slim加载了初始v1模型
with tf.variable_scope('input') as scope:
input_img = tf.get_variable('in_img',shape=([1, img_height, img_width, 3]),dtype=tf.float32,initializer=tf.zeros_initializer())
with slim.arg_scope(inception.inception_v1_arg_scope()):
_, end_points = inception.inception_v1(input_img, num_classes=1001, is_training=False)
# Create an operation that loads the pre-trained model from the checkpoint
init_fn = slim.assign_from_checkpoint_fn(
os.path.join('home/n/models/inception_/', '/home/n/data/inception_v1.ckpt'),
slim.get_model_variables('InceptionV1')
)
我做错了,因为它更新永远不会发生。 谢谢