Skip to content

Instantly share code, notes, and snippets.

@oscar-defelice
Created November 4, 2020 08:29
Show Gist options
  • Select an option

  • Save oscar-defelice/1b6f58bfb7b038ad96c8e440161fc18f to your computer and use it in GitHub Desktop.

Select an option

Save oscar-defelice/1b6f58bfb7b038ad96c8e440161fc18f to your computer and use it in GitHub Desktop.
# build the model
keras_model = Sequential()
keras_model.add(Embedding(vocab_size, output_dim = emb_dim, input_length=max_len))
keras_model.add(Dropout(dropout_rate))
keras_model.add(Conv1D(50, 3, activation='relu', padding='same', strides=1))
keras_model.add(MaxPool1D())
keras_model.add(Dropout(dropout_rate))
keras_model.add(Conv1D(100, 3, activation='relu', padding='same', strides=1))
keras_model.add(MaxPool1D())
keras_model.add(Dropout(dropout_rate))
keras_model.add(Conv1D(200, 3, activation='relu', padding='same', strides=1))
keras_model.add(GlobalMaxPool1D())
keras_model.add(Dropout(dropout_rate))
keras_model.add(Dense(100))
keras_model.add(Activation('relu'))
keras_model.add(Dropout(dropout_rate))
keras_model.add(Dense(n_labels))
keras_model.add(Activation('softmax'))
keras_model.compile(loss=loss, metrics=[metric], optimizer=opt)
keras_model.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment