Problem with tensor flow Notebook --> Failed test case: model has incorrect type. Expected: <class ''>, but got: <class 'NoneType'>

Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning → housing price exercice …
error : Failed test case: model has incorrect type.
<class ‘’>,
but got:
<class ‘NoneType’>.

scenario :


GRADED FUNCTION: house_model

{Moderator Edit: Solution Code Removed}

Get your trained model

model = house_model()

Use tf. with keras.

And please move your post to the relevant course as described here.

thanks for you answer, but you mean with use tf?
i am using tf like this :

import tensorflow as tf
import numpy as np
from tensorflow import keras

model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1],activation=‘relu’)])

I mean tf.keras.layers, etc.

PS: Sharing your code is not allowed, so I am deleting it after this reply. Next time, only share your full error.

PPS: You moved this post to the Deep Learning Specialization course 4 but I moved it to the correct course category, TF1 Course 1.

still having the same problem: the full error is :“Failed test case: model has incorrect type.
<class ‘’>,
but got:
<class ‘NoneType’>.”

You are importing keras too, so, using keras with and without tf. would work.

Is your pre-defined code looks like this:

First Cell Code:

import tensorflow as tf
import numpy as np

Second Cell Code:

# GRADED FUNCTION: house_model
def house_model():

    # Define input and output tensors with the values for houses with 1 up to 6 bedrooms
    # Hint: Remember to explictly set the dtype as float
    xs = None
    ys = None

    # Define your model (should be a model with 1 dense layer and 1 unit)
    model = None

    # Compile your model
    # Set the optimizer to Stochastic Gradient Descent
    # and use Mean Squared Error as the loss function
    model.compile(optimizer=None, loss=None)

    # Train your model for 1000 epochs by feeding the i/o tensors, None, epochs=None)

    return model

If not, use these codes.

sorry it is still not working i tried usiing TF , not using TF … i tried again using the code from scracth … but the i still not getting approval … this it the very basic exercice and l already approved other more complex scenarios… i think there is issue with the validation of the tool… this is not help me if i can not share the code with you. i already did the scenario under jupiter notebook and it is running ok…

Send me your notebook in a private message. Click my name and message.

Excuse me, I’m having the same problem, could you tell me if you have a solution?

Can you please post the error you are getting with screenshot image. There is another post related to this assignment which has solutions for this similar error. Kindly refer using search engine or post the screenshot here.

If your model is not defined with correct code and/or has not replaced all the None inside #START AND END CODE HERE, you will encounter such error.


Of course, this is the error



Your error is related to the below model code
Define your model (should be a model with 1 dense layer and 1 unit)
model = None(this code has been written incorrectly.

Kindly go through the link in the previous comment where it gives hints to correct the code.

If still unable to correct, send me your codes for this grader cell via personal DM. Do not post codes here. Click on my name and then message.



you have used
model = tf.keras.Sequential([tf.keras.layers.Dense(units=1, input_shape=[1])])

this code is incorrect. your code is not defining the model for the keras define dense layer. and the image below should help you differentiate between what part of your code is missing in your code.