optimizer_schedules.rst 1.7 KB
Newer Older
thomwolf's avatar
thomwolf committed
1
2
3
Optimizer
----------------------------------------------------

4
5
6
7
The ``.optimization`` module provides:

- an optimizer with weight decay fixed that can be used to fine-tuned models, and
- several schedules in the form of schedule objects that inherit from ``_LRSchedule``:
8
- a gradient accumulation class to accumulate the gradients of multiple batches
9

thomwolf's avatar
thomwolf committed
10
11
12
``AdamW``
~~~~~~~~~~~~~~~~

13
.. autoclass:: transformers.AdamW
thomwolf's avatar
thomwolf committed
14
15
    :members:

16
17
18
19
20
21
22
23
``AdamWeightDecay``
~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.AdamWeightDecay
    :members:

.. autofunction:: transformers.create_optimizer

thomwolf's avatar
thomwolf committed
24
25
26
Schedules
----------------------------------------------------

27
Learning Rate Schedules
28
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29
.. autofunction:: transformers.get_constant_schedule
thomwolf's avatar
thomwolf committed
30

31

32
.. autofunction:: transformers.get_constant_schedule_with_warmup
thomwolf's avatar
thomwolf committed
33

34
35
36
37
38
.. image:: /imgs/warmup_constant_schedule.png
    :target: /imgs/warmup_constant_schedule.png
    :alt:


39
.. autofunction:: transformers.get_cosine_schedule_with_warmup
thomwolf's avatar
thomwolf committed
40

41
42
43
44
45
.. image:: /imgs/warmup_cosine_schedule.png
    :target: /imgs/warmup_cosine_schedule.png
    :alt:


46
.. autofunction:: transformers.get_cosine_with_hard_restarts_schedule_with_warmup
thomwolf's avatar
thomwolf committed
47

48
49
50
51
52
53
.. image:: /imgs/warmup_cosine_hard_restarts_schedule.png
    :target: /imgs/warmup_cosine_hard_restarts_schedule.png
    :alt:



54
.. autofunction:: transformers.get_linear_schedule_with_warmup
55
56
57
58

.. image:: /imgs/warmup_linear_schedule.png
    :target: /imgs/warmup_linear_schedule.png
    :alt:
59
60
61
62

``Warmup``
~~~~~~~~~~~~~~~~

63
.. autoclass:: transformers.WarmUp
64
65
66
67
68
69
70
71
72
    :members:

Gradient Strategies
----------------------------------------------------

``GradientAccumulator``
~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.GradientAccumulator