【发布时间】:2016-08-23 20:36:40
【问题描述】:
我正在尝试为 theano 后端模拟与 SeparableConvolution2D 层等效的东西(它已经存在于 TensorFlow 后端)。作为第一步,我需要做的是将一个通道从张量传递到下一层。假设我有一个名为 conv1 的 2D 卷积层,它有 16 个过滤器,它产生的输出形状为: (batch_size, 16, height, width) 我需要选择形状为 (: , 0, : , : ) 的子张量并将其传递给下一层。够简单吧?
这是我的代码:
from keras import backend as K
image_input = Input(batch_shape = (batch_size, 1, height, width ), name = 'image_input' )
conv1 = Convolution2D(16, 3, 3, name='conv1', activation = 'relu')(image_input)
conv2_input = K.reshape(conv1[:,0,:,:] , (batch_size, 1, height, width))
conv2 = Convolution2D(16, 3, 3, name='conv1', activation = 'relu')(conv2_input)
这会抛出:
Exception: You tried to call layer "conv1". This layer has no information about its expected input shape, and thus cannot be built. You can build it manually via: layer.build(batch_input_shape)
为什么图层没有所需的形状信息?我正在使用 theano 后端的 reshape 。这是将单个通道传递到下一层的正确方法吗?
【问题讨论】:
标签: neural-network theano conv-neural-network keras