【发布时间】:2022-01-15 02:11:16
【问题描述】:
我尝试创建一个只有一个隐藏层的最小 非卷积 NN 图像二元分类器(作为更复杂模型之前的实践):
def make_model(input_shape):
inputs = keras.Input(shape=input_shape)
x = layers.Dense(128, activation="ReLU")(inputs)
outputs = layers.Dense(1, activation="sigmoid")(x)
return keras.Model(inputs, outputs)
model = make_model(input_shape=(256, 256, 3))
它的model.summary() 显示
Model: "model"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) [(None, 256, 256, 3)] 0
dense (Dense) (None, 256, 256, 128) 512
dense_1 (Dense) (None, 256, 256, 1) 129
=================================================================
Total params: 641
Trainable params: 641
Non-trainable params: 0
由于dense_1 层只有一个神经元,我期望该层的输出形状为(None, 1)(即,表示预测的二进制标签的单个数字),但模型给出了(None, 256, 256, 1) .
我的模型设置有什么问题,如何才能正确设置?
【问题讨论】:
标签: python tensorflow keras