我有一个X
由均值和标准差组成的数据集,重复 5 次,所以数组中有 10 列
并且Y
由范围组成:
例子:
0 到 20
20 至 40
40 至 60
60 至 80
80 到 100
要将值转换为 0 和 1,每个元素除以其列的最高出现次数,这适用于 X 和 Y
目标:使 X 和 Y 生成接下来的 60 个值
X = 60 个值的块
Y = 每个区块接下来的30个值
问题:出于某种原因,我得到负值,看起来我的神经网络出现故障
X:
[[0.573 0.699 0.412 0.224 0.696 0.512 0.326 0.314 0.79 0.685]
[0.456 0.251 0.629 0.523 0.344 0.286 0.8 0.699 0.721 1. ]
...
[0.229 0.148 0.683 0.624 0.222 0.146 0.687 0.732 0.296 0.184]
[0.646 0.627 0.204 0.152 0.542 0.632 0.36 0.224 0.291 0.215]]
是:
[[1. 0.5 0. 0. 0. ]
[1. 0.5 0. 0. 0. ]
...
[1. 0.5 0. 0. 0. ]
[1. 0.5 0. 0. 0. ]]
脚本:
model = keras.Sequential(
[
layers.Dense(10, activation="sigmoid", name="hidden-input"),
layers.Dense(5, name="output"),
]
)
model.compile(optimizer = 'Adam', loss = 'mse', metrics = ['mae'])
model.fit(X, Y, epochs = 20, batch_size = 10)
print(model.summary())
y = model.predict(X)
概括:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
hidden-input (Dense) multiple 110
_________________________________________________________________
output (Dense) multiple 55
=================================================================
Total params: 165
Trainable params: 165
Non-trainable params: 0
火车:
Epoch 1/20
48/48 [==============================] - 0s 2ms/sample - loss: 0.3500 - mean_absolute_error: 0.4904
...
Epoch 20/20
48/48 [==============================] - 0s 178us/sample - loss: 0.0283 - mean_absolute_error: 0.1172
输出:
[[ 8.6036199e-01 4.6452054e-01 1.3958054e-02 -2.3673278e-01 3.2733783e-02]
[ 9.7470945e-01 4.6182287e-01 6.4254209e-02 -2.0704785e-01 -2.0927802e-02]
...
[ 7.7844203e-01 4.5801651e-01 -2.5306268e-02 -2.8805625e-01 4.5798883e-02]]
qq_笑_17
相关分类