def init_state(inputs, state_shape, state_initializer=tf.zeros_initializer, dtype=tf.float32):
 if (inputs is not None):
  inferred_batch_size = inputs.get_shape().with_rank_at_least(1)[0]
  batch_size = tf.shape(inputs)[0]
  dtype = inputs.dtype
 else:
  inferred_batch_size = 0
  batch_size = 0
 initial_state = state_initializer(tf.pack(([batch_size] + state_shape)), dtype=dtype)
 initial_state.set_shape(([inferred_batch_size] + state_shape))
 return initial_state

def init_state ( inputs , state_shape , state_initializer = tf . zeros_initializer , dtype = tf . float32 ) : if ( inputs is not None ) : inferred_batch_size = inputs . get_shape ( ) . with_rank_at_least ( 1 ) [ 0 ] batch_size = tf . shape ( inputs ) [ 0 ] dtype = inputs . dtype else : inferred_batch_size = 0 batch_size = 0 initial_state = state_initializer ( tf . pack ( ( [ batch_size ] + state_shape ) ) , dtype = dtype ) initial_state . set_shape ( ( [ inferred_batch_size ] + state_shape ) ) return initial_state
helper function to create an initial state given inputs .