首页 > 解决方案 > 如何在 tf.keras 中指定输出层的单位?

问题描述

在我的数据集中,单个输入和输出的形状是 15 x 61。我指定 input_shape=(15,61)。这意味着 15 x 61 到 15 x 61 之间的映射,这不是分类问题。输出层中的单位规范应该是什么?

model = tf.keras.models.Sequential([tf.keras.layers.Dense(units=128,input_shape =(15,61),
tf.keras.layers.Dense(units=128, activation=tf.nn.relu),
tf.keras.layers.Dense(units=, activation=tf.nn.softmax)])

标签: tf.keras

解决方案


您在 Dense 上的 Keras turorial中拥有所有信息。如果你想进行分类,输出形状必须是类的数量。如果您希望 15 * 61 作为输入和 15*61 作为输出,只需将所有这些 : 展平15 x 61 = 915,因此采用 915 大小的图层并输出 915 大小的图层,然后对其进行整形以获得初始形状。


推荐阅读