Nov 2022 help with compute_layer_style_cost

This is just a quick note to emphasize that reading the November 2022 discussion for the programming assignment: Art Generation with Neural Style Transfer was of immense help in getting through Exercise 3 where one must compute the layer_style_cost.

I know this post doesn’t add anything useful for those with a lot of user group experience. But for those, like me, who are just getting familiar with the user group I thought this post might be useful.

Like others I was getting an answer of 2.9203947 instead of the correct answer; 14.017805.

After reading the posts I computed the transposes of a_S and a_G and then performed the reshapes - BEFORE computing the gram matrices. I then got the correct answer of 14.017805.

I went back and looked at the a_S and a-G arrays with and without preceding them with the transpose and found that while they had the same shape the numbers were very different. I still need to cogitate a lot more to get a full understanding but I’m working on that.

2 Likes

How you do the reshape and transpose matters. I’m not sure which November 2022 thread you are referring to, but here’s a thread which discusses the reshape issues in some detail. You might want to go back and read the earlier posts on that thread to get more context, but then read that post and the next one that demonstrates the difference in the methods of flattening.