I want to design a BiLstm-Alexnet Model. I wrote the below code for defining the model architecture:
model= Sequential()
model.add(Reshape((450,2,2),input_shape=(900,1,2)))
model.add(Conv2D(456, kernel_size=(11,1), strides=(1,1), padding="same", activation="relu", kernel_initializer="he_normal",
kernel_regularizer=l2(weight), bias_regularizer=l2(weight),input_shape=(900,1,2)))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(3,1)))
model.add(Conv2D(256, kernel_size=(5,1), strides=1, padding="same", activation="relu", kernel_initializer="he_normal",
kernel_regularizer=l2(weight), bias_regularizer=l2(weight)))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(3,1)))
model.add(Conv2D(384, kernel_size=(3,1), strides=(1,1), padding="same", activation="relu", kernel_initializer="he_normal",
kernel_regularizer=l2(weight), bias_regularizer=l2(weight)))
model.add(BatchNormalization())
model.add(Conv2D(384, kernel_size=(3,1), strides=1, padding="same", activation="relu", kernel_initializer="he_normal",
kernel_regularizer=l2(weight), bias_regularizer=l2(weight)))
model.add(BatchNormalization())
model.add(Conv2D(256, kernel_size=(3,1), strides=1, padding="same", activation="relu", kernel_initializer="he_normal",
kernel_regularizer=l2(weight), bias_regularizer=l2(weight)))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(3,1),strides=(2,1)))
model.add(Permute((2,1,3)))
#.add(Embedding(max_features, embedding_size, input_length=maxlen*max_charlen))
model.add(Reshape((2,4*256)))
model.add(Bidirectional(LSTM(64, return_sequences=True)))
model.add(Flatten())
model.add(Dense(18, activation="relu"))
model.add(Dense(2, activation="softmax"))
return model
When I try to compile the model, I am getting the following error:
ValueError: Exception encountered when calling layer "reshape_5" (type Reshape).
total size of new array must be unchanged, input_shape = [2, 24, 256], output_shape = [2, 1024]
Call arguments received by layer "reshape_5" (type Reshape):
• inputs=tf.Tensor(shape=(None, 2, 24, 256), dtype=float32)
Which layer is called reshape_5
? Why I am receiving this error? How can I fix my Error?