Keras:使用“输入”层时出现“发现:Tensor(“ input_1:0”,shape =(None,256,256,2),dtype = float32)“错误

潘切斯特

我的模特:

model = Sequential()
model.add(Input(shape=input_shape))       
model.add(Flatten())

# 2nd Fully Connected Layer
model.add(Dense(120))
model.add(Activation('relu'))

model.add(Dropout(0.3))

# Output Layer
model.add(Dense(n_classes))
model.add(Activation('softmax'))

我的输入形状是(256,256,2)。我收到此错误:TypeError:添加的层必须是类Layer的实例。找到:Tensor(“ input_1:0”,shape =(None,256,256,2),dtype = float32)。我做错了什么?

教皇教区

输入不会返回图层https://github.com/fchollet/keras/blob/master/keras/engine/topology.py#L1142

它是InputLayer的包装。在使用时Sequential,只需跳过它并使用参数input_shape

model.add(Flatten(input_shape = your_input_shape)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章