chunk_id
large_stringlengths
36
36
doc_type
large_stringclasses
2 values
category
large_stringclasses
17 values
document
large_stringclasses
50 values
version_raw
large_stringclasses
590 values
chunk_index
int64
0
262
text
large_stringlengths
11
5.69k
file_path
large_stringclasses
882 values
525e073a-28e5-58d1-afa2-422b33675289
docs
pytorch
pytorch_crossentropyloss
25
3
on an input, followed by [`NLLLoss`](torch.nn.NLLLoss.html#torch.nn.NLLLoss "torch.nn.NLLLoss"). * Probabilities for each class; useful when labels beyond a single class per minibatch item are required, such as for blended labels, label smoothing, etc. The unreduced (i.e. with `reduction` set to `...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_25.md
e5e2493b-4424-5213-8f06-7f307a105134
docs
pytorch
pytorch_crossentropyloss
25
4
ℓ(x,y)={∑n=1NlnN,if reduction=‘mean’;∑n=1Nln,if reduction=‘sum’.\ell(x, y) = \begin{cases} \frac{\sum\_{n=1}^N l\_n}{N}, & \text{if reduction} = \text{`mean';}\\ \sum\_{n=1}^N l\_n, & \text{if reduction} = \text{`sum'.} \end{cases} ℓ(x,y)={N∑n=1N​ln​​,∑n=1N​ln​,​if reduction=‘m...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_25.md
9e665e39-d950-5479-aeb2-4b066c30e292
docs
pytorch
pytorch_crossentropyloss
25
5
the losses are averaged over each loss element in the batch. Note that for some losses, there are multiple elements per sample. If the field `size_average` is set to `False`, the losses are instead summed for each minibatch. Ignored when `reduce` is `False`. Default: `True` ...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_25.md
db009e2c-b4dd-5d14-ac5b-fbf0a5b72ceb
docs
pytorch
pytorch_crossentropyloss
25
6
on `size_average`. When `reduce` is `False`, returns a loss per batch element instead and ignores `size_average`. Default: `True` * **reduction** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")*,* *optional*) – Specifies the reduction to apply to the output:...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_25.md
c685fba4-befc-5896-9555-76bd74a078c6
docs
pytorch
pytorch_crossentropyloss
25
7
become a mixture of the original ground truth and a uniform distribution as described in [Rethinking the Inception Architecture for Computer Vision](https://arxiv.org/abs/1512.00567). Default: 0.00.00.0. Shape: : * Input: Shape (C)(C)(C), (N,C)(N, C)(N,C) or (N,C,d1,d2,...,dK)(N, C, d\_1,...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_25.md
c6399b03-8363-5ca8-b3a5-bc40188d2daa
docs
pytorch
pytorch_crossentropyloss
25
8
in the case of K-dimensional loss, depending on the shape of the input. Otherwise, scalar. where: C=number of classesN=batch size\begin{aligned} C ={} & \text{number of classes} \\ N ={} & \text{batch size} \\ \end{aligned} C=N=​number of classesbatch size​ ...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_25.md
b7cb6647-0700-5b8f-980f-0002388232b3
docs
pytorch
pytorch_crossentropyloss
25
9
--- © Copyright 2023, PyTorch Contributors. Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_25.md
a1bda8cb-f917-52ef-bd6f-f60322d1c7d2
docs
pytorch
pytorch_crossentropyloss
26
0
# CrossEntropyLoss¶ Source: https://docs.pytorch.org/docs/2.6/generated/torch.nn.CrossEntropyLoss.html Version: 2.6 *class* torch.nn.CrossEntropyLoss(*weight=None*, *size\_average=None*, *ignore\_index=-100*, *reduce=None*, *reduction='mean'*, *label\_smoothing=0.0*)[[source]](../_modules/torch/nn/modules/loss.html#C...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
47d6c401-e893-5681-85d1-67d1dcdc2b16
docs
pytorch
pytorch_crossentropyloss
26
1
input has to be a Tensor of size (C)(C)(C) for unbatched input, (minibatch,C)(minibatch, C)(minibatch,C) or (minibatch,C,d1,d2,...,dK)(minibatch, C, d\_1, d\_2, ..., d\_K)(minibatch,C,d1​,d2​,...,dK​) with K≥1K \geq 1K≥1 for the K-dimensional case. The last being useful for higher dimension inputs, such ...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
affe1cf9-658c-5079-a518-9e1d57acfe5f
docs
pytorch
pytorch_crossentropyloss
26
2
\cdot \mathbb{1}\{y\_n \not= \text{ignore\\_index}\} ℓ(x,y)=L={l1​,…,lN​}⊤,ln​=−wyn​​log∑c=1C​exp(xn,c​)exp(xn,yn​​)​⋅1{yn​=ignore\_index} where xxx is the input, yyy is the target, www is the weight, CCC is the number of classes, and NNN spans the minibatch dimension as well as d1,...,d...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
cb90a080-fd83-5ece-bde8-722383e7dccf
docs
pytorch
pytorch_crossentropyloss
26
3
Note that this case is equivalent to applying [`LogSoftmax`](torch.nn.LogSoftmax.html#torch.nn.LogSoftmax "torch.nn.LogSoftmax") on an input, followed by [`NLLLoss`](torch.nn.NLLLoss.html#torch.nn.NLLLoss "torch.nn.NLLLoss"). * Probabilities for each class; useful when labels beyond a single class per m...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
250c3497-8df8-5716-8a3e-97f20911ded0
docs
pytorch
pytorch_crossentropyloss
26
4
d1,...,dkd\_1, ..., d\_kd1​,...,dk​ for the K-dimensional case. If `reduction` is not `'none'` (default `'mean'`), then ℓ(x,y)={∑n=1NlnN,if reduction=‘mean’;∑n=1Nln,if reduction=‘sum’.\ell(x, y) = \begin{cases} \frac{\sum\_{n=1}^N l\_n}{N}, & \text{if reduction} = \text{`mean';}\\ \...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
61dfdaea-eae5-5481-8f8b-90dbfd38854d
docs
pytorch
pytorch_crossentropyloss
26
5
* **size\_average** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")*,* *optional*) – Deprecated (see `reduction`). By default, the losses are averaged over each loss element in the batch. Note that for some losses, there are multiple elements per sample. ...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
02e3c670-56d3-561f-9257-4a508a6beb6d
docs
pytorch
pytorch_crossentropyloss
26
6
* **reduce** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")*,* *optional*) – Deprecated (see `reduction`). By default, the losses are averaged or summed over observations for each minibatch depending on `size_average`. When `reduce` is `False`, returns a...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
a9295044-a3fd-5cfa-88d1-0bc1314f6d19
docs
pytorch
pytorch_crossentropyloss
26
7
* **label\_smoothing** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")*,* *optional*) – A float in [0.0, 1.0]. Specifies the amount of smoothing when computing the loss, where 0.0 means no smoothing. The targets become a mixture of the original ground t...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
d6684039-9890-5a2a-8499-4182624c29dc
docs
pytorch
pytorch_crossentropyloss
26
8
If containing class probabilities, same shape as the input and each value should be between [0,1][0, 1][0,1]. * Output: If reduction is ‘none’, shape ()()(), (N)(N)(N) or (N,d1,d2,...,dK)(N, d\_1, d\_2, ..., d\_K)(N,d1​,d2​,...,dK​) with K≥1K \geq 1K≥1 in the case of K-dimensional loss, depe...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
9b5d29e1-2ce9-527f-bb34-514e07059383
docs
pytorch
pytorch_crossentropyloss
26
9
>>> target = torch.randn(3, 5).softmax(dim=1) >>> output = loss(input, target) >>> output.backward() ``` [Next ![](../_static/images/chevron-right-orange.svg)](torch.nn.CTCLoss.html "CTCLoss") [![](../_static/images/chevron-right-orange.svg) Previous](torch.nn.MSELoss.html "MSELoss") --- © Copyright ...
large_dataset/raw/docs/pytorch/crossentropyloss/crossentropyloss_26.md
1eeb9b3b-2321-592b-8995-4009cf6893b0
docs
pytorch
pytorch_lstm
20
0
# LSTM¶ Source: https://docs.pytorch.org/docs/2.0/generated/torch.nn.LSTM.html Version: 2.0 *class* torch.nn.LSTM(*\*args*, *\*\*kwargs*)[[source]](../_modules/torch/nn/modules/rnn.html#LSTM)[¶](#torch.nn.LSTM "Permalink to this definition") : Applies a multi-layer long short-term memory (LSTM) RNN to an input ...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
847d51be-52e6-5f0f-9a08-552eb4e6e7a1
docs
pytorch
pytorch_lstm
20
1
it​=σ(Wii​xt​+bii​+Whi​ht−1​+bhi​)ft​=σ(Wif​xt​+bif​+Whf​ht−1​+bhf​)gt​=tanh(Wig​xt​+big​+Whg​ht−1​+bhg​)ot​=σ(Wio​xt​+bio​+Who​ht−1​+bho​)ct​=ft​⊙ct−1​+it​⊙gt​ht​=ot​⊙tanh(ct​)​ where hth\_tht​ is the hidden state at time t, ctc\_tct​ is the cell state at time t, xtx\_txt​ is the input at time t, ht−1h\_{...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
dbad9f30-7837-555e-8ea3-0dbed03b1d94
docs
pytorch
pytorch_lstm
20
2
If `proj_size > 0` is specified, LSTM with projections will be used. This changes the LSTM cell in the following way. First, the dimension of hth\_tht​ will be changed from `hidden_size` to `proj_size` (dimensions of WhiW\_{hi}Whi​ will be changed accordingly). Second, the output hidden state of each la...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
d3d44e98-9e2d-5cc5-b714-845a43964ad0
docs
pytorch
pytorch_lstm
20
3
with the second LSTM taking in outputs of the first LSTM and computing the final results. Default: 1 * **bias** – If `False`, then the layer does not use bias weights b\_ih and b\_hh. Default: `True` * **batch\_first** – If `True`, then the input and output tensors are prov...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
8affeecc-0f82-5c88-914e-606ca8d58f78
docs
pytorch
pytorch_lstm
20
4
: * **input**: tensor of shape (L,Hin)(L, H\_{in})(L,Hin​) for unbatched input, (L,N,Hin)(L, N, H\_{in})(L,N,Hin​) when `batch_first=False` or (N,L,Hin)(N, L, H\_{in})(N,L,Hin​) when `batch_first=True` containing the features of the input sequence. The input can also be a packed vari...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
e3876ae6-b21e-5428-8c5d-fbf2465029b7
docs
pytorch
pytorch_lstm
20
5
Defaults to zeros if (h\_0, c\_0) is not provided. * **c\_0**: tensor of shape (D∗num\_layers,Hcell)(D \* \text{num\\_layers}, H\_{cell})(D∗num\_layers,Hcell​) for unbatched input or (D∗num\_layers,N,Hcell)(D \* \text{num\\_layers}, N, H\_{cell})(D∗num\_layers,N,Hcell​) containing the ...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
99ae3683-f83f-56f1-95e5-b0edf39d3242
docs
pytorch
pytorch_lstm
20
6
N=L=D=Hin​=Hcell​=Hout​=​batch sizesequence length2 if bidirectional=True otherwise 1input\_sizehidden\_sizeproj\_size if proj\_size>0 otherwise hidden\_size​ Outputs: output, (h\_n, c\_n) : * **output**: tensor of shape (L,D∗Hout)(L, D \* H\_{out})(L,D∗Hout​) for unbatched input, (L,N,D∗Ho...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
365a1ac5-f890-5c97-86fd-1bd9c2012da1
docs
pytorch
pytorch_lstm
20
7
* **h\_n**: tensor of shape (D∗num\_layers,Hout)(D \* \text{num\\_layers}, H\_{out})(D∗num\_layers,Hout​) for unbatched input or (D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_layers,N,Hout​) containing the final hidden state for each element in the sequence. When `bidi...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
cca2b5e1-a8fb-568d-8034-de70e295d6bb
docs
pytorch
pytorch_lstm
20
8
(W\_ii|W\_if|W\_ig|W\_io), of shape (4\*hidden\_size, input\_size) for k = 0. Otherwise, the shape is (4\*hidden\_size, num\_directions \* hidden\_size). If `proj_size > 0` was specified, the shape will be (4\*hidden\_size, num\_directions \* proj\_size) for k > 0 * **wei...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
8d910681-5343-5974-b6b8-89b29b70d350
docs
pytorch
pytorch_lstm
20
9
of shape (proj\_size, hidden\_size). Only present when `proj_size > 0` was specified. * **weight\_ih\_l[k]\_reverse** – Analogous to weight\_ih\_l[k] for the reverse direction. Only present when `bidirectional=True`. * **weight\_hh\_l[k]\_reverse** – Analogous to weight\_hh...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
97de90c9-3060-5fed-8ad6-8889393fe955
docs
pytorch
pytorch_lstm
20
10
where k=1hidden\_sizek = \frac{1}{\text{hidden\\_size}}k=hidden\_size1​ Note For bidirectional LSTMs, forward and backward are directions 0 and 1 respectively. Example of splitting the output layers when `batch_first=False`: `output.view(seq_len, batch, num_directions, hidden_size)`. Note ...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
3ee9a10c-6268-59d0-bd19-cd399f3cf71e
docs
pytorch
pytorch_lstm
20
11
(note the leading colon symbol) `CUBLAS_WORKSPACE_CONFIG=:16:8` or `CUBLAS_WORKSPACE_CONFIG=:4096:2`. See the [cuDNN 8 Release Notes](https://docs.nvidia.com/deeplearning/sdk/cudnn-release-notes/rel_8.html) for more information. Note If the following conditions are satisfied: 1) cudnn...
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
aa4c1db0-201c-5c33-b5f4-e0ef8e50acf1
docs
pytorch
pytorch_lstm
20
12
Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/lstm/lstm_20.md
743305de-76f5-5edd-8ed7-8efd0286c08c
docs
pytorch
pytorch_lstm
21
0
# LSTM¶ Source: https://docs.pytorch.org/docs/2.1/generated/torch.nn.LSTM.html Version: 2.1 *class* torch.nn.LSTM(*self*, *input\_size*, *hidden\_size*, *num\_layers=1*, *bias=True*, *batch\_first=False*, *dropout=0.0*, *bidirectional=False*, *proj\_size=0*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
f0e9b503-6949-526d-8438-4aadd78afc35
docs
pytorch
pytorch_lstm
21
1
o\_t = \sigma(W\_{io} x\_t + b\_{io} + W\_{ho} h\_{t-1} + b\_{ho}) \\ c\_t = f\_t \odot c\_{t-1} + i\_t \odot g\_t \\ h\_t = o\_t \odot \tanh(c\_t) \\ \end{array} it​=σ(Wii​xt​+bii​+Whi​ht−1​+bhi​)ft​=σ(Wif​xt​+bif​+Whf​ht−1​+bhf​)gt​=tanh(Wig​xt​+big​+Whg​ht−1​+bhg​)ot​=σ(Wio​xt​+bio​+Who​ht−1​+bho...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
5ab0fa87-27d8-5345-a047-88e9610b789e
docs
pytorch
pytorch_lstm
21
2
dropout δt(l−1)\delta^{(l-1)}\_tδt(l−1)​ where each δt(l−1)\delta^{(l-1)}\_tδt(l−1)​ is a Bernoulli random variable which is 000 with probability `dropout`. If `proj_size > 0` is specified, LSTM with projections will be used. This changes the LSTM cell in the following way. First, the dimension of hth\...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
d52b2a2d-01d9-5c35-af70-da675ee5efa8
docs
pytorch
pytorch_lstm
21
3
* **num\_layers** – Number of recurrent layers. E.g., setting `num_layers=2` would mean stacking two LSTMs together to form a stacked LSTM, with the second LSTM taking in outputs of the first LSTM and computing the final results. Default: 1 * **bias** – If `False`, then the...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
40e82786-2378-529c-a1f5-df9637993347
docs
pytorch
pytorch_lstm
21
4
* **proj\_size** – If `> 0`, will use LSTM with projections of corresponding size. Default: 0 Inputs: input, (h\_0, c\_0) : * **input**: tensor of shape (L,Hin)(L, H\_{in})(L,Hin​) for unbatched input, (L,N,Hin)(L, N, H\_{in})(L,N,Hin​) when `batch_first=False` or (N,L,Hin)(N, L, ...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
67721e14-8f47-51f8-b4d0-b873705c8fd7
docs
pytorch
pytorch_lstm
21
5
(D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_layers,N,Hout​) containing the initial hidden state for each element in the input sequence. Defaults to zeros if (h\_0, c\_0) is not provided. * **c\_0**: tensor of shape (D∗num\_layers,Hcell)(D \* \text{num\\_lay...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
f007e645-307a-5d72-a7e5-a7b67a98f026
docs
pytorch
pytorch_lstm
21
6
H\_{cell} ={} & \text{hidden\\_size} \\ H\_{out} ={} & \text{proj\\_size if } \text{proj\\_size}>0 \text{ otherwise hidden\\_size} \\ \end{aligned} N=L=D=Hin​=Hcell​=Hout​=​batch sizesequence length2 if bidirectional=True otherwise 1input\_sizehidden\_sizeproj\_size if proj\_size>0 other...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
f7243e44-8c6f-5d02-b776-c6a670556492
docs
pytorch
pytorch_lstm
21
7
a concatenation of the forward and reverse hidden states at each time step in the sequence. * **h\_n**: tensor of shape (D∗num\_layers,Hout)(D \* \text{num\\_layers}, H\_{out})(D∗num\_layers,Hout​) for unbatched input or (D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_la...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
e3f75c77-ed97-52fd-800c-72bb922c6a1b
docs
pytorch
pytorch_lstm
21
8
: * **weight\_ih\_l[k]** – the learnable input-hidden weights of the kth\text{k}^{th}kth layer (W\_ii|W\_if|W\_ig|W\_io), of shape (4\*hidden\_size, input\_size) for k = 0. Otherwise, the shape is (4\*hidden\_size, num\_directions \* hidden\_size). If `proj_size > 0` was specified, t...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
67cb3b7d-c6d5-5b89-9a45-ceae4d5821b0
docs
pytorch
pytorch_lstm
21
9
* **weight\_hr\_l[k]** – the learnable projection weights of the kth\text{k}^{th}kth layer of shape (proj\_size, hidden\_size). Only present when `proj_size > 0` was specified. * **weight\_ih\_l[k]\_reverse** – Analogous to weight\_ih\_l[k] for the reverse direction. Only p...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
ec03e3fb-d40e-5cb6-a0ba-6a46bf9b2c24
docs
pytorch
pytorch_lstm
21
10
All the weights and biases are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k})U(−k​,k​) where k=1hidden\_sizek = \frac{1}{\text{hidden\\_size}}k=hidden\_size1​ Note For bidirectional LSTMs, forward and backward are directions 0 and 1 respectively. Example of splitting the output layers wh...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
410419a0-8230-57b2-802e-ce349c5365bc
docs
pytorch
pytorch_lstm
21
11
On CUDA 10.1, set environment variable `CUDA_LAUNCH_BLOCKING=1`. This may affect performance. On CUDA 10.2 or later, set environment variable (note the leading colon symbol) `CUBLAS_WORKSPACE_CONFIG=:16:8` or `CUBLAS_WORKSPACE_CONFIG=:4096:2`. See the [cuDNN 8 Release Notes](https://do...
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
c494ed9a-1cdd-5d6b-8f3e-d8d91d24270a
docs
pytorch
pytorch_lstm
21
12
[![](../_static/images/chevron-right-orange.svg) Previous](torch.nn.RNN.html "RNN") --- © Copyright 2023, PyTorch Contributors. Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/lstm/lstm_21.md
c51ec464-ad7d-5fd9-876e-9085686ee20d
docs
pytorch
pytorch_lstm
22
0
# LSTM¶ Source: https://docs.pytorch.org/docs/2.2/generated/torch.nn.LSTM.html Version: 2.2 *class* torch.nn.LSTM(*self*, *input\_size*, *hidden\_size*, *num\_layers=1*, *bias=True*, *batch\_first=False*, *dropout=0.0*, *bidirectional=False*, *proj\_size=0*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
e9a93e31-b9de-53bf-8133-2788d0b4cf2d
docs
pytorch
pytorch_lstm
22
1
o\_t = \sigma(W\_{io} x\_t + b\_{io} + W\_{ho} h\_{t-1} + b\_{ho}) \\ c\_t = f\_t \odot c\_{t-1} + i\_t \odot g\_t \\ h\_t = o\_t \odot \tanh(c\_t) \\ \end{array} it​=σ(Wii​xt​+bii​+Whi​ht−1​+bhi​)ft​=σ(Wif​xt​+bif​+Whf​ht−1​+bhf​)gt​=tanh(Wig​xt​+big​+Whg​ht−1​+bhg​)ot​=σ(Wio​xt​+bio​+Who​ht−1​+bho...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
7538f173-c0fe-5d48-9191-23ad24711b38
docs
pytorch
pytorch_lstm
22
2
dropout δt(l−1)\delta^{(l-1)}\_tδt(l−1)​ where each δt(l−1)\delta^{(l-1)}\_tδt(l−1)​ is a Bernoulli random variable which is 000 with probability `dropout`. If `proj_size > 0` is specified, LSTM with projections will be used. This changes the LSTM cell in the following way. First, the dimension of hth\...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
6310a2a3-0669-5b3e-bb9d-56c0d0f75c13
docs
pytorch
pytorch_lstm
22
3
* **num\_layers** – Number of recurrent layers. E.g., setting `num_layers=2` would mean stacking two LSTMs together to form a stacked LSTM, with the second LSTM taking in outputs of the first LSTM and computing the final results. Default: 1 * **bias** – If `False`, then the...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
c2d8b667-fb1f-594d-b116-1860560d7fa0
docs
pytorch
pytorch_lstm
22
4
* **proj\_size** – If `> 0`, will use LSTM with projections of corresponding size. Default: 0 Inputs: input, (h\_0, c\_0) : * **input**: tensor of shape (L,Hin)(L, H\_{in})(L,Hin​) for unbatched input, (L,N,Hin)(L, N, H\_{in})(L,N,Hin​) when `batch_first=False` or (N,L,Hin)(N, L, ...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
7204157e-0089-5ee2-99c0-69c0fa3c2a6c
docs
pytorch
pytorch_lstm
22
5
(D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_layers,N,Hout​) containing the initial hidden state for each element in the input sequence. Defaults to zeros if (h\_0, c\_0) is not provided. * **c\_0**: tensor of shape (D∗num\_layers,Hcell)(D \* \text{num\\_lay...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
f1ecb2f8-1023-57bd-bf37-6acd72e9f623
docs
pytorch
pytorch_lstm
22
6
H\_{cell} ={} & \text{hidden\\_size} \\ H\_{out} ={} & \text{proj\\_size if } \text{proj\\_size}>0 \text{ otherwise hidden\\_size} \\ \end{aligned} N=L=D=Hin​=Hcell​=Hout​=​batch sizesequence length2 if bidirectional=True otherwise 1input\_sizehidden\_sizeproj\_size if proj\_size>0 other...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
c79254fc-666a-5fa0-90be-28862ebc9d69
docs
pytorch
pytorch_lstm
22
7
a concatenation of the forward and reverse hidden states at each time step in the sequence. * **h\_n**: tensor of shape (D∗num\_layers,Hout)(D \* \text{num\\_layers}, H\_{out})(D∗num\_layers,Hout​) for unbatched input or (D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_la...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
a3d64a90-d996-5123-b264-270e8682f516
docs
pytorch
pytorch_lstm
22
8
: * **weight\_ih\_l[k]** – the learnable input-hidden weights of the kth\text{k}^{th}kth layer (W\_ii|W\_if|W\_ig|W\_io), of shape (4\*hidden\_size, input\_size) for k = 0. Otherwise, the shape is (4\*hidden\_size, num\_directions \* hidden\_size). If `proj_size > 0` was specified, t...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
429a56cd-26ce-5855-9391-28b9e563befa
docs
pytorch
pytorch_lstm
22
9
* **weight\_hr\_l[k]** – the learnable projection weights of the kth\text{k}^{th}kth layer of shape (proj\_size, hidden\_size). Only present when `proj_size > 0` was specified. * **weight\_ih\_l[k]\_reverse** – Analogous to weight\_ih\_l[k] for the reverse direction. Only p...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
ec25ec69-f34a-500f-8040-d992f153d7ee
docs
pytorch
pytorch_lstm
22
10
All the weights and biases are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k})U(−k​,k​) where k=1hidden\_sizek = \frac{1}{\text{hidden\\_size}}k=hidden\_size1​ Note For bidirectional LSTMs, forward and backward are directions 0 and 1 respectively. Example of splitting the output layers wh...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
2e13f0ea-3048-537a-902c-fa2d512087b6
docs
pytorch
pytorch_lstm
22
11
On CUDA 10.1, set environment variable `CUDA_LAUNCH_BLOCKING=1`. This may affect performance. On CUDA 10.2 or later, set environment variable (note the leading colon symbol) `CUBLAS_WORKSPACE_CONFIG=:16:8` or `CUBLAS_WORKSPACE_CONFIG=:4096:2`. See the [cuDNN 8 Release Notes](https://do...
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
51714248-ffe1-59c0-88cd-64845b91ecd6
docs
pytorch
pytorch_lstm
22
12
[![](../_static/images/chevron-right-orange.svg) Previous](torch.nn.RNN.html "RNN") --- © Copyright 2023, PyTorch Contributors. Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/lstm/lstm_22.md
43c129a4-15f1-5d03-abce-cc4db7315267
docs
pytorch
pytorch_lstm
23
0
# LSTM¶ Source: https://docs.pytorch.org/docs/2.3/generated/torch.nn.LSTM.html Version: 2.3 *class* torch.nn.LSTM(*input\_size*, *hidden\_size*, *num\_layers=1*, *bias=True*, *batch\_first=False*, *dropout=0.0*, *bidirectional=False*, *proj\_size=0*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn/modules...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
1fc334c3-5aee-5690-bb7c-b9f0afeb62bc
docs
pytorch
pytorch_lstm
23
1
c\_t = f\_t \odot c\_{t-1} + i\_t \odot g\_t \\ h\_t = o\_t \odot \tanh(c\_t) \\ \end{array} it​=σ(Wii​xt​+bii​+Whi​ht−1​+bhi​)ft​=σ(Wif​xt​+bif​+Whf​ht−1​+bhf​)gt​=tanh(Wig​xt​+big​+Whg​ht−1​+bhg​)ot​=σ(Wio​xt​+bio​+Who​ht−1​+bho​)ct​=ft​⊙ct−1​+it​⊙gt​ht​=ot​⊙tanh(ct​)​ where hth\_tht​ is the hidd...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
4c41ac00-ba8d-5813-bd52-527bc217a2bd
docs
pytorch
pytorch_lstm
23
2
variable which is 000 with probability `dropout`. If `proj_size > 0` is specified, LSTM with projections will be used. This changes the LSTM cell in the following way. First, the dimension of hth\_tht​ will be changed from `hidden_size` to `proj_size` (dimensions of WhiW\_{hi}Whi​ will be changed accor...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
51f84f9c-bed4-5666-b640-8215471a19f4
docs
pytorch
pytorch_lstm
23
3
would mean stacking two LSTMs together to form a stacked LSTM, with the second LSTM taking in outputs of the first LSTM and computing the final results. Default: 1 * **bias** – If `False`, then the layer does not use bias weights b\_ih and b\_hh. Default: `True` *...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
5c2c3f4e-a78b-5e10-b2f1-4946f4e5fbf9
docs
pytorch
pytorch_lstm
23
4
Inputs: input, (h\_0, c\_0) : * **input**: tensor of shape (L,Hin)(L, H\_{in})(L,Hin​) for unbatched input, (L,N,Hin)(L, N, H\_{in})(L,N,Hin​) when `batch_first=False` or (N,L,Hin)(N, L, H\_{in})(N,L,Hin​) when `batch_first=True` containing the features of the input sequence. The...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
5309140b-4b1a-5c25-a29c-55ee98a5ef37
docs
pytorch
pytorch_lstm
23
5
initial hidden state for each element in the input sequence. Defaults to zeros if (h\_0, c\_0) is not provided. * **c\_0**: tensor of shape (D∗num\_layers,Hcell)(D \* \text{num\\_layers}, H\_{cell})(D∗num\_layers,Hcell​) for unbatched input or (D∗num\_layers,N,Hcell)(D \* \text{num...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
1872f1fd-e9be-5f4a-9ee5-067f01386ee6
docs
pytorch
pytorch_lstm
23
6
H\_{out} ={} & \text{proj\\_size if } \text{proj\\_size}>0 \text{ otherwise hidden\\_size} \\ \end{aligned} N=L=D=Hin​=Hcell​=Hout​=​batch sizesequence length2 if bidirectional=True otherwise 1input\_sizehidden\_sizeproj\_size if proj\_size>0 otherwise hidden\_size​ Outputs: output, (h\_n, ...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
821229e3-3896-5bbe-be8e-20710eaff223
docs
pytorch
pytorch_lstm
23
7
a concatenation of the forward and reverse hidden states at each time step in the sequence. * **h\_n**: tensor of shape (D∗num\_layers,Hout)(D \* \text{num\\_layers}, H\_{out})(D∗num\_layers,Hout​) for unbatched input or (D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_la...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
529e13eb-c537-596a-a5fd-108ef8eb7e6e
docs
pytorch
pytorch_lstm
23
8
: * **weight\_ih\_l[k]** – the learnable input-hidden weights of the kth\text{k}^{th}kth layer (W\_ii|W\_if|W\_ig|W\_io), of shape (4\*hidden\_size, input\_size) for k = 0. Otherwise, the shape is (4\*hidden\_size, num\_directions \* hidden\_size). If `proj_size > 0` was specified, t...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
5e0dc9d6-c8f2-5517-b6cf-dd284b254f6e
docs
pytorch
pytorch_lstm
23
9
* **weight\_hr\_l[k]** – the learnable projection weights of the kth\text{k}^{th}kth layer of shape (proj\_size, hidden\_size). Only present when `proj_size > 0` was specified. * **weight\_ih\_l[k]\_reverse** – Analogous to weight\_ih\_l[k] for the reverse direction. Only p...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
008fc87d-03e3-5898-b766-426b77e5b3e4
docs
pytorch
pytorch_lstm
23
10
All the weights and biases are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k})U(−k​,k​) where k=1hidden\_sizek = \frac{1}{\text{hidden\\_size}}k=hidden\_size1​ Note For bidirectional LSTMs, forward and backward are directions 0 and 1 respectively. Example of splitting the output layers wh...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
3da1ad51-1182-5860-8cca-9623f5da275c
docs
pytorch
pytorch_lstm
23
11
On CUDA 10.1, set environment variable `CUDA_LAUNCH_BLOCKING=1`. This may affect performance. On CUDA 10.2 or later, set environment variable (note the leading colon symbol) `CUBLAS_WORKSPACE_CONFIG=:16:8` or `CUBLAS_WORKSPACE_CONFIG=:4096:2`. See the [cuDNN 8 Release Notes](https://do...
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
5c1282be-8699-5852-b595-ce6671ae1886
docs
pytorch
pytorch_lstm
23
12
[![](../_static/images/chevron-right-orange.svg) Previous](torch.nn.RNN.html "RNN") --- © Copyright 2023, PyTorch Contributors. Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/lstm/lstm_23.md
17f3e27a-eafb-5e9f-990a-9c02bdc9f7b3
docs
pytorch
pytorch_lstm
24
0
# LSTM¶ Source: https://docs.pytorch.org/docs/2.4/generated/torch.nn.LSTM.html Version: 2.4 *class* torch.nn.LSTM(*input\_size*, *hidden\_size*, *num\_layers=1*, *bias=True*, *batch\_first=False*, *dropout=0.0*, *bidirectional=False*, *proj\_size=0*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn/modules...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
6d3e8246-0a56-593a-bdbc-2b62fd0c4959
docs
pytorch
pytorch_lstm
24
1
c\_t = f\_t \odot c\_{t-1} + i\_t \odot g\_t \\ h\_t = o\_t \odot \tanh(c\_t) \\ \end{array} it​=σ(Wii​xt​+bii​+Whi​ht−1​+bhi​)ft​=σ(Wif​xt​+bif​+Whf​ht−1​+bhf​)gt​=tanh(Wig​xt​+big​+Whg​ht−1​+bhg​)ot​=σ(Wio​xt​+bio​+Who​ht−1​+bho​)ct​=ft​⊙ct−1​+it​⊙gt​ht​=ot​⊙tanh(ct​)​ where hth\_tht​ is the hidd...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
993c1348-9b96-58ab-86b3-207ed86b10bd
docs
pytorch
pytorch_lstm
24
2
variable which is 000 with probability `dropout`. If `proj_size > 0` is specified, LSTM with projections will be used. This changes the LSTM cell in the following way. First, the dimension of hth\_tht​ will be changed from `hidden_size` to `proj_size` (dimensions of WhiW\_{hi}Whi​ will be changed accor...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
3fb19abb-9d62-5b23-970e-65fa320d059c
docs
pytorch
pytorch_lstm
24
3
would mean stacking two LSTMs together to form a stacked LSTM, with the second LSTM taking in outputs of the first LSTM and computing the final results. Default: 1 * **bias** – If `False`, then the layer does not use bias weights b\_ih and b\_hh. Default: `True` *...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
9ab5dcd3-2445-53d3-863f-85d4ba140f91
docs
pytorch
pytorch_lstm
24
4
Inputs: input, (h\_0, c\_0) : * **input**: tensor of shape (L,Hin)(L, H\_{in})(L,Hin​) for unbatched input, (L,N,Hin)(L, N, H\_{in})(L,N,Hin​) when `batch_first=False` or (N,L,Hin)(N, L, H\_{in})(N,L,Hin​) when `batch_first=True` containing the features of the input sequence. The...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
28a50e00-f2b9-59b7-931f-b2d4b4e6f386
docs
pytorch
pytorch_lstm
24
5
initial hidden state for each element in the input sequence. Defaults to zeros if (h\_0, c\_0) is not provided. * **c\_0**: tensor of shape (D∗num\_layers,Hcell)(D \* \text{num\\_layers}, H\_{cell})(D∗num\_layers,Hcell​) for unbatched input or (D∗num\_layers,N,Hcell)(D \* \text{num...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
50e19370-ac0d-5461-8791-8aead403bb6e
docs
pytorch
pytorch_lstm
24
6
H\_{out} ={} & \text{proj\\_size if } \text{proj\\_size}>0 \text{ otherwise hidden\\_size} \\ \end{aligned} N=L=D=Hin​=Hcell​=Hout​=​batch sizesequence length2 if bidirectional=True otherwise 1input\_sizehidden\_sizeproj\_size if proj\_size>0 otherwise hidden\_size​ Outputs: output, (h\_n, ...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
643f5a9e-0d53-52d4-b03f-6d18f839f8e9
docs
pytorch
pytorch_lstm
24
7
a concatenation of the forward and reverse hidden states at each time step in the sequence. * **h\_n**: tensor of shape (D∗num\_layers,Hout)(D \* \text{num\\_layers}, H\_{out})(D∗num\_layers,Hout​) for unbatched input or (D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_la...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
0873412f-a446-550f-be7c-9eea46515703
docs
pytorch
pytorch_lstm
24
8
: * **weight\_ih\_l[k]** – the learnable input-hidden weights of the kth\text{k}^{th}kth layer (W\_ii|W\_if|W\_ig|W\_io), of shape (4\*hidden\_size, input\_size) for k = 0. Otherwise, the shape is (4\*hidden\_size, num\_directions \* hidden\_size). If `proj_size > 0` was specified, t...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
7886a9fd-1c67-5bbc-940b-a194f65ae9ce
docs
pytorch
pytorch_lstm
24
9
* **weight\_hr\_l[k]** – the learnable projection weights of the kth\text{k}^{th}kth layer of shape (proj\_size, hidden\_size). Only present when `proj_size > 0` was specified. * **weight\_ih\_l[k]\_reverse** – Analogous to weight\_ih\_l[k] for the reverse direction. Only p...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
bdc84029-835b-5480-95f9-542f329811fb
docs
pytorch
pytorch_lstm
24
10
All the weights and biases are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k})U(−k​,k​) where k=1hidden\_sizek = \frac{1}{\text{hidden\\_size}}k=hidden\_size1​ Note For bidirectional LSTMs, forward and backward are directions 0 and 1 respectively. Example of splitting the output layers wh...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
111011c2-22ee-5e35-b977-92b8dd99d227
docs
pytorch
pytorch_lstm
24
11
On CUDA 10.1, set environment variable `CUDA_LAUNCH_BLOCKING=1`. This may affect performance. On CUDA 10.2 or later, set environment variable (note the leading colon symbol) `CUBLAS_WORKSPACE_CONFIG=:16:8` or `CUBLAS_WORKSPACE_CONFIG=:4096:2`. See the [cuDNN 8 Release Notes](https://do...
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
2f7231d8-cc01-59ae-948f-7a0f1e6543f2
docs
pytorch
pytorch_lstm
24
12
[![](../_static/images/chevron-right-orange.svg) Previous](torch.nn.RNN.html "RNN") --- © Copyright 2023, PyTorch Contributors. Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/lstm/lstm_24.md
d48b1e83-921a-53d5-bc34-f43a34fe97a1
docs
pytorch
pytorch_lstm
25
0
# LSTM¶ Source: https://docs.pytorch.org/docs/2.5/generated/torch.nn.LSTM.html Version: 2.5 *class* torch.nn.LSTM(*input\_size*, *hidden\_size*, *num\_layers=1*, *bias=True*, *batch\_first=False*, *dropout=0.0*, *bidirectional=False*, *proj\_size=0*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn/modules...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
95261e05-95d6-5bf2-83b5-04f718c4354a
docs
pytorch
pytorch_lstm
25
1
c\_t = f\_t \odot c\_{t-1} + i\_t \odot g\_t \\ h\_t = o\_t \odot \tanh(c\_t) \\ \end{array} it​=σ(Wii​xt​+bii​+Whi​ht−1​+bhi​)ft​=σ(Wif​xt​+bif​+Whf​ht−1​+bhf​)gt​=tanh(Wig​xt​+big​+Whg​ht−1​+bhg​)ot​=σ(Wio​xt​+bio​+Who​ht−1​+bho​)ct​=ft​⊙ct−1​+it​⊙gt​ht​=ot​⊙tanh(ct​)​ where hth\_tht​ is the hidd...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
2ee96faf-ef98-5292-a60f-d3f26669fff6
docs
pytorch
pytorch_lstm
25
2
variable which is 000 with probability `dropout`. If `proj_size > 0` is specified, LSTM with projections will be used. This changes the LSTM cell in the following way. First, the dimension of hth\_tht​ will be changed from `hidden_size` to `proj_size` (dimensions of WhiW\_{hi}Whi​ will be changed accor...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
830ae296-7247-5b5a-aeb8-283d62fd8912
docs
pytorch
pytorch_lstm
25
3
would mean stacking two LSTMs together to form a stacked LSTM, with the second LSTM taking in outputs of the first LSTM and computing the final results. Default: 1 * **bias** – If `False`, then the layer does not use bias weights b\_ih and b\_hh. Default: `True` *...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
3b82ae6d-8ffd-539d-93bb-145c20510a69
docs
pytorch
pytorch_lstm
25
4
Inputs: input, (h\_0, c\_0) : * **input**: tensor of shape (L,Hin)(L, H\_{in})(L,Hin​) for unbatched input, (L,N,Hin)(L, N, H\_{in})(L,N,Hin​) when `batch_first=False` or (N,L,Hin)(N, L, H\_{in})(N,L,Hin​) when `batch_first=True` containing the features of the input sequence. The...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
c10d9e64-5b65-583d-959a-654614220ab6
docs
pytorch
pytorch_lstm
25
5
initial hidden state for each element in the input sequence. Defaults to zeros if (h\_0, c\_0) is not provided. * **c\_0**: tensor of shape (D∗num\_layers,Hcell)(D \* \text{num\\_layers}, H\_{cell})(D∗num\_layers,Hcell​) for unbatched input or (D∗num\_layers,N,Hcell)(D \* \text{num...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
11a7bd19-e425-580a-9780-a104574f8420
docs
pytorch
pytorch_lstm
25
6
H\_{out} ={} & \text{proj\\_size if } \text{proj\\_size}>0 \text{ otherwise hidden\\_size} \\ \end{aligned} N=L=D=Hin​=Hcell​=Hout​=​batch sizesequence length2 if bidirectional=True otherwise 1input\_sizehidden\_sizeproj\_size if proj\_size>0 otherwise hidden\_size​ Outputs: output, (h\_n, ...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
f1dc8272-170a-52f2-a8a9-f2687866ce5c
docs
pytorch
pytorch_lstm
25
7
a concatenation of the forward and reverse hidden states at each time step in the sequence. * **h\_n**: tensor of shape (D∗num\_layers,Hout)(D \* \text{num\\_layers}, H\_{out})(D∗num\_layers,Hout​) for unbatched input or (D∗num\_layers,N,Hout)(D \* \text{num\\_layers}, N, H\_{out})(D∗num\_la...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
4afce965-d5ab-58c8-9b32-f069039f3977
docs
pytorch
pytorch_lstm
25
8
: * **weight\_ih\_l[k]** – the learnable input-hidden weights of the kth\text{k}^{th}kth layer (W\_ii|W\_if|W\_ig|W\_io), of shape (4\*hidden\_size, input\_size) for k = 0. Otherwise, the shape is (4\*hidden\_size, num\_directions \* hidden\_size). If `proj_size > 0` was specified, t...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
b0916303-0caa-5f88-8f91-0fca77484df2
docs
pytorch
pytorch_lstm
25
9
* **weight\_hr\_l[k]** – the learnable projection weights of the kth\text{k}^{th}kth layer of shape (proj\_size, hidden\_size). Only present when `proj_size > 0` was specified. * **weight\_ih\_l[k]\_reverse** – Analogous to weight\_ih\_l[k] for the reverse direction. Only p...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
55c2fd83-f267-5e09-9abe-3c3dfd4e783c
docs
pytorch
pytorch_lstm
25
10
All the weights and biases are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k})U(−k​,k​) where k=1hidden\_sizek = \frac{1}{\text{hidden\\_size}}k=hidden\_size1​ Note For bidirectional LSTMs, forward and backward are directions 0 and 1 respectively. Example of splitting the output layers wh...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
b5a62112-0667-5048-a368-45234eb34e3d
docs
pytorch
pytorch_lstm
25
11
On CUDA 10.1, set environment variable `CUDA_LAUNCH_BLOCKING=1`. This may affect performance. On CUDA 10.2 or later, set environment variable (note the leading colon symbol) `CUBLAS_WORKSPACE_CONFIG=:16:8` or `CUBLAS_WORKSPACE_CONFIG=:4096:2`. See the [cuDNN 8 Release Notes](https://do...
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
a4b52981-50fa-511f-8dfe-748a6ce25bbd
docs
pytorch
pytorch_lstm
25
12
[![](../_static/images/chevron-right-orange.svg) Previous](torch.nn.RNN.html "RNN") --- © Copyright 2023, PyTorch Contributors. Built with [Sphinx](http://sphinx-doc.org/) using a [theme](https://github.com/rtfd/sphinx_rtd_theme) provided by [Read the Docs](https://readthedocs.org).
large_dataset/raw/docs/pytorch/lstm/lstm_25.md
d37b2a32-91ce-5921-bd74-49d0fcf45ed5
docs
pytorch
pytorch_lstm
26
0
# LSTM¶ Source: https://docs.pytorch.org/docs/2.6/generated/torch.nn.LSTM.html Version: 2.6 *class* torch.nn.LSTM(*input\_size*, *hidden\_size*, *num\_layers=1*, *bias=True*, *batch\_first=False*, *dropout=0.0*, *bidirectional=False*, *proj\_size=0*, *device=None*, *dtype=None*)[[source]](../_modules/torch/nn/modules...
large_dataset/raw/docs/pytorch/lstm/lstm_26.md
52c46c75-9499-5e6e-99a5-61526a04ba7d
docs
pytorch
pytorch_lstm
26
1
g\_t = \tanh(W\_{ig} x\_t + b\_{ig} + W\_{hg} h\_{t-1} + b\_{hg}) \\ o\_t = \sigma(W\_{io} x\_t + b\_{io} + W\_{ho} h\_{t-1} + b\_{ho}) \\ c\_t = f\_t \odot c\_{t-1} + i\_t \odot g\_t \\ h\_t = o\_t \odot \tanh(c\_t) \\ \end{array} it​=σ(Wii​xt​+bii​+Whi​ht−1​+bhi​)ft​=σ(Wif​xt​+bif​+Whf​ht−1​+b...
large_dataset/raw/docs/pytorch/lstm/lstm_26.md
edbba3c5-58e6-5d53-8cef-e387c2d9149f
docs
pytorch
pytorch_lstm
26
2
(l≥2l \ge 2l≥2) is the hidden state ht(l−1)h^{(l-1)}\_tht(l−1)​ of the previous layer multiplied by dropout δt(l−1)\delta^{(l-1)}\_tδt(l−1)​ where each δt(l−1)\delta^{(l-1)}\_tδt(l−1)​ is a Bernoulli random variable which is 000 with probability `dropout`. If `proj_size > 0` is specified, LSTM with pro...
large_dataset/raw/docs/pytorch/lstm/lstm_26.md
ae0121d0-44eb-5814-988b-d720c159bc39
docs
pytorch
pytorch_lstm
26
3
* **hidden\_size** – The number of features in the hidden state h * **num\_layers** – Number of recurrent layers. E.g., setting `num_layers=2` would mean stacking two LSTMs together to form a stacked LSTM, with the second LSTM taking in outputs of the first LSTM and computi...
large_dataset/raw/docs/pytorch/lstm/lstm_26.md
fb149db1-a647-5226-b927-e27a1527b725
docs
pytorch
pytorch_lstm
26
4
* **bidirectional** – If `True`, becomes a bidirectional LSTM. Default: `False` * **proj\_size** – If `> 0`, will use LSTM with projections of corresponding size. Default: 0 Inputs: input, (h\_0, c\_0) : * **input**: tensor of shape (L,Hin)(L, H\_{in})(L,Hin​) for unbatched input, (...
large_dataset/raw/docs/pytorch/lstm/lstm_26.md