Last active
March 12, 2020 10:54
-
-
Save aravindpai/c7546863492ec90e9b7506ea51749732 to your computer and use it in GitHub Desktop.
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
#deep learning library | |
from keras.models import * | |
from keras.layers import * | |
from keras.callbacks import * | |
model=Sequential() | |
#embedding layer | |
model.add(Embedding(size_of_vocabulary,300,input_length=100,trainable=True)) | |
#lstm layer | |
model.add(LSTM(128,return_sequences=True,dropout=0.2)) | |
#Global Maxpooling | |
model.add(GlobalMaxPooling1D()) | |
#Dense Layer | |
model.add(Dense(64,activation='relu')) | |
model.add(Dense(1,activation='sigmoid')) | |
#Add loss function, metrics, optimizer | |
model.compile(optimizer='adam', loss='binary_crossentropy',metrics=["acc"]) | |
#Adding callbacks | |
es = EarlyStopping(monitor='val_loss', mode='min', verbose=1,patience=3) | |
mc=ModelCheckpoint('best_model.h5', monitor='val_acc', mode='max', save_best_only=True,verbose=1) | |
#Print summary of model | |
print(model.summary()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment