Skip to content

Instantly share code, notes, and snippets.

@aravindpai
Created March 26, 2020 21:19
Show Gist options
  • Save aravindpai/ba51f9ea6c6da29dd8b69db59df6bf10 to your computer and use it in GitHub Desktop.
Save aravindpai/ba51f9ea6c6da29dd8b69db59df6bf10 to your computer and use it in GitHub Desktop.
from keras.layers import *
from keras.models import *
from keras.callbacks import *
import keras.backend as K
K.clear_session()
model = Sequential()
#embedding layer
model.add(Embedding(len(unique_x), 100, input_length=32,trainable=True))
model.add(Conv1D(64,3, padding='causal',activation='relu'))
model.add(Dropout(0.2))
model.add(MaxPool1D(2))
model.add(Conv1D(128,3,activation='relu',dilation_rate=2,padding='causal'))
model.add(Dropout(0.2))
model.add(MaxPool1D(2))
model.add(Conv1D(256,3,activation='relu',dilation_rate=4,padding='causal'))
model.add(Dropout(0.2))
model.add(MaxPool1D(2))
#model.add(Conv1D(256,5,activation='relu'))
model.add(GlobalMaxPool1D())
model.add(Dense(256, activation='relu'))
model.add(Dense(len(unique_y), activation='softmax'))
model.compile(loss='sparse_categorical_crossentropy', optimizer='adam')
model.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment