# Course -1,Week 2, Ex-8, Value error with reshaping

**URL:** <https://community.deeplearning.ai/t/course-1-week-2-ex-8-value-error-with-reshaping/12601>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [June 7, 2021, 8:24pm UTC](https://community.deeplearning.ai/t/course-1-week-2-ex-8-value-error-with-reshaping/12601 "2021-06-07T20:24:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalith](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lalith](https://community.deeplearning.ai/u/Lalith)\
**Post date:** [June 7, 2021, 8:24pm UTC](https://community.deeplearning.ai/t/course-1-week-2-ex-8-value-error-with-reshaping/12601/1 "2021-06-07T20:24:24Z")

</div>

ValueError Traceback (most recent call last)  
 in   
----\> 1 model\_test(model)

~/work/release/W2A2/public\_tests.py in model\_test(target)  
109 y\_test = np.array([1, 0, 1])  
110  
 → 111 d = target(X, Y, x\_test, y\_test, num\_iterations=50, learning\_rate=1e-4)  
112  
113 assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"

in model(X\_train, Y\_train, X\_test, Y\_test, num\_iterations, learning\_rate, print\_cost)  
40 b = params[“b”]  
41  
—\> 42 Y\_prediction\_test = predict(w, b, test\_set\_x)  
43 Y\_prediction\_train = predict(w,b,train\_set\_x)  
44

in predict(w, b, X)  
16 m = X.shape[1]  
17 Y\_prediction = np.zeros((1, m))  
—\> 18 w = w.reshape(X.shape[0], 1)  
19  
20 # Compute vector “A” predicting the probabilities of a cat being present in the picture

ValueError: cannot reshape array of size 12 into shape (12288,1)

Above is the error I am getting, Can anyone help with this.

---

<div class="post-metadata">

**Author:** ![crackingthecode](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/crackingthecode/32/2653_2.png) [@crackingthecode](https://community.deeplearning.ai/u/crackingthecode)\
**Post date:** [June 8, 2021, 3:13am UTC](https://community.deeplearning.ai/t/course-1-week-2-ex-8-value-error-with-reshaping/12601/2 "2021-06-08T03:13:12Z")

</div>

Did your test for optimize() pass?

---

<div class="post-metadata">

**Author:** ![Lalith](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lalith](https://community.deeplearning.ai/u/Lalith)\
**Post date:** [June 8, 2021, 9:07am UTC](https://community.deeplearning.ai/t/course-1-week-2-ex-8-value-error-with-reshaping/12601/3 "2021-06-08T09:07:51Z")

</div>

Yes, I got all test passed for the optimize() test.

---

<div class="post-metadata">

**Author:** ![crackingthecode](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/crackingthecode/32/2653_2.png) [@crackingthecode](https://community.deeplearning.ai/u/crackingthecode)\
**Post date:** [June 8, 2021, 3:43pm UTC](https://community.deeplearning.ai/t/course-1-week-2-ex-8-value-error-with-reshaping/12601/4 "2021-06-08T15:43:47Z")

</div>

> [@Lalith](#):
>
> Y\_prediction\_test = predict(w, b, test\_set\_x)

Where are you getting test\_set\_x? The problem is most likely caused with whatever you’re doing to get test\_set\_x from X\_test. I believe it’s using test\_set\_x from the preceding code blocks and hence it contains irrelevant data.

---

<div class="post-metadata">

**Author:** ![Lalith](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lalith](https://community.deeplearning.ai/u/Lalith)\
**Post date:** [June 8, 2021, 4:43pm UTC](https://community.deeplearning.ai/t/course-1-week-2-ex-8-value-error-with-reshaping/12601/5 "2021-06-08T16:43:46Z")

</div>

Thank you for your response I didn’t find exact cause for the error but after closing it and again I tried the programming task today . I went with the same but it got worked.
