Hi Im currently working on the below program but im getting below error: ValueError: Input 0 of layer "sequential_35" is incompatible with the layer: expected shape=(None, 800, 1, 100), found shape=(None, 1, 100). I need to convert it to 4D output to run the program. Please help. Advance Thank You.
tok = Tokenizer(num_words=max_words)
tok.fit_on_texts(X)
print('Found %s unique tokens.' % len(tok.word_index))
X = tok.texts_to_sequences(X.values)
X = sequence.pad_sequences(X, maxlen=max_len)
print('Shape of data tensor:', X.shape)
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.15)
le = LabelEncoder()
Y_train_enc = le.fit_transform(Y_train)
Y_train_enc = np_utils.to_categorical(Y_train_enc)
Y_test_enc = le.transform(Y_test)
Y_test_enc = np_utils.to_categorical(Y_test_enc)
def malware_model(act_func="softsign"):
model = Sequential()
model.add(Embedding(257, 128, input_shape=(max_words, 1, max_len)))
model.add(ConvLSTM2D(filters=12, kernel_size=(1, 2),
dropout=0.1, activation='relu', return_sequences=True))
model.add(ConvLSTM2D(filters=12, kernel_size=(
1, 2), dropout=0.1, activation='relu'))
model.add(ConvLSTM1D(filters=12, kernel_size=(
1), dropout=0.1, activation='relu'))
model.add(Dense(128, activation=act_func))
model.add(Dropout(0.1))
model.add(Dense(256, activation=act_func))
model.add(Dropout(0.1))
model.add(Dense(128, activation=act_func))
model.add(Dropout(0.1))
model.add(Dense(1, name='out_layer', activation="linear"))
return model
model = malware_model()
print(model.summary())
model.compile(loss='mse', optimizer="rmsprop",
metrics=['accuracy'])
history = model.fit(tf.expand_dims(X_train, axis=1), batch_size=1000, epochs=10,
validation_data=(X_test, Y_test), verbose=1)`
ValueError: Input 0 of layer "sequential_35" is incompatible with the layer: expected shape=(None, 800, 1, 100), found shape=(None, 1, 100)'