30 集对于这项任务来说似乎太少了,因为输入和输出的维度太多 (30)。如果您需要映射这些高维数据,则需要数千个示例(更多集)。
我建议模拟转换以生成数千个样本。然后使用一个小型神经网络从 X 预测 Y。因为,输入没有空间或时间维度,而是代表离散点,我认为卷积或循环模型不会有用。
因此,从具有均方误差损失的小型 MLP 开始。但是,如果输出点总是整数,那么考虑到范围不大,您也可以将其建模为分类问题。
我在 keras 中添加了一个小型神经网络模型来预测转换。
import numpy as np
import keras
import tensorflow
from keras.layers import Input, Dense, Reshape
from keras.models import Model
X = np.random.randint(-100, 100, (3000, 10, 3)) # 10 3d points
Y = 2*(X + 5)/7 # this is our simple transformation operation
print(X.shape)
print(Y.shape)
in_m = Input(shape=(30,)) # input layer
f1_fc = Dense(100, activation = 'relu')(in_m) # first fc layer
f2_fc = Dense(30, activation = 'linear')(f1_fc) # second fc layer
simple_model = Model(in_m, f2_fc)
simple_model.summary()
simple_model.compile(loss='mse', metrics=['mae'], optimizer='adam')
X_flat = np.reshape(X, (3000, 30))
Y_flat = np.reshape(Y, (3000, 30))
hist = simple_model.fit(X_flat, Y_flat, epochs = 100, validation_split = 0.2, batch_size = 20)
输出:
(3000, 10, 3)
(3000, 10, 3)
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_9 (InputLayer) (None, 30) 0
_________________________________________________________________
dense_15 (Dense) (None, 100) 3100
_________________________________________________________________
dense_16 (Dense) (None, 30) 3030
=================================================================
Total params: 6,130
Trainable params: 6,130
Non-trainable params: 0