
    h                     |   S r SSKJr  SSKrSSKJr  \R                  " S5      S\S\S	\\   S
\\   4S j5       r	\R                  " S5      S\S
\\   4S j5       r
\R                  " S5      SS.S\S\S\S
\\   4S jj5       r\R                  " S5      SS.S\S\S\S\S
\\   4
S jj5       rS\S\S\S
\4S jr\R                  " S5      SSSSS .S!\S"\S#\S$\S\S\S
\\   4S% jj5       r\R                  " S&5      S'\S(\S)\S
\\   4S* j5       r\R                  " S+5      S,\S-\S.\S
\\   4S/ j5       r/ S0Qrg)1zEGenerators that provide different rates, schedules, decays or series.    )IterableN   )registryzconstant_then.v1ratestepsschedulereturnc              #   R   #    [        U5       H  nU v   M	     U H  nUv   M	     g7f)z>Yield a constant rate for N steps, before starting a schedule.N)range)r   r   r   ivalues        I/home/james-whalen/.local/lib/python3.13/site-packages/thinc/schedules.pyconstant_thenr   	   s)     
 5\
  s   %'zconstant.v1c              #      #     U v   M  7f)zYield a constant rate. )r   s    r   constantr      s      
 s   
zdecaying.v1)t	base_ratedecayr   c             #   8   #     U SSX-  -   -  -  v   US-  nM  7f)zYield an infinite series of linearly decaying values,
following the schedule: base_rate * 1 / (1 + decay * t)

EXAMPLE:
    >>> learn_rates = decaying(0.001, 1e-4)
    >>> next(learn_rates)
    0.001
    >>> next(learn_rates)
    0.00999
      ?r   r   )r   r   r   s      r   decayingr      s.      3#	/233	Q s   zcompounding.v1        startstopcompoundc             #   J   #    [        U 5      n [        X@U5      v   XB-  nM  7f)aD  Yield 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.0, 10.0, 1.5)
    >>> assert next(sizes) == 1.
    >>> assert next(sizes) == 1 * 1.5
    >>> assert next(sizes) == 1.5 * 1.5
)float_clip)r   r   r   r   currs        r   compoundingr!   ,   s-      <D
D&& s   !#r   c                 8    X:  a  [        X5      $ [        X5      $ )N)maxmin)r   r   r   s      r   r   r   @   s     %3uC3u3CC    zslanted_triangular.v1g?    r   )cut_fracratior   r   max_rate	num_stepsr'   r(   c             #      #    [        X-  5      n US-  nXV:  a  XV-  nOSXV-
  USU-  S-
  -  -  -
  nU SXsS-
  -  -   -  SU-  -  nUv   M;  7f)zpYield an infinite series of values according to Howard and Ruder's
"slanted triangular learning rate" schedule.
r   )int)	r)   r*   r'   r(   r   r   cutp
learn_rates	            r   slanted_triangularr0   D   st      i"
#C
	Q7Aag#X)9":;<AQ!)_!45UC
 s   A
Azwarmup_linear.v1initial_ratewarmup_stepstotal_stepsc           	   #      #    Sn X1:  a  U[        SU5      -  nO[        SX#-
  [        SX!-
  5      -  5      nX@-  v   US-  nM?  7f)zGenerate a series, starting from an initial rate, and then with a warmup
period, and then a linear decline. Used for learning rates.
r   r   r   r   )r#   )r1   r2   r3   stepfactors        r   warmup_linearr7   \   s`      D
C<00Fk(C[5O,PPF ##	 s   AAzcyclic_triangular.v1min_lrmax_lrperiodc              #      #    Sn [         R                  " SUSU-  -  -   5      n[         R                  " X2-  SU-  -
  S-   5      n[        SSU-
  5      nXU -
  U-  -   v   US-  nMb  7f)Nr      r   )numpyfloorabsr#   )r8   r9   r:   itcyclexrelatives          r   cyclic_triangularrD   o   sv     	
B
Aa&j 112IIbkAI-12q!a%=8333
a s   A&A()rD   r7   r   r   r   r7   r0   r!   )__doc__typingr   r=   configr   	schedulesr   r,   r   r   r   r!   r   r0   r7   rD   __all__r   r%   r   <module>rJ      s@   K    
&'
'/e_ ( 
M"5 Xe_  # 
M"9:  e 3 x  #  
$%>A).6;e_ &&D Du DE De D 
+,
  	
    e_ -. 
&''*9<e_ ($ 
*+e U C HUO  ,	r%   