Reputation: 1217
I am trying to recreate the Inception model version 4. But i want to train it on my image data set standard shape (224,224,3)
,so i am not taking in any pretrained weights.
But I am getting an error like this.
x = merge([x1, x2], mode='concat', concat_axis=channel_axis)
TypeError: 'module' object is not callable
Here is the code:
def inception_stem(input):
if K.image_dim_ordering() == "th":
channel_axis = 1
else:
channel_axis = -1
# Input Shape is 299 x 299 x 3 (th) or 3 x 299 x 299 (th)
x = conv_block(input, 32, 3, 3, subsample=(2, 2), border_mode='valid')
x = conv_block(x, 32, 3, 3, border_mode='valid')
x = conv_block(x, 64, 3, 3)
x1 = MaxPooling2D((3, 3), strides=(2, 2), border_mode='valid')(x)
x2 = conv_block(x, 96, 3, 3, subsample=(2, 2), border_mode='valid')
x = tf.concat([x1,x2],axis=channel_axis)
#x = merge([x1, x2], mode='concat', concat_axis=channel_axis) #here is the error occuring try find out the reason behind it
x1 = conv_block(x, 64, 1, 1)
x1 = conv_block(x1, 96, 3, 3, border_mode='valid')
x2 = conv_block(x, 64, 1, 1)
x2 = conv_block(x2, 64, 1, 7)
x2 = conv_block(x2, 64, 7, 1)
x2 = conv_block(x2, 96, 3, 3, border_mode='valid')
x = merge([x1, x2], mode='concat', concat_axis=channel_axis)
x1 = conv_block(x, 192, 3, 3, subsample=(2, 2), border_mode='valid')
x2 = MaxPooling2D((3, 3), strides=(2, 2), border_mode='valid')(x)
x = merge([x1, x2], mode='concat', concat_axis=channel_axis)
return x
I am using python 3.6
,keras 2.2.2
, tensorflow-gpu 1.9.0
.
I followed the GitHub for the issue, but the answers were not clear and exact. Can anyone find the solution.
Upvotes: 1
Views: 935
Reputation: 2632
Use the concatenate layer, that should help you
from tensorflow.python.keras.layers import concatenate
x = concatenate([x1, x2], axis=channel_axis)
return x
Upvotes: 2