B eð]Dã@sHdZddlmZmZddd„Zddd„Zdd „Zdd d „Zddd„ZdS)zEGenerators that provide different rates, schedules, decays or series.é)Úunicode_literalsÚdivisionccs(x"|dd||V|d7}qWdS)aYield an infinite series of linearly decaying values, following the schedule: base_rate * 1/(1+decay*t) Example: >>> learn_rates = linear_decay(0.001, 1e-4) >>> next(learn_rates) 0.001 >>> next(learn_rates) 0.00999 gð?éN©)Z base_rateÚdecayÚtrrú./tmp/pip-install-b8evvk6i/thinc/thinc/rates.pyÚdecayingsr çccs(t|ƒ}xt|||ƒV||9}q WdS)aZYield an infinite series of compounding values. Each time the generator is called, a value is produced by multiplying the previous value by the compound rate. EXAMPLE: >>> sizes = compounding(1., 10., 1.5) >>> assert next(sizes) == 1. >>> assert next(sizes) == 1 * 1.5 >>> assert next(sizes) == 1.5 * 1.5 N)ÚfloatÚ_clip)ÚstartÚstopÚcompoundrÚcurrrrrÚ compoundings rcCs||krt||ƒSt||ƒS)N)ÚmaxÚmin)Úvaluer rrrrr +sr ccs4x.|dkr|Vq||||V|d7}qWdS)Ngrr)ZraterZ decay_stepsrrrrÚ annealing/s rçš™™™™™¹?é rc csnt||ƒ}x\|d7}||kr(||}nd|||d|d}|d||dd|}|VqWdS)zxYield an infinite series of values according to Howard and Ruder's "slanted triangular learning rate" schedule. rN)Úint) Zmax_rateZ num_stepsZcut_fracZratiorrZcutÚpZ learn_raterrrÚslanted_triangular8s  rN)r)r )r )rrrr ) Ú__doc__Ú __future__rrr rr rrrrrrÚs