Hello !

I tried to read through all the others showing similar problem but I just cannot figure out why my reshaping goes wrong when called from the optimiser loop while it seems to work correctly with the first tests.

I’ve tried reshaping to [-1, n_W*n_H, n_C], [1, -1, n_C], [m, -1, n_C] but the same problem comes up.

Is there a specific reason why the m value was not assigned from the shape on the current template ? i.e. the ready template had:

_, n_H, n_W, n_C = …

Here’s the error message:

ValueError: in user code:

```
<ipython-input-26-cd29da83566d>:26 train_step *
J_content = compute_content_cost(a_C, a_G)
<ipython-input-4-0fa8231dc89d>:26 compute_content_cost *
a_C_unrolled = tf.reshape(content_output, shape=[-1, n_H*n_W, n_C])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py:201 wrapper **
return target(*args, **kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py:195 reshape
result = gen_array_ops.reshape(tensor, shape, name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py:8234 reshape
"Reshape", tensor=tensor, shape=shape, name=name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:488 _apply_op_helper
(input_name, err))
```

ValueError: Tried to convert ‘tensor’ to a tensor and failed. Error: Dimension 1 in both shapes must be equal, but are 50 and 25. Shapes are [1,50,50,512] and [1,25,25,512].

From merging shape 3 with other shapes. for ‘{{node Reshape_10/packed}} = Pack[N=6, T=DT_FLOAT, axis=0](Reshape_10/tensor/values_0, Reshape_10/tensor/values_1, Reshape_10/tensor/values_2, Reshape_10/tensor/values_3, Reshape_10/tensor/values_4, Reshape_10/tensor/values_5)’ with input shapes: [1,400,400,64], [1,200,200,128], [1,100,100,256], [1,50,50,512], [1,25,25,512], [1,25,25,512].

Any ideas how to move forward ?