Skip to content

Instantly share code, notes, and snippets.

@ayushoriginal
Created June 24, 2019 06:22
Show Gist options
  • Save ayushoriginal/8a9e08405dcb012c1272392c6488fac2 to your computer and use it in GitHub Desktop.
Save ayushoriginal/8a9e08405dcb012c1272392c6488fac2 to your computer and use it in GitHub Desktop.
CNN
def CNN(self):
model = Sequential()
model.add(Embedding(self.vocab_length, 30, input_length=self.max_len)) # Max Length of Tweet
model.add(Convolution1D(64,5,activation="relu"))
model.add(Dropout(0.5))
model.add(Convolution1D(32,3,activation="relu"))
model.add(Dropout(0.5))
model.add(Convolution1D(16,3,activation="sigmoid"))
model.add(MaxPooling1D(5))
model.add(Flatten())
model.add(Dense(self.tr_labels.shape[1],activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam',metrics=['accuracy'])
model.summary()
self.model = model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment