Created
December 6, 2018 08:32
-
-
Save hadifar/05222e8f10206d2eede2d39736bd801a 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
# rnn_cell = tf.contrib.rnn.BasicRNNCell(rnn_size) # will remove in tensorflow 2.0 | |
rnn_cell = tf.keras.layers.SimpleRNNCell(rnn_size) | |
outputs, states = tf.nn.dynamic_rnn(rnn_cell, embed, dtype=tf.float32) | |
# RNN outputs: [batch_size * seq_len * hidden_size] | |
# split and extract only last output | |
last_rnn_output = outputs[:, -1, :] | |
# Dense layers | |
dense1 = tf.layers.dense(last_rnn_output, 16, activation='relu') | |
logit = tf.layers.dense(last_rnn_output, 2) | |
pred = tf.nn.softmax(logit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment