【问题标题】:Predict new coordinates given old coordinates in Tensorflow's Keras在 Tensorflow 的 Keras 中给定旧坐标预测新坐标
【发布时间】:2022-01-20 17:50:00
【问题描述】:

目标是在给定旧的 (x1, y1), (x2, y2) 坐标集时,能够预测新的 (x1, y1), (x2, y2) 坐标集。

也就是说,如果我的旧坐标是(0, 0), (4, 4),我想得到一个像(2, 3, 8, 9)这样的输出,其中数字对应的是(x1, y1 , x2, y2)。

只是,我不知道如何获得这样的多个数字输出。

【问题讨论】:

    标签: python deep-learning neural-network tf.keras


    【解决方案1】:

    您只需要使用顺序模型。据我了解,您的输入尺寸为 4,输出尺寸也为 4。在这种情况下,您会执行以下操作:

    import tensorflow as tf
    from tensorflow import keras
    from tensorflow.keras import layers
    
    model = keras.Sequential(
        [ 
            
            layers.Dense(4, activation="relu", name="layer1", input_shape=(4,)),
            layers.Dense(100, activation="relu", name="layer2"),
            layers.Dense(100, activation="relu", name="layer3"),
            layers.Dense(4, activation="relu", name="layer4"),
        ]
    )
    model.compile(optimizer='sgd', loss='mse')
    

    然后你就可以训练你的模型了。但是,您需要根据自己的数据调整模型的参数和结构。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-18
      • 2018-03-14
      • 2021-10-23
      • 2019-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多