# C1W1 -Received an array of 30 Tensors, but expected 1 to match the input keys dense\_Dense1\_input

**URL:** <https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333>\
**Category:** Browser-based Models with TensorFlow.js\
**Tags:** week-module-1\
**Created:** [November 27, 2024, 1:10pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333 "2024-11-27T13:10:15Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [November 27, 2024, 1:10pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/1 "2024-11-27T13:10:15Z")

</div>

link to classroom: [https://www.coursera.org/learn/browser-based-models-tensorflow/home/week/1](https://www.coursera.org/learn/browser-based-models-tensorflow/home/week/1)

This is the breast cancer week 1 assignment

I get this error in chrome:

Any thoughts on how i would go about troubleshooting this? I am running the javascript using a python webserver (run from VS code)  
Many thanks in advance!  
C

 ![tensorflowjs_fail](https://global.discourse-cdn.com/dlai/original/3X/1/0/10f77c48a0ba86302b8620e9f0797172d8f2b4f1.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 27, 2024, 1:14pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/2 "2024-11-27T13:14:36Z")

</div>

@Cormac_Garvey

is this the complete error log you got?

please don’t post any link to your assignment, it is against community guidelines.

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [November 27, 2024, 2:05pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/3 "2024-11-27T14:05:09Z")

</div>

Hi, yes this is the complete error…

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 27, 2024, 2:25pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/4 "2024-11-27T14:25:45Z")

</div>

can I know did you run the codes/assignment file in bracket multiple times??

Here is what resolved my issue when I had encountered not so similar issue. Deleting the complete folder of course from my local directory.

Re-downloading the folder and making sure to locate it to the local drive of my system.

Then making sure to keep the model architecture as simple as possible.

Referring to week 1 videos helps you resolve on how to create the model as well as the upgraded labs.

Also make sure you only write the codes in bracket where it mentions YOUR CODE HERE to END CODE HERE.

Another thing to cross check if your browser is update and the bracket app is also updated.

Let me know if addressing this resolves your issue.

Regards  
DP

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [November 27, 2024, 3:06pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/5 "2024-11-27T15:06:01Z")

</div>

Im not using the bracket app ( some note somewhere said it was discontinued). Im using VS code for the (python ) webserver, and also to edit the HTML files. I restarted the python web server and also tried using chome incognito (browser is up to date) . I am running the file from a local directory which is the root directory of the webserver. Model arc simple are possible. 2 dense layers right? Many thanks

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 27, 2024, 3:12pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/6 "2024-11-27T15:12:53Z")

</div>

> [@Cormac\_Garvey](#):
>
> I restarted the python web server

as suspected. Kindly do as I mentioned of deleting the files from local directory and redownload.

Make sure you have deleted the cache and browsing history too before you redownload the files in your system.

your issue is not with the number of dense layers.

If you notice the input keys is giving an incorrect output, than expected. So everytime you restart the tensorflow codes in the webchrome console is adding up.

Did you try the approach I mentioned!!!

Sorry as far as I remember it is execution of code from the vs code or bracket to the console in the chrome browser matters. So you using vs code should probably shouldn’t be issue as I have seen other learner also used it.

regards  
DP

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [November 27, 2024, 4:45pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/7 "2024-11-27T16:45:31Z")

</div>

ok i deleted all browser cache, and recreated the files from scratch, and gave it a nee name. I still get the same error. So its likely that the code i copied from old file to new file has also copied the error.

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [November 27, 2024, 4:53pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/8 "2024-11-27T16:53:34Z")

</div>

one thing i was curious about was… why we dont have an input and flatten layer, but i guess that must be keras-specific

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 27, 2024, 5:03pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/9 "2024-11-27T17:03:54Z")

</div>

please don’t copy paste your codes.

Can you just send me screenshot of the codes of your model architecture where input shape is relative to number of features by personal DM

another thing is to check your codes for training data and testing data where you convert column names to array form.

Next your code asks you to specify the number of feature from your training. It provides hint that you get number of features from the number of columns and the number of labels in training data.

So this code would be

```auto
(await trainingData.columnNames()).length - 1

```

After this your model architecture code comes.

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [November 27, 2024, 8:46pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/10 "2024-11-27T20:46:01Z")

</div>

i actually hardcoded the number of columns. Its an integer right?

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [November 27, 2024, 9:34pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/11 "2024-11-27T21:34:18Z")

</div>

yes correct. it is lot simpler, refer the week1 video where Instructor is creating his model, notice the number of features how he mentions and uses them in training and testing data. You are suppose to do the same.

I also suspect there could be issue with your model architecture based on the error.

your first layer to the sequential model is tf.layers.dense mentions inputShape : [numOfFeatures] and activation as per classification you are doing if binary used sigmoid, if multiple softmax, then based on number of features, you could use number of units

and then next two more dense layer based on your specification.

I have provided necessary hints, you should be able to crack it up as I know you are good at programming.

But just let me know if you still need to look at your codes.

Regards  
DP

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [November 29, 2024, 9:39am UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/12 "2024-11-29T09:39:28Z")

</div>

Thanks Deepti,  
i have sent DM with model code for your review. 🙂

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [December 3, 2024, 9:42am UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/13 "2024-12-03T09:42:35Z")

</div>

Hi Deepti, did you get a chance to look at the screenshots i sent?  
Many thanks  
Cormac

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [December 3, 2024, 3:36pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/14 "2024-12-03T15:36:46Z")

</div>

sorry I somehow forgot to respond to you

try applying 3 layer but kee relu activation function only for 2nd layer

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [December 3, 2024, 4:40pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/15 "2024-12-03T16:40:57Z")

</div>

i tried that with a softmax layer, but it hasnt helped. Should i be tryinh a different activation type?

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [December 4, 2024, 4:35pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/16 "2024-12-04T16:35:56Z")

</div>

sigmoid, relu, sigmoid. 3 layer models. please tag my name as I didn’t get notification of your response, hence late response.

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [December 5, 2024, 12:33pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/17 "2024-12-05T12:33:57Z")

</div>

This didnt affect the error message. Here is the summary of my model . Does anything look wrong?

 ![image](https://global.discourse-cdn.com/dlai/original/3X/d/8/d8b3ec1f2760c63d421a69061e68cff1331dce8a.png)

---

<div class="post-metadata">

**Author:** ![Cormac\_Garvey](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/cormac_garvey/32/98660_2.png) [@Cormac\_Garvey](https://community.deeplearning.ai/u/Cormac_Garvey)\
**Post date:** [December 5, 2024, 12:42pm UTC](https://community.deeplearning.ai/t/c1w1-received-an-array-of-30-tensors-but-expected-1-to-match-the-input-keys-dense-dense1-input/728333/18 "2024-12-05T12:42:50Z")

</div>

Thanks to stackoverflow for the following post which solved this, after 2 weeks of re doing the course and 3rd attempt from scratch to get this to work.

> <https://stackoverflow.com/questions/68111657/uncaught-in-promise-error-received-an-array-of-30-tensors-but-expected-1-to>

apparently you **have to**.batch() the converted training data, but this was no mentioned in any of the comments.
