RNNCellBase¶
- class paddle.nn. RNNCellBase ( name_scope=None, dtype='float32' ) [source]
- 
         RNNCellBase is the base class for abstraction representing the calculations mapping the input and state to the output and new state. It is suitable to and mostly used in RNN. - 
            
           get_initial_states
           (
           batch_ref, 
           shape=None, 
           dtype=None, 
           init_value=0.0, 
           batch_dim_idx=0
           )
           get_initial_states¶
- 
           Generate initialized states according to provided shape, data type and value. - Parameters
- 
             - batch_ref (Tensor) – A tensor, which shape would be used to determine the batch size, which is used to generate initial states. For batch_ref’s shape d, d[batch_dim_idx] is treated as batch size. 
- shape (list|tuple, optional) – A (possibly nested structure of) shape[s], where a shape is a list/tuple of integer. -1 (for batch size) will be automatically prepended if a shape does not starts with it. If None, property state_shape will be used. Defaults to None. 
- dtype (str|list|tuple, optional) – A (possibly nested structure of) data type[s]. The structure must be same as that of shape, except when all tensors’ in states has the same data type, a single data type can be used. If None and property cell.state_shape is not available, current default floating type of paddle is used. Defaults to None. 
- init_value (float, optional) – A float value used to initialize states. Defaults to 0. 
- batch_dim_idx (int, optional) – An integer indicating which dimension of the of batch_ref represents batch. Defaults to 0. 
 
- Returns
- 
             
             - tensor of the provided shape and
- 
               dtype, or list of tensors that each satisfies the requirements, packed in the same structure as shape and type does. 
 
- Return type
- 
             init_states (Tensor|tuple|list) 
 
 - property state_shape
- 
           Abstract method (property). Used to initialize states. A (possiblely nested structure of) shape[s], where a shape is a list/tuple of integers (-1 for batch size would be automatically inserted into a shape if shape is not started with it). Not necessary to be implemented if states are not initialized by get_initial_states or the shape argument is provided when using get_initial_states. 
 - property state_dtype
- 
           Abstract method (property). Used to initialize states. A (possiblely nested structure of) data types[s]. The structure must be same as that of shape, except when all tensors’ in states has the same data type, a signle data type can be used. Not necessary to be implemented if states are not initialized by get_initial_states or the dtype argument is provided when using get_initial_states. 
 
- 
            
           get_initial_states
           (
           batch_ref, 
           shape=None, 
           dtype=None, 
           init_value=0.0, 
           batch_dim_idx=0
           )
           
