[英]The code is showing syntax error “tf.keras.layers.Dense(units=4)”
We were trying to get started in tensorflow so and we got this error in the celsius to fahrenheit example code of tf. 我们试图从tensorflow开始,因此我们在摄氏到华氏度的tf示例代码中遇到了这个错误。
its a syntax error but as compared to tutorial it looks the same 它是一个语法错误,但与教程相比,它看起来相同
`celsius = np.array([8,10,12,14,16], dtype = float) #data
fahrenheit = np.array([12,13,14,15,16], dtype = float) #data
model = tf.keras.Sequential([ #setting model
tf.keras.layers.Dense(units=4, input_shape=[1])
tf.keras.layers.Dense(units=4) #error in the network
tf.keras.layers.Dense(units=1)
])`
well we are trying to create our first neural network but got stuck here 好吧,我们正在尝试创建我们的第一个神经网络,但被困在这里
Your are adding a list to the model, so the list entries have to be seperated by a ,
instead of only a new line (after each of the dense layers). 您正在向模型中添加一个列表,因此列表条目必须用分隔
,
而不是仅换行(在每个密集层之后)。
Try this: 尝试这个:
celsius = np.array([8,10,12,14,16], dtype = float) #data
fahrenheit = np.array([12,13,14,15,16], dtype = float) #data
model = tf.keras.Sequential([ #setting model
tf.keras.layers.Dense(units=4, input_shape=[1]), #just added , here (and in the next line)
tf.keras.layers.Dense(units=4), #error in the network
tf.keras.layers.Dense(units=1)
])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.