Last active
December 31, 2018 01:49
-
-
Save lettergram/a330f4e54983583ef36090c7021c9913 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
import keras | |
model = Sequential() | |
# Input (max_words) --(W1)-> Hidden Layer (512) | |
model.add(Dense(512, input_shape=(max_words,))) | |
model.add(Activation('tanh')) | |
model.add(Dropout(0.5)) | |
# Hidden Layer (512) --(W2)--> Output Layer (num_classes) | |
model.add(Dense(num_classes)) | |
model.add(Activation('softmax')) | |
# Add optimization method, loss function, and optimization value | |
model.compile(loss='categorical_crossentropy', | |
optimizer='adam', metrics=['accuracy']) | |
# "Fit model" (train model), using training data (80% of data) | |
model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs) | |
# Evaluate the trained model, using the test data (20% of data) | |
score = model.evaluate(x_test, y_test, batch_size=batch_size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment