In [1]:
import tensorflow as tf
import numpy as np
from tensorflow.contrib import rnn
sess = tf.InteractiveSession()

In [2]:
h = [1,0,0,0]
e = [0,1,0,0]
l = [0,0,1,0]
o = [0,0,0,1]

In [3]:
with tf.variable_scope("one_variable") as scope:
    
    hidden_size = 2
    cell = tf.contrib.rnn.BasicRNNCell(num_units = hidden_size)
    print(cell.output_size, cell.state_size)
    print(cell)
    x = np.array([[h, h],
                  [e, e],
                  [l, l],
                 ], dtype = np.float32)
    print(x)
    output, _state = tf.nn.dynamic_rnn(cell, x,sequence_length= [2,1,1], dtype = tf.float32)
    sess.run(tf.global_variables_initializer())
    
    print(sess.run(output))
    print(sess.run(_state))


2 2
<tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.BasicRNNCell object at 0x7f289b7f1198>
[[[ 1.  0.  0.  0.]
  [ 1.  0.  0.  0.]]

 [[ 0.  1.  0.  0.]
  [ 0.  1.  0.  0.]]

 [[ 0.  0.  1.  0.]
  [ 0.  0.  1.  0.]]]
[[[-0.34647563 -0.55300802]
  [-0.01913427 -0.60014039]]

 [[ 0.52593786  0.59151882]
  [ 0.          0.        ]]

 [[ 0.23493758 -0.51024634]
  [ 0.          0.        ]]]
[[-0.01913427 -0.60014039]
 [ 0.52593786  0.59151882]
 [ 0.23493758 -0.51024634]]

In [ ]: