# Art\_Generation\_with\_Neural\_Style - Assignment 2, Exercise 3

**URL:** <https://community.deeplearning.ai/t/art-generation-with-neural-style-assignment-2-exercise-3/727401>\
**Category:** Convolutional Neural Networks\
**Tags:** week-module-4, coursera-platform\
**Created:** [November 25, 2024, 3:07pm UTC](https://community.deeplearning.ai/t/art-generation-with-neural-style-assignment-2-exercise-3/727401 "2024-11-25T15:07:49Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [November 25, 2024, 4:20pm UTC](https://community.deeplearning.ai/t/art-generation-with-neural-style-assignment-2-exercise-3/727401/4 "2024-11-25T16:20:19Z")

</div>

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.](https://community.deeplearning.ai/t/neural-style-transfer-programming-exercise-compute-content-cost-reshape-confusion/231502/2) 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:

```auto
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

```

---

_[View the full topic](https://community.deeplearning.ai/t/art-generation-with-neural-style-assignment-2-exercise-3/727401)._
