W4A2/Art_Generation_with_Neural_Style_Transfer Assignment: ValueError: No gradients provided for any variable

W4A2/Art_Generation_with_Neural_Style_Transfer Assignment

I am getting “ValueError: No gradients provided for any variable” from train_step_test(train_step, generated_image)

Apparently my implementation of train_step() function is not correct. I would appreciate some guidance.

1 Like

Your code in the train_step() function is fairly simple, since it just calls the functions you tested earlier:

You compute a_G using the generated_image.
You compute J_style using compute_style_cost(…)
You compute J_content using compute _content_cost(…)
You compute J using total_cost(…).

Assuming you did not modify any of the provided code, the gradients should be available via the call to tape.gradient().

1 Like

These are exactly my steps and tape.gradient(J, generated_image) returns None.

1 Like

Next, the key points are:

  • What function arguments did you use?
  • Did you run all of the cells from the top of the notebook when you opened it for editing?

Also, are you running the notebook in Coursera Labs?

1 Like
  • What function arguments did you use? How can I share it with you? Can I just include my code (4-5 lines) here? I do not want to violate any Coursera rules…
  • Did you run all of the cells from the top of the notebook… YES
  • Also, are you running the notebook in Coursera Labs? YES
1 Like

Update for those who find this thread later.

The vgg_model_outputs() function can use generated_image without any further processing.