【问题标题】:3d points coordinate regression3d 点坐标回归
【发布时间】:2019-09-25 03:32:46
【问题描述】:

我有 30 组 3D 点,它们是描述 30 个对象的关键点,每组包含 10 个点,这些点表示为 X,形状为 [30,10,3]。我还有30个物体经过一定变换后对应的3D点,表示为Y,形状为[30,10,3]。

现在我想从这 30 个对象中训练一个机器学习模型,使用 X 和 Y 作为数据和注释,并预测转换后新对象的关键点坐标。

有人知道如何用 python 做到这一点吗?

【问题讨论】:

    标签: python machine-learning regression


    【解决方案1】:

    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
    
    
    
    

    【讨论】:

      猜你喜欢
      • 2018-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-14
      相关资源
      最近更新 更多