cnn-text classification code example
Example: cnn architecture for text classification
sequence_input = Input(shape=(MAX_SEQUENCE_LENGTH,), dtype='int32')embedded_sequences = embedding_layer(sequence_input)l_cov1= Conv1D(128, 5, activation='relu')(embedded_sequences)l_pool1 = MaxPooling1D(5)(l_cov1)l_cov2 = Conv1D(128, 5, activation='relu')(l_pool1)l_pool2 = MaxPooling1D(5)(l_cov2)l_cov3 = Conv1D(128, 5, activation='relu')(l_pool2)l_pool3 = MaxPooling1D(35)(l_cov3) # global max poolingl_flat = Flatten()(l_pool3)l_dense = Dense(128, activation='relu')(l_flat)preds = Dense(len(macronum), activation='softmax')(l_dense)