Art_Generation_with_Neural_Style - Assignment 2, Exercise 3

The problem is that you are producing 3D tensors after the reshape. What is required are 2D tensors. Here’s the comment in the template code:

# Reshape the tensors from (1, n_H, n_W, n_C) to (n_C, n_H * n_W) (≈2 lines)

It sounds like you already realize the key point that you can’t simply reshape directly to the end shape you want, because it scrambles the values as described on this thread. Read all the way through to see the full explanation.

I added some print statements to my code to show the shapes and here’s what I see when I run the test case there:

shape(a_S) [1 4 4 3]
shape(a_G) [1 4 4 3]
after reshape+T: shape(a_S) [ 3 16]
after reshape+T: shape(a_G) [ 3 16]
shape(a_S) [1 4 4 3]
shape(a_G) [1 4 4 3]
after reshape+T: shape(a_S) [ 3 16]
after reshape+T: shape(a_G) [ 3 16]
J_style_layer = tf.Tensor(14.01649, shape=(), dtype=float32)
All tests passed
2 Likes