Created
August 9, 2018 23:21
-
-
Save Myeongjoon/c574cfe5a7f5b0cc5794a23523d2d82e to your computer and use it in GitHub Desktop.
RNN output 스텝
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
# Weights for output layers | |
with tf.name_scope('linear_layer_weights') as scope: | |
with tf.name_scope("W_linear"): | |
Wl = tf.Variable(tf.truncated_normal([hidden_layer_size, num_classes], | |
mean=0, stddev=.01)) | |
variable_summaries(Wl) | |
with tf.name_scope("Bias_linear"): | |
bl = tf.Variable(tf.truncated_normal([num_classes], | |
mean=0, stddev=.01)) | |
variable_summaries(bl) | |
# Apply linear layer to state vector | |
def get_linear_layer(hidden_state): | |
return tf.matmul(hidden_state, Wl) + bl | |
with tf.name_scope('outputs') as scope: | |
# Iterate across time, apply linear layer to all RNN outputs | |
all_outputs = tf.map_fn(get_linear_layer, all_hidden_states) | |
# Get Last output -- h_28 | |
output = all_outputs[-1] | |
tf.summary.histogram('outputs', output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment