Last active
June 2, 2020 01:07
-
-
Save sai-teja-ponugoti/d6dd52369520a18f4bff8e99638e27d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
embedding_dim = 16 | |
# creating a model for sentiment analysis | |
model = tf.keras.Sequential([ | |
# addinging an Embedding layer for Neural Network to learn the vectors | |
tf.keras.layers.Embedding(vocab_size, embedding_dim, input_length = max_length), | |
# Global Average pooling is similar to adding up vectors in this case | |
tf.keras.layers.GlobalAveragePooling1D(), | |
tf.keras.layers.Dense(24, activation = 'relu'), | |
tf.keras.layers.Dense(1, activation = 'sigmoid') | |
]) | |
model.compile(loss = 'binary_crossentropy', optimizer = 'adam', metrics = ['accuracy']) | |
num_epochs = 10 | |
history = model.fit(training_padded,training_labels, epochs = num_epochs, | |
validation_data = (testing_padded,testing_labels)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment