C1W1 Lab 1 missing "from tensorflow import keras"

Hi All,

Using “correct” code for the first graded function in the C1W1 throws an error when it can’t find keras. It appears that the uneditable cell which loads tf and np fails to import keras like we see in the lecture. This can be addressed by including:

from tensorflow import keras

above the function. (Unfortunately, you have to put this above or in the function rather in the previous cell where it belongs, because the previous cell is uneditable.) Admins, can you pls fix in the notebook to either (1) include the line of code I used here in the uneditable cell or (2) create an instruction to students to write such a line of code and provide an appropriate place to do it. This will save newer learners confusion. Thanks!

Also, for some reason the “New Topic” button was grayed out when I tried to post this to C1W1 discussion items. Perhaps it’s because I’m new to this course. However, this account has been active for several weeks as I’ve completed four courses in the DLS. The UI does not specify a reason that the button is grayed out.

Admins, can you pls fix that as well? Either have the button not be grayed out or have the UI explain why the button is grayed out and provide the user a workaround.

Thanks!

Hi Chris @chris.favila can you have a look at the first part of this. Thanks

Hi Aaron!

  • You can use the keras module built into the tensorflow package by using the syntax tf.keras.<type of model or layer>. You don’t need from tensorflow import keras unless you want to type keras only instead of tf.keras. That extra import was included in the ungraded lab though, and that can be confusing. We’ll push a revision to fix that. Hope this helps!

  • As for posting in the C1 W1 category, are you posting it on this category? If so, can you take a screenshot similar to the one below so I can include it in the report? Please include the greyed out New Topic button and the heading above that shows the course and week numbers.

Thank you for reporting these!

And thank you as well, Gent, for bringing this to my attention!

1 Like

Hi Chris, Thanks for the quick reply.

You can use the keras module built into the tensorflow package by using the syntax tf.keras.<type of model or layer> . You don’t need from tensorflow import keras unless you want to type keras only instead of tf.keras .

I should clarify: I actually did use precisely the syntax you recommend: tf.keras.OtherStuff when it threw the error. I thought this was highly unusual so I retyped it manually and re-executed the code block four times. The error reproduced exactly all four times when I typed the code as you suggest. However, when I included the import command the error did not occur. I checked two additional times and my workaround solution succeeded each time. If you are able to access my submission, you could try commenting out the line I added above the function to reproduce the error.

Regarding the grayed out New Topic link, I cannot find the page right now. But the link you shared works and is not grayed out so I’ll revisit if it comes back. FYI, several course pages hung last night (and even crashed Chrome) before I saw a screen saying there was maintenance going on… wonder if this is related.

Hi Aaron! Kindly check your inbox. We’d like to see if we can replicate the import issue. Thank you!

Glad the New Topic button is working for you now. Maybe it was indeed a glitch caused by the maintenance.

Hi. For other learners who may encounter the same issue: Please do not import keras. Kindly use tf.keras.<layer> instead of keras.<layer>. Please check your code carefully to avoid autograder errors. Thank you!

Hi Chris!
It worked. Thank you very much.

1 Like

Thanks Chris. It was my mistake to omit “tf” and it was partially luck that my workaround worked.

1 Like