elegy/hooks.py
def add_summary(name: tp.Optional[str], value: np.ndarray) -> None:
    """
    A hook that lets you define a summary in the current module. Its primary
    use is to keep track of certain values as they flow through the network
    so `Model.summary()` can show a representation of architecture.

    ```python
    def call(self, x):
        ...
        y = jax.nn.relu(x)
        elegy.add_summary("relu", y)
        ...
    ```

    The summaries will be aggregated by [`apply`][elegy.module.Module.apply]
    if `get_summaries` is set to `True`, else this hook does nothing.

    ```python
    transformed_state = transform.apply(..., get_summaries=True, ...)
    ```

    Arguments:
        name: The name of the loss. If a summary with the same
            `name` already exists a unique identifier will be generated.
        value: The value for the summary.
    """

    if LOCAL.contexts:
        context: Context = LOCAL.contexts[-1]
        module = context.module_c[-1]

        if not context.get_summaries:
            return

        # name = level_names[module]
        base_name = "/".join(context.path_names_c)

        base_name = f"{base_name}/{name}" if name is not None else base_name
        base_name = get_unique_name(context.summaries, base_name)
        module = module if name is None else None  # pass module only if name is None

        context.summaries.append((module, base_name, value))
    else:
        raise ValueError("Cannot execute `add_summary` outside of an `elegy.context`")

    A hook that lets you define a summary in the current module. Its primary
    use is to keep track of certain values as they flow through the network
    so `Model.summary()` can show a representation of architecture.

    ```python
    def call(self, x):
        ...
        y = jax.nn.relu(x)
        elegy.add_summary("relu", y)
        ...
    ```

    The summaries will be aggregated by [`apply`][elegy.module.Module.apply]
    if `get_summaries` is set to `True`, else this hook does nothing.

    ```python
    transformed_state = transform.apply(..., get_summaries=True, ...)
    ```

    Arguments:
        name: The name of the loss. If a summary with the same
            `name` already exists a unique identifier will be generated.
        value: The value for the summary.
    
A hook that lets you define a summary in the current module. Its primary
use is to keep track of certain values as they flow through the network
so `Model.summary()` can show a representation of architecture.






A hook that lets you define a summary in the current module . Its primary use is to keep track of certain values as they flow through the network so ` Model . summary () ` can show a representation of architecture .
def add_summary(name: tp.Optional[str], value: np.ndarray) -> None:
    if LOCAL.contexts:
        context: Context = LOCAL.contexts[-1]
        module = context.module_c[-1]
        if not context.get_summaries:
            return
        base_name = "/".join(context.path_names_c)
        base_name = f"{base_name}/{name}" if name is not None else base_name
        base_name = get_unique_name(context.summaries, base_name)
        module = module if name is None else None  
        context.summaries.append((module, base_name, value))
    else:
        raise ValueError("Cannot execute `add_summary` outside of an `elegy.context`")
def add_summary ( name : tp . Optional [ str ] , value : np . ndarray ) -> None : if LOCAL . contexts : context : Context = LOCAL . contexts [ - 1 ] module = context . module_c [ - 1 ] if not context . get_summaries : return base_name = "/" . join ( context . path_names_c ) base_name = f"{base_name}/{name}" if name is not None else base_name base_name = get_unique_name ( context . summaries , base_name ) module = module if name is None else None context . summaries . append ( ( module , base_name , value ) ) else : raise ValueError ( "Cannot execute `add_summary` outside of an `elegy.context`" )
A hook that lets you define a summary in the current module.
A hook that lets you define a summary in the current module .
"""
    A hook that lets you define a summary in the current module. Its primary
    use is to keep track of certain values as they flow through the network
    so `Model.summary()` can show a representation of architecture.

    ```python
    def call(self, x):
        ...
        y = jax.nn.relu(x)
        elegy.add_summary("relu", y)
        ...
    ```

    The summaries will be aggregated by [`apply`][elegy.module.Module.apply]
    if `get_summaries` is set to `True`, else this hook does nothing.

    ```python
    transformed_state = transform.apply(..., get_summaries=True, ...)
    ```

    Arguments:
        name: The name of the loss. If a summary with the same
            `name` already exists a unique identifier will be generated.
        value: The value for the summary.
    """ # name = level_names[module] # pass module only if name is None
name
tp.Optional[str]
The name of the loss. If a summary with the same
`name` already exists a unique identifier will be generated.
The name of the loss . If a summary with the same ` name ` already exists a unique identifier will be generated .
value
np.ndarray
The value for the summary.
The value for the summary .