【发布时间】:2021-11-09 00:50:00
【问题描述】:
Google colab 上的温度预测时间序列教程很好地介绍了如何设置各种模型的训练、验证和测试性能。如何使用这个训练有素的 multi_conv_model 使用新的未标记数据运行温度预测。专门寻找如何仅使用输入数据框调用 Keras 预测函数。
CONV_WIDTH = 3
multi_conv_model = tf.keras.Sequential([
# Shape [batch, time, features] => [batch, CONV_WIDTH, features]
tf.keras.layers.Lambda(lambda x: x[:, -CONV_WIDTH:, :]),
# Shape => [batch, 1, conv_units]
tf.keras.layers.Conv1D(256, activation='relu', kernel_size=(CONV_WIDTH)),
# Shape => [batch, 1, out_steps*features]
tf.keras.layers.Dense(OUT_STEPS*num_features,
kernel_initializer=tf.initializers.zeros()),
# Shape => [batch, out_steps, features]
tf.keras.layers.Reshape([OUT_STEPS, num_features])
])
history = compile_and_fit(multi_conv_model, multi_window)
IPython.display.clear_output()
multi_val_performance['Conv'] = multi_conv_model.evaluate(multi_window.val)
multi_performance['Conv'] = multi_conv_model.evaluate(multi_window.test, verbose=0)
multi_window.plot(multi_conv_model)
这是我尝试过的,但它没有给出有意义的 5 期预测:
predict_inputs_df = test_df[:20] # or some other input data points
predict_inputs_df = (predict_inputs_df - train_mean) / train_std
predictions = conv_model(tf.stack([np.array(predict_inputs_df)]))
predictions
【问题讨论】:
标签: tensorflow keras deep-learning time-series conv-neural-network