【发布时间】:2018-12-04 01:04:37
【问题描述】:
我想使用 keras 根据 n 个输入预测 x、y 坐标。我不清楚为什么我的网络在大约 5 个时期后不会改善。如果我的输入变量从 5-14(x) 和 5-11(y) 变化,我不明白为什么 x=2.9 和 y=2.1 等网络值。如何获得更好的预测?
数据:
input:
[[-92. 0. -83. 0. 0. 0. ]
[ 0. 0. 0. -82. 0. 0. ]
...
[-65.5 -82. 0. 0. 0. 0. ]]
output:
[[ 5 5]
[ 5 5]
...
[11 14]]
Results:
Predicted: [4.396636 4.019871] label: [11 14] Difference: 16.583492755889893
Predicted: [2.9728146 2.1784768] label: [11 14] Difference: 19.848708629608154
Predicted: [3.9281645 4.2113876] label: [11 14] Difference: 16.860447883605957
网络:
from keras.models import Sequential
from keras.layers import *
model = Sequential()
model.add(Dense(16, input_dim = ipad_test_numpy_input.shape[1], activation='linear'))
model.add(Dense(8, activation='linear'))
model.add(Dense(2, activation='linear'))
model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(ipad_numpy_input, ipad_numpy_labels, epochs=50, batch_size=5)
score = model.evaluate(ipad_test_numpy_input, ipad_test_numpy_labels, batch_size=5)
【问题讨论】:
-
除了下面的答案之外,您还需要在将数据输入神经网络之前规范化...
标签: python neural-network keras regression prediction