【发布时间】:2020-03-10 15:17:18
【问题描述】:
我正在通过 TensorFlow (tfjs) 学习机器学习。
我的第一个测试是训练我的模型来预测 cos(x) 作为 x 的函数(从 0 到 2*Math.PI*4 aka 4 个周期)
特征:2000 个 x 值(随机)
label: cos(x) 的 2000 个值
型号:
const model = tf.sequential({
layers: [
tf.layers.dense({ inputShape: [1], units: 22, activation: 'tanh' }),
tf.layers.dense({ units: 1 }),
]
});
model.compile({
optimizer: tf.train.adam(0.01),
loss: 'meanSquaredError',
metrics: ['mae']
});
...
await model.fit(feature, label, {
epochs: 500,
validationSplit: 0.2,
})
结果相当“有趣”:
现在我想知道如何增强我的模型以适应 cos(x) 的周期性(不使用 cos(x) 的数学周期性,例如 y = cos(x modulo 2PI))。
我的模型是否有可能“理解”存在周期性?
【问题讨论】:
标签: tensorflow machine-learning keras tfjs-node