File size: 2,830 Bytes
ee21b96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
.. role:: hidden
    :class: hidden-section

.. module:: fairseq.models

.. _Models:

Models
======

A Model defines the neural network's ``forward()`` method and encapsulates all
of the learnable parameters in the network. Each model also provides a set of
named *architectures* that define the precise network configuration (e.g.,
embedding dimension, number of layers, etc.).

Both the model type and architecture are selected via the ``--arch``
command-line argument. Once selected, a model may expose additional command-line
arguments for further configuration.

.. note::

    All fairseq Models extend :class:`BaseFairseqModel`, which in turn extends
    :class:`torch.nn.Module`. Thus any fairseq Model can be used as a
    stand-alone Module in other PyTorch code.


Convolutional Neural Networks (CNN)
-----------------------------------

.. module:: fairseq.models.fconv
.. autoclass:: fairseq.models.fconv.FConvModel
    :members:
.. autoclass:: fairseq.models.fconv.FConvEncoder
    :members:
    :undoc-members:
.. autoclass:: fairseq.models.fconv.FConvDecoder
    :members:


Long Short-Term Memory (LSTM) networks
--------------------------------------

.. module:: fairseq.models.lstm
.. autoclass:: fairseq.models.lstm.LSTMModel
    :members:
.. autoclass:: fairseq.models.lstm.LSTMEncoder
    :members:
.. autoclass:: fairseq.models.lstm.LSTMDecoder
    :members:


Transformer (self-attention) networks
-------------------------------------

.. module:: fairseq.models.transformer
.. autoclass:: fairseq.models.transformer.TransformerModel
    :members:
.. autoclass:: fairseq.models.transformer.TransformerEncoder
    :members:
.. autoclass:: fairseq.models.transformer.TransformerEncoderLayer
    :members:
.. autoclass:: fairseq.models.transformer.TransformerDecoder
    :members:
.. autoclass:: fairseq.models.transformer.TransformerDecoderLayer
    :members:


Adding new models
-----------------

.. currentmodule:: fairseq.models
.. autofunction:: fairseq.models.register_model
.. autofunction:: fairseq.models.register_model_architecture
.. autoclass:: fairseq.models.BaseFairseqModel
    :members:
    :undoc-members:
.. autoclass:: fairseq.models.FairseqEncoderDecoderModel
    :members:
    :undoc-members:
.. autoclass:: fairseq.models.FairseqEncoderModel
    :members:
    :undoc-members:
.. autoclass:: fairseq.models.FairseqLanguageModel
    :members:
    :undoc-members:
.. autoclass:: fairseq.models.FairseqMultiModel
    :members:
    :undoc-members:
.. autoclass:: fairseq.models.FairseqEncoder
    :members:
.. autoclass:: fairseq.models.CompositeEncoder
    :members:
.. autoclass:: fairseq.models.FairseqDecoder
    :members:


.. _Incremental decoding:

Incremental decoding
--------------------

.. autoclass:: fairseq.models.FairseqIncrementalDecoder
    :members:
    :undoc-members: