coursera assignment python file compiling error


i have a coursera assignment in jupyter notebook the problem is that in jupyter it runs correctly but when i submit it fail and shows this error :
Can’t compile the student’s code. invalid syntax (, line 23)

the task is :
In this exercise you’ll try to build a neural network that predicts the price of a house according to a simple formula.

So, imagine if house pricing was as easy as a house costs 50k + 50k per bedroom, so that a 1 bedroom house costs 100k, a 2 bedroom house costs 150k etc.

How would you create a neural network that learns this relationship so that it would predict a 7 bedroom house as costing close to 400k etc.

Hint: Your network might work better if you scale the house price down. You don’t have to give the answer 400…it might be better to create something that predicts the number 4, and then your answer is in the ‘hundreds of thousands’ etc.

my answer was

import tensorflow as tf
import numpy as np
from tensorflow import keras
def house_model(y_new):
   xs = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0], dtype=float)
   ys = np.array([100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 450.0, 500.0, 550.0,600.0, 650.0,700.0], dtype=float)

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

   return (model.predict(y_new)[0]+1) //100
prediction = house_model([7.0])


Just remove the last two blocks of JavaScript. It worked for me.

Answered By – Varad More

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published