Week 1 Assignment 1 compiling the model

metrics_0_check: wine quality metrics is incorrect. Please check implementation.
Expected: <class ‘tensorflow.python.keras.metrics.RootMeanSquaredError’>
Result: <class ‘tensorflow.python.keras.metrics.MeanMetricWrapper’>
Please open utils.py if you want to see the unit test here.

metrics_1_check: wine type metrics: wine_quality_root_mean_squared_error is incorrect. Please check implementation.
Expected: True
Result: False
Please open utils.py if you want to see the unit test here.

2 Tests passed
2 Tests failed

Exception Traceback (most recent call last)
in
----> 1 utils.test_model_compile(model)

~/work/release/W1_Assignment/utils.py in test_model_compile(model)
317 ]
318
→ 319 test_loop(test_cases)
320
321 def test_history(history):

~/work/release/W1_Assignment/utils.py in test_loop(test_cases)
25 print(’\033[92m’, success," Tests passed")
26 print(’\033[91m’, fails, " Tests failed")
—> 27 raise Exception(“Please check the error messages above.”)
28
29 def test_white_df(white_df):

Exception: Please check the error messages above.

I am having this problem and I have no idea how to solve it. Pls help

1 Like

Hello,

At compling the model section there should be something wrong in the metrics, it needs to be an instance of the class;

Blockquote

For wine quality, please use the root mean squared error. Instead of a string, you’ll set it to an instance of the class RootMeanSquaredError, which belongs to the tf.keras.metrics module

Blockquote

Also make sure white_df is properly set.

loss = {‘wine_quality’:‘mse’,‘wine_type’ :‘binary_crossentropy’},
metrics = {‘wine_quality’:tf.keras.metrics.RootMeanSquaredError(),
‘wine_type’ :‘accuracy’
}
Is it wrong?

Thats correct impemented.

# URL of the white wine dataset

URI = ‘./winequality-white.csv’

# load the dataset from the URL

white_df = pd.read_csv(URI, sep=";")

# fill the is_red column with zeros.

white_df[“is_red”] = 0

# keep only the first of duplicate items

white_df = white_df.drop_duplicates(keep=‘first’)

I think my white df is properly set but I still get the errors.

These are given in the assigment:
URL = ‘http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv’ for white

And
URL = ‘http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv

For red.

Do you have these?

I am using the same URL but still getting the same errors.

Send me a copy on private message, i will have a look on your code.

I already replied to your question in another post. I checked the code and the problem is as I said that you are using an activation for wine_quality output. You are not supposed to use activation for that output.

def final_model(inputs):

# get the base model

 x = base_model(inputs)

# connect the output Dense layer for regression

 wine_quality = Dense(units='1',name='wine_quality')(x)

# connect the output Dense layer for classification. this will use a sigmoid activation.

 wine_type = Dense(units='1', activation='sigmoid', name='wine_type')(x)

# define the model using the input and output layers

 model = Model(inputs=inputs, outputs=[wine_type,wine_quality])

 return model

layer_3_activation_check: wine_quality layer has an incorrect activation. Please check implementation.
Expected: <function sigmoid at 0x7f66e57b39e0>
Result: <function linear at 0x7f66e57b3b90>
Please open utils.py if you want to see the unit test here.

1 Tests passed
1 Tests failed

Exception Traceback (most recent call last)
in
----> 1 utils.test_final_model(final_model)

~/work/release/W1_Assignment/utils.py in test_final_model(final_model)
279 ]
280
→ 281 test_loop(test_cases)
282
283 def test_model_compile(model):

~/work/release/W1_Assignment/utils.py in test_loop(test_cases)
25 print(’\033[92m’, success," Tests passed")
26 print(’\033[91m’, fails, " Tests failed")
—> 27 raise Exception(“Please check the error messages above.”)
28
29 def test_white_df(white_df):

Exception: Please check the error messages above.

It shows an error if I do not use activation for that output.

No, thats supposed to be like that. Try having the input as a list. Otherwise if it doesnt work I suggest you redo the lab because obviously you are not following the instructions somewhere.

I have found the problem. I should have written wine_quality followed by wine_type for the outputs. Tqvm for helping.

2 Likes

Such a trivia to make such a issue​:sweat_smile:.

I made this same mistake. Was not easy to work backwards from the error message to this cause.