# W3_A1_Ex-2_Understanding sizes of the layer

I have no idea whatsoever why;

n_x: the size of the input layer = 5--------------------thought this would be 2 to correspond to X1 and X2,
n_h: the size of the hidden layer (set this to 4)------This is understandable since our hidden layer has four nodes
n_y: the size of the output layer = 2------------This too is confusing since the output layer has only one node

As a general rule of thumb, do not try to hardcode values, unless specified.

As for finding n_x and n_y, you have to find them by extracting values from the function parameters `X` and `Y`.

Hope this helps,
Mubsi

`shape_X` and `shape_Y` are specifically for the `X` and `Y` you have loaded from this line `X, Y = load_planar_dataset()` at the early stage of the assignment. However, in exercise 2, it requires you to get the shape not of those earlier `X` and `Y`, but of the `X` and `Y` in the input arguments of the function, which can be anything other than the earlier ones

Cheers,
Raymond

``````def layer_sizes(X, Y):
"""
Arguments:
X -- input dataset of shape (input size, number of examples)
Y -- labels of shape (output size, number of examples)

Returns:
n_x -- the size of the input layer
n_h -- the size of the hidden layer
n_y -- the size of the output layer
"""
``````
1 Like

Hey, I have a similar question regarding this topic and the same exercise.
When we load the dataset using `load_planar_dataset()`, it returns a tuple `(X, Y)`, where `X` is a numpy array of shape `(2, 400)` and `Y` is a numpy array of shape `(1, 400)`. This means that we have 400 examples in the dataset, and each example is represented as a vector of 2 features (the x and y coordinates of the input) and 1 output label.

Therefore, when we compute `n_x`, we need to use `X.shape[0]`, which gives us the number of features in the input, i.e., the size of the first dimension of `X`. In this case, `X.shape[0]` is equal to 2, which is why `n_x` should also be equal to 2.

Similarly, when we compute `n_y`, we need to use `Y.shape[0]`, which gives us the number of output labels, i.e., the size of the first dimension of `Y`. In this case, `Y.shape[0]` is equal to 1, which is why `n_y` should also be equal to 1. However, when using : n_x = X.shape[0]
n_h = 4
n_y = Y.shape[0] , it returns:
The size of the input layer is: n_x = 5
The size of the hidden layer is: n_h = 4
The size of the output layer is: n_y = 2
n_h is understandable. But why n_x=5 and n_y=2 (while as I discussed earlier, I expect them to be n_x=2 and n_y=1).
any help?

Hello @Hamid_Reza_Hamedi!

I have already replied to this question in another post that you created. You can find my response here.

If you have any further questions or concerns, please donâ€™t hesitate to reach out.

Best,
Saif.

Hello Saif, for the response. I have asked another question, would be thankful to hear your response.

all the best
Hamid

This is one of the most confusing, yet super simple exercise!
What is the point here?
The data we are testing on has nothing to do with anything above.
Waisted a lot of time for nothing!

If you are facing any error, you can share it here and our mentors will guide you furtherâ€¦

Hi Saif, the problem is turn around time, it can take over a week to have a response to a question. Often I am finding it is a problem with the notebook, not my coding for example in course 3 week 4 the assignment notebook is missing import tensorflow as tf as the first line of code and consequently when you are hotcoding it errors out. I spent a day trying to work out why my code wasnâ€™t working knowing I am not supposed to alter cells. The hotcoding is still not working so if someone can message me as soon as possible I would appreciate it. Not being able to resolve this issue has meant I could have finished this course on Tuesday but its dragged everything out all week. We have a lot of mentors and staff it seems like we need a better way of asking for help? There are lots of threads and I imagine it is easy for notifications to get lost

Hi @Nicola_Port ,

This thread is at least 15 days old. If you have any questions, please post a fresh query to the course forum with as much information as possible, for example - error messages. This will help mentors to pick up your query quickly.
In regard to the missing import tensorflow statement you highlighted as a problem with the notebook, I can honestly say that line of code must have been edited out by yourself. This notebook has been tested and in use for sometime. If in doubt, you can get a refresh copy of the assignment to start again. Here is a link on how to get a fresh copy of the assignment. Go the the refreshing workspace section for full instructions.

I never touch the cells, I didnâ€™t remove the line. I have messaged as well but I havenâ€™t had a response. I know how to get a fresh copy of the assignment but its the same problem

As you can see the import tensorflow as tf line is missing.

Can you advice the correct person to message regarding this? I am still have issues with the hotcoding unrelated to this and I am unable to post code in the forum. Thanks heaps

I have no access to your assignment, so I canâ€™t verify the missing tensoflow import statement. I have added a staff member to this thread, hopefully someone will be in touch very soon.

1 Like

Hello, @Nicola_Port! You posted your message in Deep Learning Specialization (course 1) but in Course 3 of this specialization, we have only 2 weeks. It is necessary to post your query/message in the correct course category, otherwise, it is like asking for help at the wrong place.

From your screenshot, it seems you are talking about TensorFlow Developer Professional Certificate Specialization, course 3 Natural Language Processing in TensorFlow, right? (TF1C3). If so, please move your query to the correct category as described here.

Regarding your query, why do you think we need to `import tensorflow as tf`? We already importing necessary items from `tensorflow.keras` and these are sufficient for this assignment.

If you are facing any errors, share them with us. So, we can assist you.

Best,
Saif.

Thank you Saif, itâ€™s not an easy forum to navigate my apologies!

The issue was resolved by adding the tensorflow as tf statement in the first cell (I tried everything else and it honestly didnâ€™t work, the line is missing from the class repo so itâ€™s not an issue with me editing the cell in error) the other coding issue was caused by the return line statement needing to be changed in the same cell, it is under the end code here line so I hadnâ€™t amended it. Is it possible to have this corrected in the notebook? I spent two days trying to resolve errors with my coding that were issues with the notebook. If thereâ€™s a place I can raise a request for technical support I would be happy to provide the details. Thank you for the speedy response much appreciated I finished the assignment and passed with a good result

The notebook is correct. I, along with many other learners, passed this assignment without adding anything extra.

If you are facing any error, it means your code is wrong. You donâ€™t need to change the pre-written code of the notebook, neither you have to add any extra statement to import anything. If you are facing any error without importing tensorflow as tf, it means your code is incorrect and all you need is to share your error with us, without importing tensorflow as tf.

Sorry there is a misunderstanding, a mentor responded and checked my notebook they told me it was an error with the return statement needing to be altered but the statement was under the end code. I will follow up another way thank you.

Hi Kic, I have also sent this to Chris F as well, its not always clear where trouble shooting sits in the forum. Would it be possible for you to look into the notebook for course 3 week four? I have spent the last two days trying to correct an error with my code when the issue seemed to be the import tensorflow as tf statement being missed from the first cell and the return statement needing to be altered in a cell despite it being below the end code line. I have attached screenshots below. This is not a result of altering the notebook in error, the file is the same in the course repo. It was beneficial for me to spend extra time revising the code and it helped increase my understanding of the task, but I am sure you can appreciate that the complexity of studying machine learning can mean a lot of students may start feeling they lack the expertise to complete the course without realising they had the correct code and lose confidence in their ability in situations like this. If this was an issue with my coding and the amendments shouldnâ€™t have been needed please let me know so I can use the feedback in the next exercise. I passed the assignment today and was really happy with the result. Kind regards, Nicola.

Please note that this post belongs to the Deep Learning Specialization and you are asking about the TensorFlow Course (TF1 Course 3). It is like asking for help at the wrong place. Please create a new post in a category of TF1 Course 3 week 4, so mentors of that course can guide you.

Regarding your query, instead of claiming that something is wrong in the notebook and we need to import or switch something, just do your code where it is mentioned and if you face any error, ask for help at the correct place. There is nothing wrong in the notebook. See below image of my notebook, it is same as yours and I passed that.

Hi @Nicola_Port,

Firstly, as mentioned by @saifkhanengr, your are asking a Tensorflow specialisation related question in the Deep Learning specialisation. And as he rightly pointed out, you are asking in the wrong placeâ€¦what this means is, these mentors might not have seen the Tensorflow specialisation and its notebooks, so they might not know what the original state of the notebook is. Moreover, Saif pointed out to a manual where, if you havenâ€™t gone through to already, you should, it has all the instructions on how to navigate to the right category and post there. Please post your query in the right category.