Compute_cost in course 2 week 3 tensorflow introduction

I getting the
NameError: name ‘new_y_train’ is not defined
on the uneditable cell

Hello @Sakshi_Malik
To solve the error, make sure you haven’t misspelled the variable’s name and access it after it has been declared .
Regards
Jenitta

Hi @jenitta.jebaraj
I haven’t used this variable but it is used in an uneditable cell how can I fix it when i cannot edit the cell please let me know how to fix this NameError
thank you
Screenshot 2022-08-16 at 2.49.50 PM
Screenshot 2022-08-16 at 2.50.50 PM

Hi @jenitta.jebaraj
I haven’t used this variable but it is used in an uneditable cell how can I fix it when i cannot edit the cell please let me know how to fix this NameError
thank you


That means that the cell that creates new_y_train, which is earlier in the notebook, either has not been executed or it threw an error and failed to produce that output value. Please do “Cell → Run All Above” and then scan all the earlier cells in the notebook to make sure they all succeeded. My bet is that at least one of them did not. Then you will have something concrete to investigate.

its not running because below code didn’t work. y_test.map and y_train.map functions doesn’t work with one_hot_matrix.
how we can solve this issue?

new_y_test = y_test.map(one_hot_matrix)
new_y_train = y_train.map(one_hot_matrix)

That probably means there is a bug in your one_hot_matrix function. Please show us the complete exception trace that you are getting when you run that cell that calls “map” on one_hot_matrix.

If this is the error you get:

ValueError: Shape must be rank 1 but is rank 0 for '{{node Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT32](one_hot_1, Reshape/shape)' with input shapes: [6], [].

Then please have a look at this other thread for the solution.

1 Like

this is what i get

ValueError Traceback (most recent call last)
in
----> 1 new_y_test = x_train.map(one_hot_matrix)
2 new_y_train = x_test.map(one_hot_matrix)

ValueError: Shape must be rank 1 but is rank 0 for ‘{{node Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT32](one_hot, Reshape/shape)’ with input shapes: [6,64,64,3], .

thank you :heart: i try to solve the problem

Your error message is the same as I showed, so the info on that other link should help. Let us know if not!