【问题标题】:How to use exception architecture如何使用异常架构
【发布时间】:2018-04-27 06:17:11
【问题描述】:

我想使用 xception 模型对图像进行分类,但我得到了 valuerror。

xception=keras.applications.xception.Xception(include_top=False,input_shape=(71,71,3))
classifier=Sequential()
for layer in xception.layers:
    classifier.add(layer)

我遇到了这个错误

ValueError: Input 0 is incompatible with layer conv2d_1: expected axis -1 of input shape to have value 64 but got shape (None, 33, 33, 128)

我在使用 resnet 时也遇到了这个错误。但是当我使用 vgg16 或 vgg19 时我没有得到它。谁能说一下如何使用它??

【问题讨论】:

  • 我不知道为什么我们会得到这个,但你可以使用函数式 api 来避免这个错误
  • 你能说一下使用函数式api是什么意思吗?
  • 查看答案
  • input_tensor=Input(shape=(71,71,3)) xception=keras.applications.xception.Xception(include_top=False,input_tensor=input_tensor).这行得通
  • 哈哈我刚写的一样

标签: python-3.x keras convolutional-neural-network


【解决方案1】:

您可以使用函数式 API。这是分类器的一个可能示例

#Base model Xception
xception=keras.applications.xception.Xception(include_top=False,input_shape=(71,71,3))

# Input of your model
input=Input(shape=(71,71,3))
# Add the inception base model to your model
y=xception(input)
    .

    .
# Other layers by passing previous output  
y=Dense(...)(y)
# Define model
model=Model(input,y)

Docs

【讨论】:

  • 我们不用把它弄平,这里面怎么办?
  • 这是一种方法
  • GlobalaveragePooling2D 和 flattening 相同还是不同?
  • 他们是不同的
猜你喜欢
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多