(self, cell_fn)
Create a SlimRNNCell from a cell_fn.

    Args:
      cell_fn: a function which takes (inputs, state, scope) and produces the
        outputs and the new_state. Additionally when called with inputs=None and
        state=None it should return (initial_outputs, initial_state).

    Raises:
      TypeError: if cell_fn is not callable
      ValueError: if cell_fn cannot produce a valid initial state.
Create a SlimRNNCell from a cell_fn.
Create a SlimRNNCell from a cell_fn .
def __init__(self, cell_fn):
    """Create a SlimRNNCell from a cell_fn.

    Args:
      cell_fn: a function which takes (inputs, state, scope) and produces the
        outputs and the new_state. Additionally when called with inputs=None and
        state=None it should return (initial_outputs, initial_state).

    Raises:
      TypeError: if cell_fn is not callable
      ValueError: if cell_fn cannot produce a valid initial state.
    """
    if not callable(cell_fn):
      raise TypeError("cell_fn %s needs to be callable", cell_fn)
    self._cell_fn = cell_fn
    self._cell_name = cell_fn.func.__name__
    init_output, init_state = self._cell_fn(None, None)
    output_shape = init_output.get_shape()
    state_shape = init_state.get_shape()
    self._output_size = output_shape.with_rank(2)[1].value
    self._state_size = state_shape.with_rank(2)[1].value
    if self._output_size is None:
      raise ValueError("Initial output created by %s has invalid shape %s" %
                       (self._cell_name, output_shape))
    if self._state_size is None:
      raise ValueError("Initial state created by %s has invalid shape %s" %
                       (self._cell_name, state_shape))
def __init__ ( self , cell_fn ) : if not callable ( cell_fn ) : raise TypeError ( "cell_fn %s needs to be callable" , cell_fn ) self . _cell_fn = cell_fn self . _cell_name = cell_fn . func . __name__ init_output , init_state = self . _cell_fn ( None , None ) output_shape = init_output . get_shape ( ) state_shape = init_state . get_shape ( ) self . _output_size = output_shape . with_rank ( 2 ) [ 1 ] . value self . _state_size = state_shape . with_rank ( 2 ) [ 1 ] . value if self . _output_size is None : raise ValueError ( "Initial output created by %s has invalid shape %s" % ( self . _cell_name , output_shape ) ) if self . _state_size is None : raise ValueError ( "Initial state created by %s has invalid shape %s" % ( self . _cell_name , state_shape ) )