Skip to content

Instantly share code, notes, and snippets.

@hccho2
Last active February 26, 2019 08:39
Show Gist options
  • Save hccho2/547c567ece72fe1a1e07ea7d520608b6 to your computer and use it in GitHub Desktop.
Save hccho2/547c567ece72fe1a1e07ea7d520608b6 to your computer and use it in GitHub Desktop.
# coding: utf-8
import tensorflow as tf
import numpy as np
tf.reset_default_graph()
batch_size=2
T=3
input_dim=4
hidden_dim=50
#a = np.arange(batch_size*T*input_dim).reshape(batch_size,T,input_dim).astype(np.float32)
a=np.random.randn(batch_size,T,input_dim)
x = tf.convert_to_tensor(a,tf.float32)
cell = tf.contrib.rnn.GRUCell(num_units=hidden_dim)
initial_state = cell.zero_state(batch_size, tf.float32)
outputs, states = tf.nn.dynamic_rnn(cell,x,initial_state=initial_state,dtype=tf.float32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment