<commit_before>from __future__ import division

import numpy

from chainer.training import extension


class PolynomialShift(extension.Extension):

    """Trainer extension to polynomially shift an optimizer attribute.

    This extension polynomially decreases the specified attribute of the
    optimizer. The typical use case is a polynomial decay of the
    learning rate at each iteration.

    For example, suppose that this extension is invoke at every iteration.
    Then this extension will set the corresponding attribute to
    ``init_value * (1 - i / max_iter) ^ rate`` at the ``i``-th iteration, where
    the ``max_iter`` is the number of iterations to be running.

    This extension is also called before the training loop starts by default.

    Args:
        attr (str): Name of the attribute to shift.
        (rate, max_count) (float, int): ``rate`` is the the exponent of
            polynomial shift. ``max_count`` is the number of this extension to
            be invoked.
        init (float): Initial value of the attribute. If it is ``None``, the
            extension extracts the attribute at the first call and uses it as
            the initial value.
        target (float): Target value of the attribute. If the attribute reaches
            this value, the shift stops.
        optimizer (~chainer.Optimizer): Target optimizer to adjust the
            attribute. If it is ``None``, the main optimizer of the updater is
            used.

    """
    invoke_before_training = True

    def __init__(self, attr, rate, max_count, init=None, target=None,
                 optimizer=None):
        self._attr = attr
        self._rate = rate
        self._init = init
        self._target = target
        self._optimizer = optimizer<commit_msg>fix docs<commit_after>from __future__ import division

import numpy

from chainer.training import extension


class PolynomialShift(extension.Extension):

    """Trainer extension to polynomially shift an optimizer attribute.

    This extension polynomially decreases the specified attribute of the
    optimizer. The typical use case is a polynomial decay of the
    learning rate at each iteration.

    For example, suppose that this extension is invoke at every iteration.
    Then this extension will set the corresponding attribute to
    ``init_value * (1 - i / max_iter) ^ rate`` at the ``i``-th iteration, where
    the ``max_iter`` is the number of iterations to be running.

    This extension is also called before the training loop starts by default.

    Args:
        attr (str): Name of the attribute to shift.
        rate (float): Exponent of polynomial shift.
        max_count (int): Number of this extension to be invoked.
        init (float): Initial value of the attribute. If it is ``None``, the
            extension extracts the attribute at the first call and uses it as
            the initial value.
        target (float): Target value of the attribute. If the attribute reaches
            this value, the shift stops.
        optimizer (~chainer.Optimizer): Target optimizer to adjust the
            attribute. If it is ``None``, the main optimizer of the updater is
            used.

    """
    invoke_before_training = True

    def __init__(self, attr, rate, max_count, init=None, target=None,
                 optimizer=None):
        self._attr = attr
        self._rate = rate
        self._init = init
        self._target = target
        self._optimizer = optimizer
{'fraction_non_alphanumeric': 0.06284074605451936, 'fraction_numerical': 0.0005738880918220947, 'mean_word_length': 2.627471383975026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6532754', 'n_tokens_mistral': 859, 'n_tokens_neox': 837, 'n_words': 415}