Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
steps_annealing = int(steps * finetune_fraction)
steps_up = (steps - steps_annealing) // 2
steps_down = steps - steps_annealing - steps_up
return [
Phase(
lr=linspace(lr[0], lr[1], steps_up),
momentum=linspace(momentum[0], momentum[1], steps_up),
),
Phase(
lr=linspace(lr[1], lr[0], steps_down),
momentum=linspace(momentum[1], momentum[0], steps_down),
),
Phase(
lr=linspace(lr[0], finetune_lr, steps_annealing),
momentum=linspace(momentum[0], momentum[0], steps_annealing),
),
`_
"""
steps_annealing = int(steps * finetune_fraction)
steps_up = (steps - steps_annealing) // 2
steps_down = steps - steps_annealing - steps_up
return [
Phase(
lr=linspace(lr[0], lr[1], steps_up),
momentum=linspace(momentum[0], momentum[1], steps_up),
),
Phase(
lr=linspace(lr[1], lr[0], steps_down),
momentum=linspace(momentum[1], momentum[0], steps_down),
),
Phase(
lr=linspace(lr[0], finetune_lr, steps_annealing),
momentum=linspace(momentum[0], momentum[0], steps_annealing),
),
finetune_fraction (float): fraction of steps used for the fine tuning.
Must be between 0 and 1.
Returns:
A list of configured :class:`~poutyne.framework.callbacks.policies.Phase` instances.
References:
`Super-Convergence: Very Fast Training of Neural Networks Using Large Learning Rates
`_
"""
steps_annealing = int(steps * finetune_fraction)
steps_up = (steps - steps_annealing) // 2
steps_down = steps - steps_annealing - steps_up
return [
Phase(
lr=linspace(lr[0], lr[1], steps_up),
momentum=linspace(momentum[0], momentum[1], steps_up),
),
Phase(
lr=linspace(lr[1], lr[0], steps_down),
momentum=linspace(momentum[1], momentum[0], steps_down),
),
Phase(
lr=linspace(lr[0], finetune_lr, steps_annealing),
momentum=linspace(momentum[0], momentum[0], steps_annealing),
),
References:
`Super-Convergence: Very Fast Training of Neural Networks Using Large Learning Rates
`_
"""
steps_annealing = int(steps * finetune_fraction)
steps_up = (steps - steps_annealing) // 2
steps_down = steps - steps_annealing - steps_up
return [
Phase(
lr=linspace(lr[0], lr[1], steps_up),
momentum=linspace(momentum[0], momentum[1], steps_up),
),
Phase(
lr=linspace(lr[1], lr[0], steps_down),
momentum=linspace(momentum[1], momentum[0], steps_down),
),
Phase(
lr=linspace(lr[0], finetune_lr, steps_annealing),
momentum=linspace(momentum[0], momentum[0], steps_annealing),
),
def test_linspace_const(self):
self.assert_space(linspace(0, 0, 3), [0, 0, 0])
def test_linspace_decreasing(self):
self.assert_space(linspace(1, 0, 3), [1, .5, 0])