請問 SyntaxError: invalid syntax的錯誤,是指哪邊錯了
print("Here is what learned: {}".format(10.get_weights()))
另外我是用gooogle的Colab 不知道有沒有關係?
以下的內容是來自書籍歐萊禮出版的"從程式員到AI專家" page 18頁
import tensorflow as tf
import numpy as np
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense
10 = Dense(units=1, input_shape=[1])
model = Sequential([10])
model.compile(optimizer='sgd', loss='mean_squared_error')
xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)
model.fit(xs, ys, epochs=500)
print(model.predict([10.0]))
print("Here is what learned: {}".format(10.get_weights()))
File "<ipython-input-1-1b6e69b84ead>", line 16
print("Here is what learned: {}".format(10.get_weights()))
^
SyntaxError: invalid syntax