I want to design, multi channel CNN.
I got a error message in first Conv2d step. (in figure, first layer to second layer)
My code is as bellows
_concat_embeded = keras.layers.concatenate([_embeding1, _embeding2], axis= -1)
_biCH_embeded = keras.layers.Reshape((2, self.lexicalMaxLength, charWeights.shape[1]))(_concat_embeded)
_1stConv = keras.layers.Conv2D(filters=512, kernel_size=(5, charWeights.shape[1]),
activation=tf.nn.relu)(_biCH_embeded)
Shape at _biCH_embeded is [? 2, 131 ,131] (my embeddings have 131 dimension = charWeights.shape[1])
I want to generate 512 filters, which has (5, 131) shape.
Then, I've got a message, "Negative dimension size caused by subtracting 5 from 2 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: [?,2,33,131], [5,131,131,512]"
Where is problem?
I find the issue.
I reshaped my tensor with "channel_first" rule (2, 133, 133)
But my Keras config is set by "channel_last"
I change the reshape rule to "channel_last" (133,133,2)and training is running now.
(If you want change the Keras config, look at "~/.keras/keras.json")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.