Skip to content

Instantly share code, notes, and snippets.

@Myeongjoon
Created August 9, 2018 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Myeongjoon/c574cfe5a7f5b0cc5794a23523d2d82e to your computer and use it in GitHub Desktop.
Save Myeongjoon/c574cfe5a7f5b0cc5794a23523d2d82e to your computer and use it in GitHub Desktop.
RNN output 스텝
# 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