Skip to content

treex.Filters

Source code in treex/treex.py
class Filters:
    def parameters(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.Parameter TreeParts, alias for `filter(tx.Parameter)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.Parameter, *filters)

    def trainable_parameters(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.Parameter TreeParts which are not frozen, alias for
        `filter(tx.Parameter, lambda field: not field.module.frozen)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return self.parameters(lambda field: not field.module.frozen, *filters)

    def batch_stats(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.BatchStat TreeParts, alias for `filter(tx.BatchStat)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.BatchStat, *filters)

    def rngs(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.Rng TreeParts, alias for `filter(tx.Rng)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.Rng, *filters)

    def model_states(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.ModelState TreeParts, alias for `filter(tx.ModelState)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.ModelState, *filters)

    def states(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.State TreeParts, alias for `filter(tx.State)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.State, *filters)

    def metric_logs(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.Metric TreeParts, alias for `filter(tx.Metric)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.MetricLog, *filters)

    def loss_logs(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.Loss TreeParts, alias for `filter(tx.Loss)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.LossLog, *filters)

    def logs(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.Log TreeParts, alias for `filter(tx.Log)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.Log, *filters)

    def caches(self: A, *filters: types.Filter) -> A:
        """
        Returns a copy of the Module with only tx.Cache TreeParts, alias for `filter(tx.Cache)`.

        Arguments:
            filters: additional filters passed to `filter`.
        """
        return to.filter(self, types.Cache, *filters)

batch_stats(self, *filters)

Returns a copy of the Module with only tx.BatchStat TreeParts, alias for filter(tx.BatchStat).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def batch_stats(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.BatchStat TreeParts, alias for `filter(tx.BatchStat)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.BatchStat, *filters)

caches(self, *filters)

Returns a copy of the Module with only tx.Cache TreeParts, alias for filter(tx.Cache).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def caches(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.Cache TreeParts, alias for `filter(tx.Cache)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.Cache, *filters)

logs(self, *filters)

Returns a copy of the Module with only tx.Log TreeParts, alias for filter(tx.Log).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def logs(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.Log TreeParts, alias for `filter(tx.Log)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.Log, *filters)

loss_logs(self, *filters)

Returns a copy of the Module with only tx.Loss TreeParts, alias for filter(tx.Loss).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def loss_logs(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.Loss TreeParts, alias for `filter(tx.Loss)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.LossLog, *filters)

metric_logs(self, *filters)

Returns a copy of the Module with only tx.Metric TreeParts, alias for filter(tx.Metric).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def metric_logs(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.Metric TreeParts, alias for `filter(tx.Metric)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.MetricLog, *filters)

model_states(self, *filters)

Returns a copy of the Module with only tx.ModelState TreeParts, alias for filter(tx.ModelState).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def model_states(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.ModelState TreeParts, alias for `filter(tx.ModelState)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.ModelState, *filters)

parameters(self, *filters)

Returns a copy of the Module with only tx.Parameter TreeParts, alias for filter(tx.Parameter).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def parameters(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.Parameter TreeParts, alias for `filter(tx.Parameter)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.Parameter, *filters)

rngs(self, *filters)

Returns a copy of the Module with only tx.Rng TreeParts, alias for filter(tx.Rng).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def rngs(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.Rng TreeParts, alias for `filter(tx.Rng)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.Rng, *filters)

states(self, *filters)

Returns a copy of the Module with only tx.State TreeParts, alias for filter(tx.State).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def states(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.State TreeParts, alias for `filter(tx.State)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return to.filter(self, types.State, *filters)

trainable_parameters(self, *filters)

Returns a copy of the Module with only tx.Parameter TreeParts which are not frozen, alias for filter(tx.Parameter, lambda field: not field.module.frozen).

Parameters:

Name Type Description Default
filters Union[Type[Type[Any]], Callable[[treeo.tree.FieldInfo], bool]]

additional filters passed to filter.

()
Source code in treex/treex.py
def trainable_parameters(self: A, *filters: types.Filter) -> A:
    """
    Returns a copy of the Module with only tx.Parameter TreeParts which are not frozen, alias for
    `filter(tx.Parameter, lambda field: not field.module.frozen)`.

    Arguments:
        filters: additional filters passed to `filter`.
    """
    return self.parameters(lambda field: not field.module.frozen, *filters)