Course 4 Week 4 A2 Neural Style Transfer

In section 5.6 - Train the Model
I get the error output
ValueError: No gradients provided for any variable: ['generated_image:0'].
when I add the noise to generated_image as

generated_image = tf.Variable(tf.image.convert_image_dtype(content_image, tf.float32))
noise = tf.random.uniform(tf.shape(generated_image), 0, 0.5)
generated_image = tf.add(generated_image, noise)
generated_image = tf.clip_by_value(generated_image, clip_value_min=0.0, clip_value_max=1.0)

If I only use original image as Input
generated_image = tf.Variable(tf.image.convert_image_dtype(content_image, tf.float32))
no error will occur
I think it is a bug in the exercise, how can I fix this?

Another problem is that In Exercise 6 - train_step
The testing code for evaluating cost for epoch 0, I get output 10221.33203125, but the answer is 10221.168, which is a very little error, I’ve passed every test for functions before this test, is this also a bug or if I miss anything?

Hi Brian,

You are right it makes sense to use a noisy image. But in principle the process also works without noise, as the content will be adjusted as a result of adjustments in style to lower the style cost. The difference in the evaluation of cost does not seem to be an issue.

I should mention that people at the backend are continuously working to fix bugs and add updates to the notebook. Thanks for providing this type of feedback!