rllib/utils/tf_utils.py
def zero_logps_from_actions(actions: TensorStructType) -> TensorType:
    """Helper function useful for returning dummy logp's (0) for some actions.

    Args:
        actions: The input actions. This can be any struct
            of complex action components or a simple tensor of different
            dimensions, e.g. [B], [B, 2], or {"a": [B, 4, 5], "b": [B]}.

    Returns:
        A 1D tensor of 0.0 (dummy logp's) matching the batch
        dim of `actions` (shape=[B]).
    """
    # Need to flatten `actions` in case we have a complex action space.
    # Take the 0th component to extract the batch dim.
    action_component = tree.flatten(actions)[0]
    logp_ = tf.zeros_like(action_component, dtype=tf.float32)
    # Logp's should be single values (but with the same batch dim as
    # `deterministic_actions` or `stochastic_actions`). In case
    # actions are just [B], zeros_like works just fine here, but if
    # actions are [B, ...], we have to reduce logp back to just [B].
    while len(logp_.shape) > 1:
        logp_ = logp_[:, 0]
    return logp_
Helper function useful for returning dummy logp's (0) for some actions.

    Args:
        actions: The input actions. This can be any struct
            of complex action components or a simple tensor of different
            dimensions, e.g. [B], [B, 2], or {"a": [B, 4, 5], "b": [B]}.

    Returns:
        A 1D tensor of 0.0 (dummy logp's) matching the batch
        dim of `actions` (shape=[B]).
    
Helper function useful for returning dummy logp's (0) for some actions.
Helper function useful for returning dummy logp ' s ( 0 ) for some actions .
def zero_logps_from_actions(actions: TensorStructType) -> TensorType:
    action_component = tree.flatten(actions)[0]
    logp_ = tf.zeros_like(action_component, dtype=tf.float32)
    while len(logp_.shape) > 1:
        logp_ = logp_[:, 0]
    return logp_
def zero_logps_from_actions ( actions : TensorStructType ) -> TensorType : action_component = tree . flatten ( actions ) [ 0 ] logp_ = tf . zeros_like ( action_component , dtype = tf . float32 ) while len ( logp_ . shape ) > 1 : logp_ = logp_ [ : , 0 ] return logp_
Helper function useful for returning dummy logp's (0) for some actions.
Helper function useful for returning dummy logp ' s ( 0 ) for some actions .
"""Helper function useful for returning dummy logp's (0) for some actions.

    Args:
        actions: The input actions. This can be any struct
            of complex action components or a simple tensor of different
            dimensions, e.g. [B], [B, 2], or {"a": [B, 4, 5], "b": [B]}.

    Returns:
        A 1D tensor of 0.0 (dummy logp's) matching the batch
        dim of `actions` (shape=[B]).
    """ # Need to flatten `actions` in case we have a complex action space. # Take the 0th component to extract the batch dim. # Logp's should be single values (but with the same batch dim as # `deterministic_actions` or `stochastic_actions`). In case # actions are just [B], zeros_like works just fine here, but if # actions are [B, ...], we have to reduce logp back to just [B].
A 1D tensor of 0.0 (dummy logp's) matching the batch
dim of `actions` (shape=[B]).
A 1D tensor of 0 . 0 ( dummy logp ' s ) matching the batch dim of ` actions ` ( shape = [ B ] ) .
actions
TensorStructType
The input actions. This can be any struct
of complex action components or a simple tensor of different
dimensions, e.g.
The input actions . This can be any struct of complex action components or a simple tensor of different dimensions e . g .