Bug in compute_style_cost

In weeks 4 assignment " Art Generation with Neural Style Transfer" there is a bug in the function “compute_style_cost” causing the generated image to look really bad.

The parameters: “style_image_output” and “generated_image_output” of function “compute_style_cost” both contain a list of the following activations:
STYLE_LAYERS + Content Layer.

However, the “Content Layer” shouldn’t be used for computing the style cost.
Hence, we would expects the function to do the following filtering: a_S = style_image_output[:-1]. What we find, however, is: a_S = style_image_output[1:].

Please note, that in function “compute_content_cost” the STYLE_LAYERS are correctly omitted, by filtering out only the content layer: a_C = content_output[-1].

Hi Thomas_Kurbiel,

Good that you are reporting this. As far as I can see you are correct: in compute_style_cost a_S should be set to style_image_output[:-1] and a_G to generated_image_output[:-1]. I will report this to people at the backend. @Mubsi



The bug has been solved. However, it is not strongly related to a generated image looking bad. In the exercise, the image in the training loop does not look very good, because the learning rate is too high. If you want to get something better, you would like to decrease it and increase the number of iterations.

1 Like