import{s as da,A as Ot,o as ha,n as Yt}from"../chunks/scheduler.01eeda35.js";import{S as ua,i as _a,g as l,s as a,r as d,A as ga,h as m,f as t,c as n,j as z,u as h,x as w,k as y,y as s,a as i,v as u,d as _,t as g,w as f}from"../chunks/index.6dd51b66.js";import{D as M}from"../chunks/Docstring.76e6b3cf.js";import{C as Qt}from"../chunks/CodeBlock.864da1b0.js";import{E as Xt}from"../chunks/ExampleCodeBlock.6a36fb6b.js";import{H as Y,E as fa}from"../chunks/EditOnGithub.7faefd25.js";function wa(R){let c,C="Example:",x,p,v;return p=new Qt({props:{code:"QWRhZmFjdG9yKG1vZGVsLnBhcmFtZXRlcnMoKSUyQyUyMHNjYWxlX3BhcmFtZXRlciUzREZhbHNlJTJDJTIwcmVsYXRpdmVfc3RlcCUzREZhbHNlJTJDJTIwd2FybXVwX2luaXQlM0RGYWxzZSUyQyUyMGxyJTNEMWUtMyk=",highlighted:'Adafactor(model.parameters(), scale_parameter=<span class="hljs-literal">False</span>, relative_step=<span class="hljs-literal">False</span>, warmup_init=<span class="hljs-literal">False</span>, lr=<span class="hljs-number">1e-3</span>)',wrap:!1}}),{c(){c=l("p"),c.textContent=C,x=a(),d(p.$$.fragment)},l(o){c=m(o,"P",{"data-svelte-h":!0}),w(c)!=="svelte-11lpom8"&&(c.textContent=C),x=n(o),h(p.$$.fragment,o)},m(o,T){i(o,c,T),i(o,x,T),u(p,o,T),v=!0},p:Yt,i(o){v||(_(p.$$.fragment,o),v=!0)},o(o){g(p.$$.fragment,o),v=!1},d(o){o&&(t(c),t(x)),f(p,o)}}}function ba(R){let c,C="Others reported the following combination to work well:",x,p,v;return p=new Qt({props:{code:"QWRhZmFjdG9yKG1vZGVsLnBhcmFtZXRlcnMoKSUyQyUyMHNjYWxlX3BhcmFtZXRlciUzRFRydWUlMkMlMjByZWxhdGl2ZV9zdGVwJTNEVHJ1ZSUyQyUyMHdhcm11cF9pbml0JTNEVHJ1ZSUyQyUyMGxyJTNETm9uZSk=",highlighted:'Adafactor(model.parameters(), scale_parameter=<span class="hljs-literal">True</span>, relative_step=<span class="hljs-literal">True</span>, warmup_init=<span class="hljs-literal">True</span>, lr=<span class="hljs-literal">None</span>)',wrap:!1}}),{c(){c=l("p"),c.textContent=C,x=a(),d(p.$$.fragment)},l(o){c=m(o,"P",{"data-svelte-h":!0}),w(c)!=="svelte-mxeef1"&&(c.textContent=C),x=n(o),h(p.$$.fragment,o)},m(o,T){i(o,c,T),i(o,x,T),u(p,o,T),v=!0},p:Yt,i(o){v||(_(p.$$.fragment,o),v=!0)},o(o){g(p.$$.fragment,o),v=!1},d(o){o&&(t(c),t(x)),f(p,o)}}}function ya(R){let c,C="scheduler as following:",x,p,v;return p=new Qt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5vcHRpbWl6YXRpb24lMjBpbXBvcnQlMjBBZGFmYWN0b3IlMkMlMjBBZGFmYWN0b3JTY2hlZHVsZSUwQSUwQW9wdGltaXplciUyMCUzRCUyMEFkYWZhY3Rvcihtb2RlbC5wYXJhbWV0ZXJzKCklMkMlMjBzY2FsZV9wYXJhbWV0ZXIlM0RUcnVlJTJDJTIwcmVsYXRpdmVfc3RlcCUzRFRydWUlMkMlMjB3YXJtdXBfaW5pdCUzRFRydWUlMkMlMjBsciUzRE5vbmUpJTBBbHJfc2NoZWR1bGVyJTIwJTNEJTIwQWRhZmFjdG9yU2NoZWR1bGUob3B0aW1pemVyKSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKC4uLiUyQyUyMG9wdGltaXplcnMlM0Qob3B0aW1pemVyJTJDJTIwbHJfc2NoZWR1bGVyKSk=",highlighted:`<span class="hljs-keyword">from</span> transformers.optimization <span class="hljs-keyword">import</span> Adafactor, AdafactorSchedule

optimizer = Adafactor(model.parameters(), scale_parameter=<span class="hljs-literal">True</span>, relative_step=<span class="hljs-literal">True</span>, warmup_init=<span class="hljs-literal">True</span>, lr=<span class="hljs-literal">None</span>)
lr_scheduler = AdafactorSchedule(optimizer)
trainer = Trainer(..., optimizers=(optimizer, lr_scheduler))`,wrap:!1}}),{c(){c=l("p"),c.textContent=C,x=a(),d(p.$$.fragment)},l(o){c=m(o,"P",{"data-svelte-h":!0}),w(c)!=="svelte-1eua222"&&(c.textContent=C),x=n(o),h(p.$$.fragment,o)},m(o,T){i(o,c,T),i(o,x,T),u(p,o,T),v=!0},p:Yt,i(o){v||(_(p.$$.fragment,o),v=!0)},o(o){g(p.$$.fragment,o),v=!1},d(o){o&&(t(c),t(x)),f(p,o)}}}function va(R){let c,C="Usage:",x,p,v;return p=new Qt({props:{code:"JTIzJTIwcmVwbGFjZSUyMEFkYW1XJTIwd2l0aCUyMEFkYWZhY3RvciUwQW9wdGltaXplciUyMCUzRCUyMEFkYWZhY3RvciglMEElMjAlMjAlMjAlMjBtb2RlbC5wYXJhbWV0ZXJzKCklMkMlMEElMjAlMjAlMjAlMjBsciUzRDFlLTMlMkMlMEElMjAlMjAlMjAlMjBlcHMlM0QoMWUtMzAlMkMlMjAxZS0zKSUyQyUwQSUyMCUyMCUyMCUyMGNsaXBfdGhyZXNob2xkJTNEMS4wJTJDJTBBJTIwJTIwJTIwJTIwZGVjYXlfcmF0ZSUzRC0wLjglMkMlMEElMjAlMjAlMjAlMjBiZXRhMSUzRE5vbmUlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAlMkMlMEElMjAlMjAlMjAlMjByZWxhdGl2ZV9zdGVwJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBzY2FsZV9wYXJhbWV0ZXIlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHdhcm11cF9pbml0JTNERmFsc2UlMkMlMEEp",highlighted:`<span class="hljs-comment"># replace AdamW with Adafactor</span>
optimizer = Adafactor(
    model.parameters(),
    lr=<span class="hljs-number">1e-3</span>,
    eps=(<span class="hljs-number">1e-30</span>, <span class="hljs-number">1e-3</span>),
    clip_threshold=<span class="hljs-number">1.0</span>,
    decay_rate=-<span class="hljs-number">0.8</span>,
    beta1=<span class="hljs-literal">None</span>,
    weight_decay=<span class="hljs-number">0.0</span>,
    relative_step=<span class="hljs-literal">False</span>,
    scale_parameter=<span class="hljs-literal">False</span>,
    warmup_init=<span class="hljs-literal">False</span>,
)`,wrap:!1}}),{c(){c=l("p"),c.textContent=C,x=a(),d(p.$$.fragment)},l(o){c=m(o,"P",{"data-svelte-h":!0}),w(c)!=="svelte-5wyjqd"&&(c.textContent=C),x=n(o),h(p.$$.fragment,o)},m(o,T){i(o,c,T),i(o,x,T),u(p,o,T),v=!0},p:Yt,i(o){v||(_(p.$$.fragment,o),v=!0)},o(o){g(p.$$.fragment,o),v=!1},d(o){o&&(t(c),t(x)),f(p,o)}}}function $a(R){let c,C,x,p,v,o,T,Wr="The <code>.optimization</code> module provides:",mt,Q,Rr="<li>an optimizer with weight decay fixed that can be used to fine-tuned models, and</li> <li>several schedules in the form of schedule objects that inherit from <code>_LRSchedule</code>:</li> <li>a gradient accumulation class to accumulate the gradients of multiple batches</li>",ct,K,pt,b,ee,Kt,Ue,Er=`AdaFactor pytorch implementation can be used as a drop in replacement for Adam original fairseq code:
<a href="https://github.com/pytorch/fairseq/blob/master/fairseq/optim/adafactor.py" rel="nofollow">https://github.com/pytorch/fairseq/blob/master/fairseq/optim/adafactor.py</a>`,er,De,kr=`Paper: <em>Adafactor: Adaptive Learning Rates with Sublinear Memory Cost</em> <a href="https://arxiv.org/abs/1804.04235" rel="nofollow">https://arxiv.org/abs/1804.04235</a> Note that
this optimizer internally adjusts the learning rate depending on the <code>scale_parameter</code>, <code>relative_step</code> and
<code>warmup_init</code> options. To use a manual (external) learning rate schedule you should set <code>scale_parameter=False</code> and
<code>relative_step=False</code>.`,tr,We,Ir="This implementation handles low-precision (FP16, bfloat) values, but we have not thoroughly tested.",rr,Re,Fr='Recommended T5 finetuning settings (<a href="https://discuss.huggingface.co/t/t5-finetuning-tips/684/3" rel="nofollow">https://discuss.huggingface.co/t/t5-finetuning-tips/684/3</a>):',ar,Ee,Nr='<li><p>Training without LR warmup or clip_threshold is not recommended.</p> <ul><li>use scheduled LR warm-up to fixed LR</li> <li>use clip_threshold=1.0 (<a href="https://arxiv.org/abs/1804.04235" rel="nofollow">https://arxiv.org/abs/1804.04235</a>)</li></ul></li> <li><p>Disable relative updates</p></li> <li><p>Use scale_parameter=False</p></li> <li><p>Additional optimizer operations like gradient clipping should not be used alongside Adafactor</p></li>',nr,Z,sr,S,or,ke,Vr='When using <code>lr=None</code> with <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> you will most likely need to use <code>AdafactorSchedule</code>',ir,H,lr,q,mr,B,te,cr,Ie,Gr="Performs a single optimization step",dt,re,ht,A,ae,pr,Fe,Jr=`Adam enables L2 weight decay and clip_by_global_norm on gradients. Just adding the square of the weights to the
loss function is <em>not</em> the correct way of using L2 regularization/weight decay with Adam, since that will interact
with the m and v parameters in strange ways as shown in <a href="https://arxiv.org/abs/1711.05101" rel="nofollow">Decoupled Weight Decay
Regularization</a>.`,dr,Ne,Pr=`Instead we want to decay the weights in a manner that doesn’t interact with the m/v parameters. This is equivalent
to adding the square of the weights to the loss with plain (non-momentum) SGD.`,hr,O,ne,ur,Ve,Zr="Creates an optimizer from its config with WarmUp custom object.",ut,E,se,_r,Ge,Sr="Creates an optimizer with a learning rate schedule using a warmup phase followed by a linear decay.",_t,oe,gt,ie,ft,L,le,gr,Je,Hr=`Scheduler names for the parameter <code>lr_scheduler_type</code> in <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>.
By default, it uses “linear”. Internally, this retrieves <code>get_linear_schedule_with_warmup</code> scheduler from <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>.
Scheduler types:`,fr,Pe,qr="<li>“linear” = get_linear_schedule_with_warmup</li> <li>“cosine” = get_cosine_schedule_with_warmup</li> <li>“cosine_with_restarts” = get_cosine_with_hard_restarts_schedule_with_warmup</li> <li>“polynomial” = get_polynomial_decay_schedule_with_warmup</li> <li>“constant” =  get_constant_schedule</li> <li>“constant_with_warmup” = get_constant_schedule_with_warmup</li> <li>“inverse_sqrt” = get_inverse_sqrt_schedule</li> <li>“reduce_lr_on_plateau” = get_reduce_on_plateau_schedule</li> <li>“cosine_with_min_lr” = get_cosine_with_min_lr_schedule_with_warmup</li> <li>“warmup_stable_decay” = get_wsd_schedule</li>",wt,k,me,wr,Ze,Br="Unified API to get any scheduler from its name.",bt,I,ce,br,Se,Or="Create a schedule with a constant learning rate, using the learning rate set in optimizer.",yt,F,pe,yr,He,Xr=`Create a schedule with a constant learning rate preceded by a warmup period during which the learning rate
increases linearly between 0 and the initial lr set in the optimizer.`,vt,de,Yr,$t,N,he,vr,qe,Qr=`Create a schedule with a learning rate that decreases following the values of the cosine function between the
initial lr set in the optimizer to 0, after a warmup period during which it increases linearly between 0 and the
initial lr set in the optimizer.`,xt,ue,Kr,Tt,V,_e,$r,Be,ea=`Create a schedule with a learning rate that decreases following the values of the cosine function between the
initial lr set in the optimizer to 0, with several hard restarts, after a warmup period during which it increases
linearly between 0 and the initial lr set in the optimizer.`,zt,ge,ta,Mt,G,fe,xr,Oe,ra=`Create a schedule with a learning rate that decreases linearly from the initial lr set in the optimizer to 0, after
a warmup period during which it increases linearly from 0 to the initial lr set in the optimizer.`,Ct,we,aa,At,j,be,Tr,Xe,na=`Create a schedule with a learning rate that decreases as a polynomial decay from the initial lr set in the
optimizer to end lr defined by <em>lr_end</em>, after a warmup period during which it increases linearly from 0 to the
initial lr set in the optimizer.`,zr,Ye,sa=`Note: <em>power</em> defaults to 1.0 as in the fairseq implementation, which in turn is based on the original BERT
implementation at
<a href="https://github.com/google-research/bert/blob/f39e881b169b9d53bea03d2d341b31707a6c052b/optimization.py#L37" rel="nofollow">https://github.com/google-research/bert/blob/f39e881b169b9d53bea03d2d341b31707a6c052b/optimization.py#L37</a>`,Lt,J,ye,Mr,Qe,oa=`Create a schedule with an inverse square-root learning rate, from the initial lr set in the optimizer, after a
warmup period which increases lr linearly from 0 to the initial lr set in the optimizer.`,jt,U,ve,Cr,Ke,ia="Create a schedule with a learning rate that has three stages:",Ar,et,la="<li>warmup: increase from min_lr_ratio times the initial learning rate to the initial learning rate following a warmup_type.</li> <li>stable: constant learning rate.</li> <li>decay: decrease from the initial learning rate to min_lr_ratio times the initial learning rate following a decay_type.</li>",Ut,$e,Dt,P,xe,Lr,tt,ma="Applies a warmup schedule on a given learning rate decay schedule.",Wt,Te,Rt,ze,Et,D,Me,jr,rt,ca=`Gradient accumulation utility. When used with a distribution strategy, the accumulator should be called in a
replica context. Gradients will be accumulated locally on each replica and without synchronization. Users should
then call <code>.gradients</code>, scale the gradients if required, and pass the result to <code>apply_gradients</code>.`,Ur,X,Ce,Dr,at,pa="Resets the accumulated gradients on the current replica.",kt,Ae,It,lt,Ft;return v=new Y({props:{title:"Optimization",local:"optimization",headingTag:"h1"}}),K=new Y({props:{title:"AdaFactor (PyTorch)",local:"transformers.Adafactor",headingTag:"h2"}}),ee=new M({props:{name:"class transformers.Adafactor",anchor:"transformers.Adafactor",parameters:[{name:"params",val:""},{name:"lr",val:" = None"},{name:"eps",val:" = (1e-30, 0.001)"},{name:"clip_threshold",val:" = 1.0"},{name:"decay_rate",val:" = -0.8"},{name:"beta1",val:" = None"},{name:"weight_decay",val:" = 0.0"},{name:"scale_parameter",val:" = True"},{name:"relative_step",val:" = True"},{name:"warmup_init",val:" = False"}],parametersDescription:[{anchor:"transformers.Adafactor.params",description:`<strong>params</strong> (<code>Iterable[nn.parameter.Parameter]</code>) &#x2014;
Iterable of parameters to optimize or dictionaries defining parameter groups.`,name:"params"},{anchor:"transformers.Adafactor.lr",description:`<strong>lr</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The external learning rate.`,name:"lr"},{anchor:"transformers.Adafactor.eps",description:`<strong>eps</strong> (<code>Tuple[float, float]</code>, <em>optional</em>, defaults to <code>(1e-30, 0.001)</code>) &#x2014;
Regularization constants for square gradient and parameter scale respectively`,name:"eps"},{anchor:"transformers.Adafactor.clip_threshold",description:`<strong>clip_threshold</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Threshold of root mean square of final gradient update`,name:"clip_threshold"},{anchor:"transformers.Adafactor.decay_rate",description:`<strong>decay_rate</strong> (<code>float</code>, <em>optional</em>, defaults to -0.8) &#x2014;
Coefficient used to compute running averages of square`,name:"decay_rate"},{anchor:"transformers.Adafactor.beta1",description:`<strong>beta1</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Coefficient used for computing running averages of gradient`,name:"beta1"},{anchor:"transformers.Adafactor.weight_decay",description:`<strong>weight_decay</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Weight decay (L2 penalty)`,name:"weight_decay"},{anchor:"transformers.Adafactor.scale_parameter",description:`<strong>scale_parameter</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If True, learning rate is scaled by root mean square`,name:"scale_parameter"},{anchor:"transformers.Adafactor.relative_step",description:`<strong>relative_step</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If True, time-dependent learning rate is computed instead of external learning rate`,name:"relative_step"},{anchor:"transformers.Adafactor.warmup_init",description:`<strong>warmup_init</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Time-dependent learning rate computation depends on whether warm-up initialization is being used`,name:"warmup_init"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L605"}}),Z=new Xt({props:{anchor:"transformers.Adafactor.example",$$slots:{default:[wa]},$$scope:{ctx:R}}}),S=new Xt({props:{anchor:"transformers.Adafactor.example-2",$$slots:{default:[ba]},$$scope:{ctx:R}}}),H=new Xt({props:{anchor:"transformers.Adafactor.example-3",$$slots:{default:[ya]},$$scope:{ctx:R}}}),q=new Xt({props:{anchor:"transformers.Adafactor.example-4",$$slots:{default:[va]},$$scope:{ctx:R}}}),te=new M({props:{name:"step",anchor:"transformers.Adafactor.step",parameters:[{name:"closure",val:" = None"}],parametersDescription:[{anchor:"transformers.Adafactor.step.closure",description:`<strong>closure</strong> (callable, optional) &#x2014; A closure that reevaluates the model
and returns the loss.`,name:"closure"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L751"}}),re=new Y({props:{title:"AdamWeightDecay (TensorFlow)",local:"transformers.AdamWeightDecay",headingTag:"h2"}}),ae=new M({props:{name:"class transformers.AdamWeightDecay",anchor:"transformers.AdamWeightDecay",parameters:[{name:"learning_rate",val:": typing.Union[float, tf_keras.src.optimizers.schedules.learning_rate_schedule.LearningRateSchedule] = 0.001"},{name:"beta_1",val:": float = 0.9"},{name:"beta_2",val:": float = 0.999"},{name:"epsilon",val:": float = 1e-07"},{name:"amsgrad",val:": bool = False"},{name:"weight_decay_rate",val:": float = 0.0"},{name:"include_in_weight_decay",val:": typing.Optional[list[str]] = None"},{name:"exclude_from_weight_decay",val:": typing.Optional[list[str]] = None"},{name:"name",val:": str = 'AdamWeightDecay'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.AdamWeightDecay.learning_rate",description:`<strong>learning_rate</strong> (<code>Union[float, LearningRateSchedule]</code>, <em>optional</em>, defaults to 0.001) &#x2014;
The learning rate to use or a schedule.`,name:"learning_rate"},{anchor:"transformers.AdamWeightDecay.beta_1",description:`<strong>beta_1</strong> (<code>float</code>, <em>optional</em>, defaults to 0.9) &#x2014;
The beta1 parameter in Adam, which is the exponential decay rate for the 1st momentum estimates.`,name:"beta_1"},{anchor:"transformers.AdamWeightDecay.beta_2",description:`<strong>beta_2</strong> (<code>float</code>, <em>optional</em>, defaults to 0.999) &#x2014;
The beta2 parameter in Adam, which is the exponential decay rate for the 2nd momentum estimates.`,name:"beta_2"},{anchor:"transformers.AdamWeightDecay.epsilon",description:`<strong>epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-07) &#x2014;
The epsilon parameter in Adam, which is a small constant for numerical stability.`,name:"epsilon"},{anchor:"transformers.AdamWeightDecay.amsgrad",description:`<strong>amsgrad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to apply AMSGrad variant of this algorithm or not, see <a href="https://arxiv.org/abs/1904.09237" rel="nofollow">On the Convergence of Adam and
Beyond</a>.`,name:"amsgrad"},{anchor:"transformers.AdamWeightDecay.weight_decay_rate",description:`<strong>weight_decay_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The weight decay to apply.`,name:"weight_decay_rate"},{anchor:"transformers.AdamWeightDecay.include_in_weight_decay",description:`<strong>include_in_weight_decay</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
List of the parameter names (or re patterns) to apply weight decay to. If none is passed, weight decay is
applied to all parameters by default (unless they are in <code>exclude_from_weight_decay</code>).`,name:"include_in_weight_decay"},{anchor:"transformers.AdamWeightDecay.exclude_from_weight_decay",description:`<strong>exclude_from_weight_decay</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
List of the parameter names (or re patterns) to exclude from applying weight decay to. If a
<code>include_in_weight_decay</code> is passed, the names in it will supersede this list.`,name:"exclude_from_weight_decay"},{anchor:"transformers.AdamWeightDecay.name",description:`<strong>name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;AdamWeightDecay&quot;</code>) &#x2014;
Optional name for the operations created when applying gradients.`,name:"name"},{anchor:"transformers.AdamWeightDecay.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Keyword arguments. Allowed to be {<code>clipnorm</code>, <code>clipvalue</code>, <code>lr</code>, <code>decay</code>}. <code>clipnorm</code> is clip gradients by
norm; <code>clipvalue</code> is clip gradients by value, <code>decay</code> is included for backward compatibility to allow time
inverse decay of learning rate. <code>lr</code> is included for backward compatibility, recommended to use
<code>learning_rate</code> instead.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization_tf.py#L180"}}),ne=new M({props:{name:"from_config",anchor:"transformers.AdamWeightDecay.from_config",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization_tf.py#L237"}}),se=new M({props:{name:"transformers.create_optimizer",anchor:"transformers.create_optimizer",parameters:[{name:"init_lr",val:": float"},{name:"num_train_steps",val:": int"},{name:"num_warmup_steps",val:": int"},{name:"min_lr_ratio",val:": float = 0.0"},{name:"adam_beta1",val:": float = 0.9"},{name:"adam_beta2",val:": float = 0.999"},{name:"adam_epsilon",val:": float = 1e-08"},{name:"adam_clipnorm",val:": typing.Optional[float] = None"},{name:"adam_global_clipnorm",val:": typing.Optional[float] = None"},{name:"weight_decay_rate",val:": float = 0.0"},{name:"power",val:": float = 1.0"},{name:"include_in_weight_decay",val:": typing.Optional[list[str]] = None"}],parametersDescription:[{anchor:"transformers.create_optimizer.init_lr",description:`<strong>init_lr</strong> (<code>float</code>) &#x2014;
The desired learning rate at the end of the warmup phase.`,name:"init_lr"},{anchor:"transformers.create_optimizer.num_train_steps",description:`<strong>num_train_steps</strong> (<code>int</code>) &#x2014;
The total number of training steps.`,name:"num_train_steps"},{anchor:"transformers.create_optimizer.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of warmup steps.`,name:"num_warmup_steps"},{anchor:"transformers.create_optimizer.min_lr_ratio",description:`<strong>min_lr_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The final learning rate at the end of the linear decay will be <code>init_lr * min_lr_ratio</code>.`,name:"min_lr_ratio"},{anchor:"transformers.create_optimizer.adam_beta1",description:`<strong>adam_beta1</strong> (<code>float</code>, <em>optional</em>, defaults to 0.9) &#x2014;
The beta1 to use in Adam.`,name:"adam_beta1"},{anchor:"transformers.create_optimizer.adam_beta2",description:`<strong>adam_beta2</strong> (<code>float</code>, <em>optional</em>, defaults to 0.999) &#x2014;
The beta2 to use in Adam.`,name:"adam_beta2"},{anchor:"transformers.create_optimizer.adam_epsilon",description:`<strong>adam_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-8) &#x2014;
The epsilon to use in Adam.`,name:"adam_epsilon"},{anchor:"transformers.create_optimizer.adam_clipnorm",description:`<strong>adam_clipnorm</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
If not <code>None</code>, clip the gradient norm for each weight tensor to this value.`,name:"adam_clipnorm"},{anchor:"transformers.create_optimizer.adam_global_clipnorm",description:`<strong>adam_global_clipnorm</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
If not <code>None</code>, clip gradient norm to this value. When using this argument, the norm is computed over all
weight tensors, as if they were concatenated into a single vector.`,name:"adam_global_clipnorm"},{anchor:"transformers.create_optimizer.weight_decay_rate",description:`<strong>weight_decay_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The weight decay to use.`,name:"weight_decay_rate"},{anchor:"transformers.create_optimizer.power",description:`<strong>power</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
The power to use for PolynomialDecay.`,name:"power"},{anchor:"transformers.create_optimizer.include_in_weight_decay",description:`<strong>include_in_weight_decay</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
List of the parameter names (or re patterns) to apply weight decay to. If none is passed, weight decay is
applied to all parameters except bias and layer norm parameters.`,name:"include_in_weight_decay"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization_tf.py#L96"}}),oe=new Y({props:{title:"Schedules",local:"schedules",headingTag:"h2"}}),ie=new Y({props:{title:"Learning Rate Schedules (PyTorch)",local:"transformers.SchedulerType",headingTag:"h3"}}),le=new M({props:{name:"class transformers.SchedulerType",anchor:"transformers.SchedulerType",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/trainer_utils.py#L420"}}),me=new M({props:{name:"transformers.get_scheduler",anchor:"transformers.get_scheduler",parameters:[{name:"name",val:": typing.Union[str, transformers.trainer_utils.SchedulerType]"},{name:"optimizer",val:": Optimizer"},{name:"num_warmup_steps",val:": typing.Optional[int] = None"},{name:"num_training_steps",val:": typing.Optional[int] = None"},{name:"scheduler_specific_kwargs",val:": typing.Optional[dict] = None"}],parametersDescription:[{anchor:"transformers.get_scheduler.name",description:`<strong>name</strong> (<code>str</code> or <code>SchedulerType</code>) &#x2014;
The name of the scheduler to use.`,name:"name"},{anchor:"transformers.get_scheduler.optimizer",description:`<strong>optimizer</strong> (<code>torch.optim.Optimizer</code>) &#x2014;
The optimizer that will be used during training.`,name:"optimizer"},{anchor:"transformers.get_scheduler.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of warmup steps to do. This is not required by all schedulers (hence the argument being
optional), the function will raise an error if it&#x2019;s unset and the scheduler type requires it.`,name:"num_warmup_steps"},{anchor:"transformers.get_scheduler.num_training_steps",description:`<strong>num_training_steps</strong> (\`int&#x201C;, <em>optional</em>) &#x2014;
The number of training steps to do. This is not required by all schedulers (hence the argument being
optional), the function will raise an error if it&#x2019;s unset and the scheduler type requires it.`,name:"num_training_steps"},{anchor:"transformers.get_scheduler.scheduler_specific_kwargs",description:`<strong>scheduler_specific_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Extra parameters for schedulers such as cosine with restarts. Mismatched scheduler types and scheduler
parameters will cause the scheduler function to raise a TypeError.`,name:"scheduler_specific_kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L513"}}),ce=new M({props:{name:"transformers.get_constant_schedule",anchor:"transformers.get_constant_schedule",parameters:[{name:"optimizer",val:": Optimizer"},{name:"last_epoch",val:": int = -1"}],parametersDescription:[{anchor:"transformers.get_constant_schedule.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_constant_schedule.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L38",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),pe=new M({props:{name:"transformers.get_constant_schedule_with_warmup",anchor:"transformers.get_constant_schedule_with_warmup",parameters:[{name:"optimizer",val:": Optimizer"},{name:"num_warmup_steps",val:": int"},{name:"last_epoch",val:": int = -1"}],parametersDescription:[{anchor:"transformers.get_constant_schedule_with_warmup.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_constant_schedule_with_warmup.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup phase.`,name:"num_warmup_steps"},{anchor:"transformers.get_constant_schedule_with_warmup.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L79",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),he=new M({props:{name:"transformers.get_cosine_schedule_with_warmup",anchor:"transformers.get_cosine_schedule_with_warmup",parameters:[{name:"optimizer",val:": Optimizer"},{name:"num_warmup_steps",val:": int"},{name:"num_training_steps",val:": int"},{name:"num_cycles",val:": float = 0.5"},{name:"last_epoch",val:": int = -1"}],parametersDescription:[{anchor:"transformers.get_cosine_schedule_with_warmup.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_cosine_schedule_with_warmup.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup phase.`,name:"num_warmup_steps"},{anchor:"transformers.get_cosine_schedule_with_warmup.num_training_steps",description:`<strong>num_training_steps</strong> (<code>int</code>) &#x2014;
The total number of training steps.`,name:"num_training_steps"},{anchor:"transformers.get_cosine_schedule_with_warmup.num_cycles",description:`<strong>num_cycles</strong> (<code>float</code>, <em>optional</em>, defaults to 0.5) &#x2014;
The number of waves in the cosine schedule (the defaults is to just decrease from the max value to 0
following a half-cosine).`,name:"num_cycles"},{anchor:"transformers.get_cosine_schedule_with_warmup.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L142",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),_e=new M({props:{name:"transformers.get_cosine_with_hard_restarts_schedule_with_warmup",anchor:"transformers.get_cosine_with_hard_restarts_schedule_with_warmup",parameters:[{name:"optimizer",val:": Optimizer"},{name:"num_warmup_steps",val:": int"},{name:"num_training_steps",val:": int"},{name:"num_cycles",val:": int = 1"},{name:"last_epoch",val:": int = -1"}],parametersDescription:[{anchor:"transformers.get_cosine_with_hard_restarts_schedule_with_warmup.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_cosine_with_hard_restarts_schedule_with_warmup.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup phase.`,name:"num_warmup_steps"},{anchor:"transformers.get_cosine_with_hard_restarts_schedule_with_warmup.num_training_steps",description:`<strong>num_training_steps</strong> (<code>int</code>) &#x2014;
The total number of training steps.`,name:"num_training_steps"},{anchor:"transformers.get_cosine_with_hard_restarts_schedule_with_warmup.num_cycles",description:`<strong>num_cycles</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of hard restarts to use.`,name:"num_cycles"},{anchor:"transformers.get_cosine_with_hard_restarts_schedule_with_warmup.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L187",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),fe=new M({props:{name:"transformers.get_linear_schedule_with_warmup",anchor:"transformers.get_linear_schedule_with_warmup",parameters:[{name:"optimizer",val:""},{name:"num_warmup_steps",val:""},{name:"num_training_steps",val:""},{name:"last_epoch",val:" = -1"}],parametersDescription:[{anchor:"transformers.get_linear_schedule_with_warmup.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_linear_schedule_with_warmup.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup phase.`,name:"num_warmup_steps"},{anchor:"transformers.get_linear_schedule_with_warmup.num_training_steps",description:`<strong>num_training_steps</strong> (<code>int</code>) &#x2014;
The total number of training steps.`,name:"num_training_steps"},{anchor:"transformers.get_linear_schedule_with_warmup.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L106",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),be=new M({props:{name:"transformers.get_polynomial_decay_schedule_with_warmup",anchor:"transformers.get_polynomial_decay_schedule_with_warmup",parameters:[{name:"optimizer",val:""},{name:"num_warmup_steps",val:""},{name:"num_training_steps",val:""},{name:"lr_end",val:" = 1e-07"},{name:"power",val:" = 1.0"},{name:"last_epoch",val:" = -1"}],parametersDescription:[{anchor:"transformers.get_polynomial_decay_schedule_with_warmup.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_polynomial_decay_schedule_with_warmup.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup phase.`,name:"num_warmup_steps"},{anchor:"transformers.get_polynomial_decay_schedule_with_warmup.num_training_steps",description:`<strong>num_training_steps</strong> (<code>int</code>) &#x2014;
The total number of training steps.`,name:"num_training_steps"},{anchor:"transformers.get_polynomial_decay_schedule_with_warmup.lr_end",description:`<strong>lr_end</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-7) &#x2014;
The end LR.`,name:"lr_end"},{anchor:"transformers.get_polynomial_decay_schedule_with_warmup.power",description:`<strong>power</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Power factor.`,name:"power"},{anchor:"transformers.get_polynomial_decay_schedule_with_warmup.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L241",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),ye=new M({props:{name:"transformers.get_inverse_sqrt_schedule",anchor:"transformers.get_inverse_sqrt_schedule",parameters:[{name:"optimizer",val:": Optimizer"},{name:"num_warmup_steps",val:": int"},{name:"timescale",val:": int = None"},{name:"last_epoch",val:": int = -1"}],parametersDescription:[{anchor:"transformers.get_inverse_sqrt_schedule.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_inverse_sqrt_schedule.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup phase.`,name:"num_warmup_steps"},{anchor:"transformers.get_inverse_sqrt_schedule.timescale",description:`<strong>timescale</strong> (<code>int</code>, <em>optional</em>, defaults to <code>num_warmup_steps</code>) &#x2014;
Time scale.`,name:"timescale"},{anchor:"transformers.get_inverse_sqrt_schedule.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L295",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),ve=new M({props:{name:"transformers.get_wsd_schedule",anchor:"transformers.get_wsd_schedule",parameters:[{name:"optimizer",val:": Optimizer"},{name:"num_warmup_steps",val:": int"},{name:"num_decay_steps",val:": int"},{name:"num_training_steps",val:": typing.Optional[int] = None"},{name:"num_stable_steps",val:": typing.Optional[int] = None"},{name:"warmup_type",val:": str = 'linear'"},{name:"decay_type",val:": str = 'cosine'"},{name:"min_lr_ratio",val:": float = 0"},{name:"num_cycles",val:": float = 0.5"},{name:"last_epoch",val:": int = -1"}],parametersDescription:[{anchor:"transformers.get_wsd_schedule.optimizer",description:`<strong>optimizer</strong> (<code>~torch.optim.Optimizer</code>) &#x2014;
The optimizer for which to schedule the learning rate.`,name:"optimizer"},{anchor:"transformers.get_wsd_schedule.num_warmup_steps",description:`<strong>num_warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup phase.`,name:"num_warmup_steps"},{anchor:"transformers.get_wsd_schedule.num_decay_steps",description:`<strong>num_decay_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the decay phase.`,name:"num_decay_steps"},{anchor:"transformers.get_wsd_schedule.num_training_steps",description:`<strong>num_training_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The total number of training steps. This is the sum of the warmup, stable and decay steps. If <code>num_stable_steps</code> is not provided, the stable phase will be <code>num_training_steps - num_warmup_steps - num_decay_steps</code>.`,name:"num_training_steps"},{anchor:"transformers.get_wsd_schedule.num_stable_steps",description:`<strong>num_stable_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of steps for the stable phase. Please ensure that <code>num_warmup_steps + num_stable_steps + num_decay_steps</code> equals <code>num_training_steps</code>, otherwise the other steps will default to the minimum learning rate.`,name:"num_stable_steps"},{anchor:"transformers.get_wsd_schedule.warmup_type",description:`<strong>warmup_type</strong> (<code>str</code>, <em>optional</em>, defaults to &#x201C;linear&#x201D;) &#x2014;
The type of warmup to use. Can be &#x2018;linear&#x2019;, &#x2018;cosine&#x2019; or &#x2018;1-sqrt&#x2019;.`,name:"warmup_type"},{anchor:"transformers.get_wsd_schedule.decay_type",description:`<strong>decay_type</strong> (<code>str</code>, <em>optional</em>, defaults to &#x201C;cosine&#x201D;) &#x2014;
The type of decay to use. Can be &#x2018;linear&#x2019;, &#x2018;cosine&#x2019; or &#x2018;1-sqrt&#x2019;.`,name:"decay_type"},{anchor:"transformers.get_wsd_schedule.min_lr_ratio",description:`<strong>min_lr_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The minimum learning rate as a ratio of the initial learning rate.`,name:"min_lr_ratio"},{anchor:"transformers.get_wsd_schedule.num_cycles",description:`<strong>num_cycles</strong> (<code>float</code>, <em>optional</em>, defaults to 0.5) &#x2014;
The number of waves in the cosine schedule (the defaults is to just decrease from the max value to 0
following a half-cosine).`,name:"num_cycles"},{anchor:"transformers.get_wsd_schedule.last_epoch",description:`<strong>last_epoch</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the last epoch when resuming training.`,name:"last_epoch"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization.py#L426",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.optim.lr_scheduler.LambdaLR</code> with the appropriate schedule.</p>
`}}),$e=new Y({props:{title:"Warmup (TensorFlow)",local:"transformers.WarmUp",headingTag:"h3"}}),xe=new M({props:{name:"class transformers.WarmUp",anchor:"transformers.WarmUp",parameters:[{name:"initial_learning_rate",val:": float"},{name:"decay_schedule_fn",val:": typing.Callable"},{name:"warmup_steps",val:": int"},{name:"power",val:": float = 1.0"},{name:"name",val:": str = None"}],parametersDescription:[{anchor:"transformers.WarmUp.initial_learning_rate",description:`<strong>initial_learning_rate</strong> (<code>float</code>) &#x2014;
The initial learning rate for the schedule after the warmup (so this will be the learning rate at the end
of the warmup).`,name:"initial_learning_rate"},{anchor:"transformers.WarmUp.decay_schedule_fn",description:`<strong>decay_schedule_fn</strong> (<code>Callable</code>) &#x2014;
The schedule function to apply after the warmup for the rest of training.`,name:"decay_schedule_fn"},{anchor:"transformers.WarmUp.warmup_steps",description:`<strong>warmup_steps</strong> (<code>int</code>) &#x2014;
The number of steps for the warmup part of training.`,name:"warmup_steps"},{anchor:"transformers.WarmUp.power",description:`<strong>power</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
The power to use for the polynomial warmup (defaults is a linear warmup).`,name:"power"},{anchor:"transformers.WarmUp.name",description:`<strong>name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Optional name prefix for the returned tensors during the schedule.`,name:"name"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization_tf.py#L38"}}),Te=new Y({props:{title:"Gradient Strategies",local:"gradient-strategies",headingTag:"h2"}}),ze=new Y({props:{title:"GradientAccumulator (TensorFlow)",local:"transformers.GradientAccumulator",headingTag:"h3"}}),Me=new M({props:{name:"class transformers.GradientAccumulator",anchor:"transformers.GradientAccumulator",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization_tf.py#L310"}}),Ce=new M({props:{name:"reset",anchor:"transformers.GradientAccumulator.reset",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/optimization_tf.py#L372"}}),Ae=new fa({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/main_classes/optimizer_schedules.md"}}),{c(){c=l("meta"),C=a(),x=l("p"),p=a(),d(v.$$.fragment),o=a(),T=l("p"),T.innerHTML=Wr,mt=a(),Q=l("ul"),Q.innerHTML=Rr,ct=a(),d(K.$$.fragment),pt=a(),b=l("div"),d(ee.$$.fragment),Kt=a(),Ue=l("p"),Ue.innerHTML=Er,er=a(),De=l("p"),De.innerHTML=kr,tr=a(),We=l("p"),We.textContent=Ir,rr=a(),Re=l("p"),Re.innerHTML=Fr,ar=a(),Ee=l("ul"),Ee.innerHTML=Nr,nr=a(),d(Z.$$.fragment),sr=a(),d(S.$$.fragment),or=a(),ke=l("p"),ke.innerHTML=Vr,ir=a(),d(H.$$.fragment),lr=a(),d(q.$$.fragment),mr=a(),B=l("div"),d(te.$$.fragment),cr=a(),Ie=l("p"),Ie.textContent=Gr,dt=a(),d(re.$$.fragment),ht=a(),A=l("div"),d(ae.$$.fragment),pr=a(),Fe=l("p"),Fe.innerHTML=Jr,dr=a(),Ne=l("p"),Ne.textContent=Pr,hr=a(),O=l("div"),d(ne.$$.fragment),ur=a(),Ve=l("p"),Ve.textContent=Zr,ut=a(),E=l("div"),d(se.$$.fragment),_r=a(),Ge=l("p"),Ge.textContent=Sr,_t=a(),d(oe.$$.fragment),gt=a(),d(ie.$$.fragment),ft=a(),L=l("div"),d(le.$$.fragment),gr=a(),Je=l("p"),Je.innerHTML=Hr,fr=a(),Pe=l("ul"),Pe.innerHTML=qr,wt=a(),k=l("div"),d(me.$$.fragment),wr=a(),Ze=l("p"),Ze.textContent=Br,bt=a(),I=l("div"),d(ce.$$.fragment),br=a(),Se=l("p"),Se.textContent=Or,yt=a(),F=l("div"),d(pe.$$.fragment),yr=a(),He=l("p"),He.textContent=Xr,vt=a(),de=l("img"),$t=a(),N=l("div"),d(he.$$.fragment),vr=a(),qe=l("p"),qe.textContent=Qr,xt=a(),ue=l("img"),Tt=a(),V=l("div"),d(_e.$$.fragment),$r=a(),Be=l("p"),Be.textContent=ea,zt=a(),ge=l("img"),Mt=a(),G=l("div"),d(fe.$$.fragment),xr=a(),Oe=l("p"),Oe.textContent=ra,Ct=a(),we=l("img"),At=a(),j=l("div"),d(be.$$.fragment),Tr=a(),Xe=l("p"),Xe.innerHTML=na,zr=a(),Ye=l("p"),Ye.innerHTML=sa,Lt=a(),J=l("div"),d(ye.$$.fragment),Mr=a(),Qe=l("p"),Qe.textContent=oa,jt=a(),U=l("div"),d(ve.$$.fragment),Cr=a(),Ke=l("p"),Ke.textContent=ia,Ar=a(),et=l("ol"),et.innerHTML=la,Ut=a(),d($e.$$.fragment),Dt=a(),P=l("div"),d(xe.$$.fragment),Lr=a(),tt=l("p"),tt.textContent=ma,Wt=a(),d(Te.$$.fragment),Rt=a(),d(ze.$$.fragment),Et=a(),D=l("div"),d(Me.$$.fragment),jr=a(),rt=l("p"),rt.innerHTML=ca,Ur=a(),X=l("div"),d(Ce.$$.fragment),Dr=a(),at=l("p"),at.textContent=pa,kt=a(),d(Ae.$$.fragment),It=a(),lt=l("p"),this.h()},l(e){const r=ga("svelte-u9bgzb",document.head);c=m(r,"META",{name:!0,content:!0}),r.forEach(t),C=n(e),x=m(e,"P",{}),z(x).forEach(t),p=n(e),h(v.$$.fragment,e),o=n(e),T=m(e,"P",{"data-svelte-h":!0}),w(T)!=="svelte-312sfx"&&(T.innerHTML=Wr),mt=n(e),Q=m(e,"UL",{"data-svelte-h":!0}),w(Q)!=="svelte-ps1e52"&&(Q.innerHTML=Rr),ct=n(e),h(K.$$.fragment,e),pt=n(e),b=m(e,"DIV",{class:!0});var $=z(b);h(ee.$$.fragment,$),Kt=n($),Ue=m($,"P",{"data-svelte-h":!0}),w(Ue)!=="svelte-114ll6r"&&(Ue.innerHTML=Er),er=n($),De=m($,"P",{"data-svelte-h":!0}),w(De)!=="svelte-9bvrpy"&&(De.innerHTML=kr),tr=n($),We=m($,"P",{"data-svelte-h":!0}),w(We)!=="svelte-1dxk71o"&&(We.textContent=Ir),rr=n($),Re=m($,"P",{"data-svelte-h":!0}),w(Re)!=="svelte-kc6644"&&(Re.innerHTML=Fr),ar=n($),Ee=m($,"UL",{"data-svelte-h":!0}),w(Ee)!=="svelte-p81jc"&&(Ee.innerHTML=Nr),nr=n($),h(Z.$$.fragment,$),sr=n($),h(S.$$.fragment,$),or=n($),ke=m($,"P",{"data-svelte-h":!0}),w(ke)!=="svelte-1qo676b"&&(ke.innerHTML=Vr),ir=n($),h(H.$$.fragment,$),lr=n($),h(q.$$.fragment,$),mr=n($),B=m($,"DIV",{class:!0});var Le=z(B);h(te.$$.fragment,Le),cr=n(Le),Ie=m(Le,"P",{"data-svelte-h":!0}),w(Ie)!=="svelte-6lkj7q"&&(Ie.textContent=Gr),Le.forEach(t),$.forEach(t),dt=n(e),h(re.$$.fragment,e),ht=n(e),A=m(e,"DIV",{class:!0});var W=z(A);h(ae.$$.fragment,W),pr=n(W),Fe=m(W,"P",{"data-svelte-h":!0}),w(Fe)!=="svelte-towids"&&(Fe.innerHTML=Jr),dr=n(W),Ne=m(W,"P",{"data-svelte-h":!0}),w(Ne)!=="svelte-id029h"&&(Ne.textContent=Pr),hr=n(W),O=m(W,"DIV",{class:!0});var je=z(O);h(ne.$$.fragment,je),ur=n(je),Ve=m(je,"P",{"data-svelte-h":!0}),w(Ve)!=="svelte-3iict9"&&(Ve.textContent=Zr),je.forEach(t),W.forEach(t),ut=n(e),E=m(e,"DIV",{class:!0});var Nt=z(E);h(se.$$.fragment,Nt),_r=n(Nt),Ge=m(Nt,"P",{"data-svelte-h":!0}),w(Ge)!=="svelte-16qojcu"&&(Ge.textContent=Sr),Nt.forEach(t),_t=n(e),h(oe.$$.fragment,e),gt=n(e),h(ie.$$.fragment,e),ft=n(e),L=m(e,"DIV",{class:!0});var nt=z(L);h(le.$$.fragment,nt),gr=n(nt),Je=m(nt,"P",{"data-svelte-h":!0}),w(Je)!=="svelte-xzcfpn"&&(Je.innerHTML=Hr),fr=n(nt),Pe=m(nt,"UL",{"data-svelte-h":!0}),w(Pe)!=="svelte-1i9daf3"&&(Pe.innerHTML=qr),nt.forEach(t),wt=n(e),k=m(e,"DIV",{class:!0});var Vt=z(k);h(me.$$.fragment,Vt),wr=n(Vt),Ze=m(Vt,"P",{"data-svelte-h":!0}),w(Ze)!=="svelte-1oh310h"&&(Ze.textContent=Br),Vt.forEach(t),bt=n(e),I=m(e,"DIV",{class:!0});var Gt=z(I);h(ce.$$.fragment,Gt),br=n(Gt),Se=m(Gt,"P",{"data-svelte-h":!0}),w(Se)!=="svelte-cadr4a"&&(Se.textContent=Or),Gt.forEach(t),yt=n(e),F=m(e,"DIV",{class:!0});var Jt=z(F);h(pe.$$.fragment,Jt),yr=n(Jt),He=m(Jt,"P",{"data-svelte-h":!0}),w(He)!=="svelte-1lj8vcj"&&(He.textContent=Xr),Jt.forEach(t),vt=n(e),de=m(e,"IMG",{alt:!0,src:!0}),$t=n(e),N=m(e,"DIV",{class:!0});var Pt=z(N);h(he.$$.fragment,Pt),vr=n(Pt),qe=m(Pt,"P",{"data-svelte-h":!0}),w(qe)!=="svelte-1lhkhz0"&&(qe.textContent=Qr),Pt.forEach(t),xt=n(e),ue=m(e,"IMG",{alt:!0,src:!0}),Tt=n(e),V=m(e,"DIV",{class:!0});var Zt=z(V);h(_e.$$.fragment,Zt),$r=n(Zt),Be=m(Zt,"P",{"data-svelte-h":!0}),w(Be)!=="svelte-1pclsvt"&&(Be.textContent=ea),Zt.forEach(t),zt=n(e),ge=m(e,"IMG",{alt:!0,src:!0}),Mt=n(e),G=m(e,"DIV",{class:!0});var St=z(G);h(fe.$$.fragment,St),xr=n(St),Oe=m(St,"P",{"data-svelte-h":!0}),w(Oe)!=="svelte-17q4ov5"&&(Oe.textContent=ra),St.forEach(t),Ct=n(e),we=m(e,"IMG",{alt:!0,src:!0}),At=n(e),j=m(e,"DIV",{class:!0});var st=z(j);h(be.$$.fragment,st),Tr=n(st),Xe=m(st,"P",{"data-svelte-h":!0}),w(Xe)!=="svelte-1y55gjq"&&(Xe.innerHTML=na),zr=n(st),Ye=m(st,"P",{"data-svelte-h":!0}),w(Ye)!=="svelte-1tn0l2l"&&(Ye.innerHTML=sa),st.forEach(t),Lt=n(e),J=m(e,"DIV",{class:!0});var Ht=z(J);h(ye.$$.fragment,Ht),Mr=n(Ht),Qe=m(Ht,"P",{"data-svelte-h":!0}),w(Qe)!=="svelte-yp2yn6"&&(Qe.textContent=oa),Ht.forEach(t),jt=n(e),U=m(e,"DIV",{class:!0});var ot=z(U);h(ve.$$.fragment,ot),Cr=n(ot),Ke=m(ot,"P",{"data-svelte-h":!0}),w(Ke)!=="svelte-1g5u0qv"&&(Ke.textContent=ia),Ar=n(ot),et=m(ot,"OL",{"data-svelte-h":!0}),w(et)!=="svelte-128o9uy"&&(et.innerHTML=la),ot.forEach(t),Ut=n(e),h($e.$$.fragment,e),Dt=n(e),P=m(e,"DIV",{class:!0});var qt=z(P);h(xe.$$.fragment,qt),Lr=n(qt),tt=m(qt,"P",{"data-svelte-h":!0}),w(tt)!=="svelte-1mfn66a"&&(tt.textContent=ma),qt.forEach(t),Wt=n(e),h(Te.$$.fragment,e),Rt=n(e),h(ze.$$.fragment,e),Et=n(e),D=m(e,"DIV",{class:!0});var it=z(D);h(Me.$$.fragment,it),jr=n(it),rt=m(it,"P",{"data-svelte-h":!0}),w(rt)!=="svelte-8tkiw"&&(rt.innerHTML=ca),Ur=n(it),X=m(it,"DIV",{class:!0});var Bt=z(X);h(Ce.$$.fragment,Bt),Dr=n(Bt),at=m(Bt,"P",{"data-svelte-h":!0}),w(at)!=="svelte-v0y289"&&(at.textContent=pa),Bt.forEach(t),it.forEach(t),kt=n(e),h(Ae.$$.fragment,e),It=n(e),lt=m(e,"P",{}),z(lt).forEach(t),this.h()},h(){y(c,"name","hf:doc:metadata"),y(c,"content",xa),y(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(de,"alt",""),Ot(de.src,Yr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_constant_schedule.png")||y(de,"src",Yr),y(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(ue,"alt",""),Ot(ue.src,Kr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_cosine_schedule.png")||y(ue,"src",Kr),y(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(ge,"alt",""),Ot(ge.src,ta="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_cosine_hard_restarts_schedule.png")||y(ge,"src",ta),y(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(we,"alt",""),Ot(we.src,aa="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_linear_schedule.png")||y(we,"src",aa),y(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,r){s(document.head,c),i(e,C,r),i(e,x,r),i(e,p,r),u(v,e,r),i(e,o,r),i(e,T,r),i(e,mt,r),i(e,Q,r),i(e,ct,r),u(K,e,r),i(e,pt,r),i(e,b,r),u(ee,b,null),s(b,Kt),s(b,Ue),s(b,er),s(b,De),s(b,tr),s(b,We),s(b,rr),s(b,Re),s(b,ar),s(b,Ee),s(b,nr),u(Z,b,null),s(b,sr),u(S,b,null),s(b,or),s(b,ke),s(b,ir),u(H,b,null),s(b,lr),u(q,b,null),s(b,mr),s(b,B),u(te,B,null),s(B,cr),s(B,Ie),i(e,dt,r),u(re,e,r),i(e,ht,r),i(e,A,r),u(ae,A,null),s(A,pr),s(A,Fe),s(A,dr),s(A,Ne),s(A,hr),s(A,O),u(ne,O,null),s(O,ur),s(O,Ve),i(e,ut,r),i(e,E,r),u(se,E,null),s(E,_r),s(E,Ge),i(e,_t,r),u(oe,e,r),i(e,gt,r),u(ie,e,r),i(e,ft,r),i(e,L,r),u(le,L,null),s(L,gr),s(L,Je),s(L,fr),s(L,Pe),i(e,wt,r),i(e,k,r),u(me,k,null),s(k,wr),s(k,Ze),i(e,bt,r),i(e,I,r),u(ce,I,null),s(I,br),s(I,Se),i(e,yt,r),i(e,F,r),u(pe,F,null),s(F,yr),s(F,He),i(e,vt,r),i(e,de,r),i(e,$t,r),i(e,N,r),u(he,N,null),s(N,vr),s(N,qe),i(e,xt,r),i(e,ue,r),i(e,Tt,r),i(e,V,r),u(_e,V,null),s(V,$r),s(V,Be),i(e,zt,r),i(e,ge,r),i(e,Mt,r),i(e,G,r),u(fe,G,null),s(G,xr),s(G,Oe),i(e,Ct,r),i(e,we,r),i(e,At,r),i(e,j,r),u(be,j,null),s(j,Tr),s(j,Xe),s(j,zr),s(j,Ye),i(e,Lt,r),i(e,J,r),u(ye,J,null),s(J,Mr),s(J,Qe),i(e,jt,r),i(e,U,r),u(ve,U,null),s(U,Cr),s(U,Ke),s(U,Ar),s(U,et),i(e,Ut,r),u($e,e,r),i(e,Dt,r),i(e,P,r),u(xe,P,null),s(P,Lr),s(P,tt),i(e,Wt,r),u(Te,e,r),i(e,Rt,r),u(ze,e,r),i(e,Et,r),i(e,D,r),u(Me,D,null),s(D,jr),s(D,rt),s(D,Ur),s(D,X),u(Ce,X,null),s(X,Dr),s(X,at),i(e,kt,r),u(Ae,e,r),i(e,It,r),i(e,lt,r),Ft=!0},p(e,[r]){const $={};r&2&&($.$$scope={dirty:r,ctx:e}),Z.$set($);const Le={};r&2&&(Le.$$scope={dirty:r,ctx:e}),S.$set(Le);const W={};r&2&&(W.$$scope={dirty:r,ctx:e}),H.$set(W);const je={};r&2&&(je.$$scope={dirty:r,ctx:e}),q.$set(je)},i(e){Ft||(_(v.$$.fragment,e),_(K.$$.fragment,e),_(ee.$$.fragment,e),_(Z.$$.fragment,e),_(S.$$.fragment,e),_(H.$$.fragment,e),_(q.$$.fragment,e),_(te.$$.fragment,e),_(re.$$.fragment,e),_(ae.$$.fragment,e),_(ne.$$.fragment,e),_(se.$$.fragment,e),_(oe.$$.fragment,e),_(ie.$$.fragment,e),_(le.$$.fragment,e),_(me.$$.fragment,e),_(ce.$$.fragment,e),_(pe.$$.fragment,e),_(he.$$.fragment,e),_(_e.$$.fragment,e),_(fe.$$.fragment,e),_(be.$$.fragment,e),_(ye.$$.fragment,e),_(ve.$$.fragment,e),_($e.$$.fragment,e),_(xe.$$.fragment,e),_(Te.$$.fragment,e),_(ze.$$.fragment,e),_(Me.$$.fragment,e),_(Ce.$$.fragment,e),_(Ae.$$.fragment,e),Ft=!0)},o(e){g(v.$$.fragment,e),g(K.$$.fragment,e),g(ee.$$.fragment,e),g(Z.$$.fragment,e),g(S.$$.fragment,e),g(H.$$.fragment,e),g(q.$$.fragment,e),g(te.$$.fragment,e),g(re.$$.fragment,e),g(ae.$$.fragment,e),g(ne.$$.fragment,e),g(se.$$.fragment,e),g(oe.$$.fragment,e),g(ie.$$.fragment,e),g(le.$$.fragment,e),g(me.$$.fragment,e),g(ce.$$.fragment,e),g(pe.$$.fragment,e),g(he.$$.fragment,e),g(_e.$$.fragment,e),g(fe.$$.fragment,e),g(be.$$.fragment,e),g(ye.$$.fragment,e),g(ve.$$.fragment,e),g($e.$$.fragment,e),g(xe.$$.fragment,e),g(Te.$$.fragment,e),g(ze.$$.fragment,e),g(Me.$$.fragment,e),g(Ce.$$.fragment,e),g(Ae.$$.fragment,e),Ft=!1},d(e){e&&(t(C),t(x),t(p),t(o),t(T),t(mt),t(Q),t(ct),t(pt),t(b),t(dt),t(ht),t(A),t(ut),t(E),t(_t),t(gt),t(ft),t(L),t(wt),t(k),t(bt),t(I),t(yt),t(F),t(vt),t(de),t($t),t(N),t(xt),t(ue),t(Tt),t(V),t(zt),t(ge),t(Mt),t(G),t(Ct),t(we),t(At),t(j),t(Lt),t(J),t(jt),t(U),t(Ut),t(Dt),t(P),t(Wt),t(Rt),t(Et),t(D),t(kt),t(It),t(lt)),t(c),f(v,e),f(K,e),f(ee),f(Z),f(S),f(H),f(q),f(te),f(re,e),f(ae),f(ne),f(se),f(oe,e),f(ie,e),f(le),f(me),f(ce),f(pe),f(he),f(_e),f(fe),f(be),f(ye),f(ve),f($e,e),f(xe),f(Te,e),f(ze,e),f(Me),f(Ce),f(Ae,e)}}}const xa='{"title":"Optimization","local":"optimization","sections":[{"title":"AdaFactor (PyTorch)","local":"transformers.Adafactor","sections":[],"depth":2},{"title":"AdamWeightDecay (TensorFlow)","local":"transformers.AdamWeightDecay","sections":[],"depth":2},{"title":"Schedules","local":"schedules","sections":[{"title":"Learning Rate Schedules (PyTorch)","local":"transformers.SchedulerType","sections":[],"depth":3},{"title":"Warmup (TensorFlow)","local":"transformers.WarmUp","sections":[],"depth":3}],"depth":2},{"title":"Gradient Strategies","local":"gradient-strategies","sections":[{"title":"GradientAccumulator (TensorFlow)","local":"transformers.GradientAccumulator","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ta(R){return ha(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ua extends ua{constructor(c){super(),_a(this,c,Ta,$a,da,{})}}export{Ua as component};
