# Compute\_layer\_style\_cost()

**URL:** <https://community.deeplearning.ai/t/compute-layer-style-cost/110472>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [March 20, 2022, 8:05pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472 "2022-03-20T20:05:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raja\_Singh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/raja_singh/32/14416_2.png) [@Raja\_Singh](https://community.deeplearning.ai/u/Raja_Singh)\
**Post date:** [March 20, 2022, 8:05pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/1 "2022-03-20T20:05:22Z")

</div>

Can someone help me with this? I am getting this error for this function(compute\_layer\_style\_cost).

 ![1](https://global.discourse-cdn.com/dlai/original/3X/c/7/c795c4f833983f6190cc23a56b71ca8c5c18a79d.png)

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [March 20, 2022, 8:21pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/2 "2022-03-20T20:21:46Z")

</div>

Please post the entire assert stack. I suspect there’s a lot more of it - eventually it will identify which line of your code caused the error.

---

<div class="post-metadata">

**Author:** ![Raja\_Singh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/raja_singh/32/14416_2.png) [@Raja\_Singh](https://community.deeplearning.ai/u/Raja_Singh)\
**Post date:** [March 20, 2022, 8:25pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/3 "2022-03-20T20:25:57Z")

</div>

Hello @TMosh , I changed the tf.square, as it was mentioned in a lot of places that it is making error, Now I am doing \*\*2, so now I am getting this error.

 ![1](https://global.discourse-cdn.com/dlai/original/3X/3/1/3167ccc974bb5d8d8ad726a56ea774739dd8c456.png)

I think the problem is with my reshape, can you please check it once, I will remove it later.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [March 20, 2022, 8:42pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/4 "2022-03-20T20:42:17Z")

</div>

Your shape parameters are incorrect.  
Please do not post your code on the forum.

---

<div class="post-metadata">

**Author:** ![Raja\_Singh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/raja_singh/32/14416_2.png) [@Raja\_Singh](https://community.deeplearning.ai/u/Raja_Singh)\
**Post date:** [March 20, 2022, 8:46pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/5 "2022-03-20T20:46:12Z")

</div>

@TMosh can you tell me what changes I have to make? I gave the parameters as it was stated in comments.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [March 20, 2022, 8:57pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/7 "2022-03-20T20:57:42Z")

</div>

Hint: The shape that’s given in the code comment is the resulting shape AFTER the transposition.

---

<div class="post-metadata">

**Author:** ![Raja\_Singh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/raja_singh/32/14416_2.png) [@Raja\_Singh](https://community.deeplearning.ai/u/Raja_Singh)\
**Post date:** [March 20, 2022, 9:31pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/8 "2022-03-20T21:31:03Z")

</div>

Hello, @TMosh I tried changing the reshape parameter, what I can sense here is I have to just unroll the 3D matrix, as I did in the previous task compute\_content\_cost(), so I am doing exactly same as what I did before, there I am getting the correct answer, but here it is showing the same error again and again. I am completely stuck.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [March 20, 2022, 9:35pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/9 "2022-03-20T21:35:09Z")

</div>

You have the correct arguments, but in the wrong order.

---

<div class="post-metadata">

**Author:** ![Raja\_Singh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/raja_singh/32/14416_2.png) [@Raja\_Singh](https://community.deeplearning.ai/u/Raja_Singh)\
**Post date:** [March 20, 2022, 9:38pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/10 "2022-03-20T21:38:39Z")

</div>

@TMosh I changed the order also, previously I was using n\_C,n\_H \* n\_W and now I am using this n\_H \* n\_W, n\_C, but it is still giving wrong values.

---

<div class="post-metadata">

**Author:** ![Raja\_Singh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/raja_singh/32/14416_2.png) [@Raja\_Singh](https://community.deeplearning.ai/u/Raja_Singh)\
**Post date:** [March 20, 2022, 9:44pm UTC](https://community.deeplearning.ai/t/compute-layer-style-cost/110472/11 "2022-03-20T21:44:37Z")

</div>

@TMosh Thank you so much, finally got the answer. The mistake I was doing is that I was only manipulationg nH,nW,nC, I was keeping the m as it is.
