As inception style networks uses I like to branch a layer's output and merge at the end of the next layer. I implemented that by the following snippet but I got DisconnectedInputError
# model is defined previously as the last layers output
# conv 3x3
left = Sequential()
left = ConvFactory(left, kernel=(3, 3), stride=(2, 2), num_filter=ch_3x3,
input_shape = model.output_shape[1:])
# pool
right = Sequential()
right.add(layers.MaxPooling2D(pool_size=(3, 3), strides=(2, 2),
input_shape = model.output_shape[1:]))
model.add(layers.Merge([left, right], mode='concat',concat_axis=1))
`from keras.layers import merge, Convolution2D, MaxPooling2D, Input
input_img = Input(shape=(3, 256, 256))
tower_1 = Convolution2D(64, 1, 1, border_mode='same', activation='relu')(input_img)
tower_1 = Convolution2D(64, 3, 3, border_mode='same', activation='relu')(tower_1)
tower_2 = Convolution2D(64, 1, 1, border_mode='same', activation='relu')(input_img)
tower_2 = Convolution2D(64, 5, 5, border_mode='same', activation='relu')(tower_2)
tower_3 = MaxPooling2D((3, 3), strides=(1, 1), border_mode='same')(input_img)
tower_3 = Convolution2D(64, 1, 1, border_mode='same', activation='relu')(tower_3)
output = merge([tower_1, tower_2, tower_3], mode='concat', concat_axis=1)`
These codes come directly from official document. Hope it will help.
http://keras.io/getting-started/functional-api-guide/#getting-started-with-the-keras-functional-api
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, but feel free to re-open it if needed.
Most helpful comment
`from keras.layers import merge, Convolution2D, MaxPooling2D, Input
input_img = Input(shape=(3, 256, 256))
tower_1 = Convolution2D(64, 1, 1, border_mode='same', activation='relu')(input_img)
tower_1 = Convolution2D(64, 3, 3, border_mode='same', activation='relu')(tower_1)
tower_2 = Convolution2D(64, 1, 1, border_mode='same', activation='relu')(input_img)
tower_2 = Convolution2D(64, 5, 5, border_mode='same', activation='relu')(tower_2)
tower_3 = MaxPooling2D((3, 3), strides=(1, 1), border_mode='same')(input_img)
tower_3 = Convolution2D(64, 1, 1, border_mode='same', activation='relu')(tower_3)
output = merge([tower_1, tower_2, tower_3], mode='concat', concat_axis=1)`
These codes come directly from official document. Hope it will help.
http://keras.io/getting-started/functional-api-guide/#getting-started-with-the-keras-functional-api