Created
January 29, 2018 06:00
-
-
Save datalater/05bdd1c751c6f452062b109be2117699 to your computer and use it in GitHub Desktop.
3filters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.layers import Merge | |
import keras.backend.tensorflow_backend as K | |
with K.tf.device('/gpu:0'): | |
filter_sizes = [3,4,5] | |
drop_out_rate = 0.5 | |
hidden_dims = 50 | |
model.add(Embedding(vocab_size, 100, input_length=max_length)) | |
for idx, sz in enumerate(filter_sizes): | |
model.add(Conv1D(filters=100, kernel_size=sz, activation='relu', strides=1, padding='valid')) | |
model.add((MaxPooling1D(pool_size=2))) | |
model.add(Dropout(drop_out_rate)) | |
model.add(Flatten()) | |
model.add(Dense(hidden_dims, activation="relu")) | |
model.add(Dense(10, activation='softmax')) | |
print(model.summary()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment