这里有两个教程可能会对您有所帮助:
https://towardsdatascience.com/machine-learning-recurrent-neural-networks-and-long-short-term-memory-lstm-python-keras-example-86001ceaaebc
https://stackabuse.com/time-series-analysis-with-lstm-using-pythons-keras-library/
本教程是关于混合数据的:
https://www.pyimagesearch.com/2019/02/04/keras-multiple-inputs-and-mixed-data/
如果您不使用未提及的其他东西,我建议您尝试使用 Keras 来熟悉如何训练它。
只要在 google 上写下你的问题,就能帮你找到很多具体的教程!
编辑:
来自 keras 文档:
keras.utils.to_categorical(y, num_classes=None, dtype='float32')
将类向量(整数)转换为二进制类矩阵。例如。与 categorical_crossentropy 一起使用。
参数
- y:要转换为矩阵的类向量(从 0 到 num_classes 的整数)。
- num_classes:类的总数。
- dtype:输入期望的数据类型,作为字符串(float32、float64、int32...)
返回:
输入的二进制矩阵表示。类轴放在最后。
# Consider an array of 5 labels out of a set of 3 classes {0, 1, 2}:
> labels
array([0, 2, 1, 2, 0])
# `to_categorical` converts this into a matrix with as many
# columns as there are classes. The number of rows
# stays the same.
> to_categorical(labels)
array([[ 1., 0., 0.],
[ 0., 0., 1.],
[ 0., 1., 0.],
[ 0., 0., 1.],
[ 1., 0., 0.]], dtype=float32)