プリンキピア

第23章付録:深層学習のための道具

23.8.1. Classes23.8.1 クラス

class d2l.torch.AdditiveAttention(num_hiddens, dropout, **kwargs)
Bases: Module
英語のヒント
基底クラス:Module
Additive attention.
英語のヒント
加法注意。
Defined in Section 11.3.2.2
英語のヒント
11.3.2.2節で定義
forward(queries, keys, values, valid_lens)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.AddNorm(norm_shape, dropout)
Bases: Module
英語のヒント
基底クラス:Module
The residual connection followed by layer normalization.
英語のヒント
残差接続とその後の層正規化。
Defined in Section 11.7.2
英語のヒント
11.7.2節で定義
forward(X, Y)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.AttentionDecoder
Bases: Decoder
英語のヒント
基底クラス:Decoder
The base attention-based decoder interface.
英語のヒント
注意機構にもとづくデコーダの基底インターフェース。
Defined in Section 11.4
英語のヒント
11.4節で定義
property attention_weights
class d2l.torch.Classifier(plot_train_per_epoch=2, plot_valid_per_epoch=1)
Bases: Module
英語のヒント
基底クラス:Module
The base class of classification models.
英語のヒント
分類モデルの基底クラス。
Defined in Section 4.3
英語のヒント
4.3節で定義
accuracy(Y_hat, Y, averaged=True)
Compute the number of correct predictions.
英語のヒント
正しい予測の数を計算する。
Defined in Section 4.3
英語のヒント
4.3節で定義
layer_summary(X_shape)
Defined in Section 7.6
英語のヒント
7.6節で定義
loss(Y_hat, Y, averaged=True)
Defined in Section 4.5
英語のヒント
4.5節で定義
validation_step(batch)
class d2l.torch.DataModule(root='../data', num_workers=4)
英語のヒント
基底クラス:HyperParameters
The base class of data.
英語のヒント
データの基底クラス。
Defined in Section 3.2.2
英語のヒント
3.2.2節で定義
get_dataloader(train)
get_tensorloader(tensors, train, indices=slice(0, None, None))
Defined in Section 3.3
英語のヒント
3.3節で定義
train_dataloader()
val_dataloader()
class d2l.torch.Decoder
Bases: Module
英語のヒント
基底クラス:Module
The base decoder interface for the encoder–decoder architecture.
英語のヒント
エンコーダ・デコーダ構造のためのデコーダの基底インターフェース。
Defined in Section 10.6
英語のヒント
10.6節で定義
forward(X, state)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
init_state(enc_all_outputs, *args)
class d2l.torch.DotProductAttention(dropout)
Bases: Module
英語のヒント
基底クラス:Module
Scaled dot product attention.
英語のヒント
スケール化内積注意。
Defined in Section 11.3.2.2
英語のヒント
11.3.2.2節で定義
forward(queries, keys, values, valid_lens=None)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.Encoder
Bases: Module
英語のヒント
基底クラス:Module
The base encoder interface for the encoder–decoder architecture.
英語のヒント
エンコーダ・デコーダ構造のためのエンコーダの基底インターフェース。
Defined in Section 10.6
英語のヒント
10.6節で定義
forward(X, *args)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.EncoderDecoder(encoder, decoder)
Bases: Classifier
英語のヒント
基底クラス:Classifier
The base class for the encoder–decoder architecture.
英語のヒント
エンコーダ・デコーダ構造のための基底クラス。
Defined in Section 10.6
英語のヒント
10.6節で定義
forward(enc_X, dec_X, *args)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
predict_step(batch, device, num_steps, save_attention_weights=False)
Defined in Section 10.7.6
英語のヒント
10.7.6節で定義
class d2l.torch.FashionMNIST(batch_size=64, resize=(28, 28))
Bases: DataModule
英語のヒント
基底クラス:DataModule
The Fashion-MNIST dataset.
英語のヒント
Fashion-MNISTのデータセット。
Defined in Section 4.2
英語のヒント
4.2節で定義
get_dataloader(train)
Defined in Section 4.2
英語のヒント
4.2節で定義
text_labels(indices)
Return text labels.
英語のヒント
テキストのラベルを返す。
Defined in Section 4.2
英語のヒント
4.2節で定義
visualize(batch, nrows=1, ncols=8, labels=[])
Defined in Section 4.2
英語のヒント
4.2節で定義
class d2l.torch.GRU(num_inputs, num_hiddens, num_layers, dropout=0)
Bases: RNN
英語のヒント
基底クラス:RNN
The multilayer GRU model.
英語のヒント
多層のGRUモデル。
Defined in Section 10.3
英語のヒント
10.3節で定義
class d2l.torch.HyperParameters
Bases: object
英語のヒント
基底クラス:object
The base class of hyperparameters.
英語のヒント
ハイパーパラメータの基底クラス。
save_hyperparameters(ignore=[])
Save function arguments into class attributes.
英語のヒント
関数の引数をクラスの属性に保存する。
Defined in Section 23.7
英語のヒント
23.7節で定義
class d2l.torch.LeNet(lr=0.1, num_classes=10)
Bases: Classifier
英語のヒント
基底クラス:Classifier
The LeNet-5 model.
英語のヒント
LeNet-5のモデル。
Defined in Section 7.6
英語のヒント
7.6節で定義
class d2l.torch.LinearRegression(lr)
Bases: Module
英語のヒント
基底クラス:Module
The linear regression model implemented with high-level APIs.
英語のヒント
高水準のAPIで実装した線形回帰のモデル。
Defined in Section 3.5
英語のヒント
3.5節で定義
configure_optimizers()
Defined in Section 3.5
英語のヒント
3.5節で定義
forward(X)
Defined in Section 3.5
英語のヒント
3.5節で定義
get_w_b()
Defined in Section 3.5
英語のヒント
3.5節で定義
loss(y_hat, y)
Defined in Section 3.5
英語のヒント
3.5節で定義
class d2l.torch.LinearRegressionScratch(num_inputs, lr, sigma=0.01)
Bases: Module
英語のヒント
基底クラス:Module
The linear regression model implemented from scratch.
英語のヒント
ゼロから実装した線形回帰のモデル。
Defined in Section 3.4
英語のヒント
3.4節で定義
configure_optimizers()
Defined in Section 3.4
英語のヒント
3.4節で定義
forward(X)
Defined in Section 3.4
英語のヒント
3.4節で定義
loss(y_hat, y)
Defined in Section 3.4
英語のヒント
3.4節で定義
class d2l.torch.Module(plot_train_per_epoch=2, plot_valid_per_epoch=1)
Bases: Module, HyperParameters
英語のヒント
基底クラス:Module、HyperParameters
The base class of models.
英語のヒント
モデルの基底クラス。
Defined in Section 3.2
英語のヒント
3.2節で定義
apply_init(inputs, init=None)
Defined in Section 6.4
英語のヒント
6.4節で定義
configure_optimizers()
Defined in Section 4.3
英語のヒント
4.3節で定義
forward(X)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
loss(y_hat, y)
plot(key, value, train)
Plot a point in animation.
英語のヒント
アニメーションで点をプロットする。
training_step(batch)
validation_step(batch)
class d2l.torch.MTFraEng(batch_size, num_steps=9, num_train=512, num_val=128)
Bases: DataModule
英語のヒント
基底クラス:DataModule
The English-French dataset.
英語のヒント
英語・フランス語のデータセット。
Defined in Section 10.5
英語のヒント
10.5節で定義
build(src_sentences, tgt_sentences)
Defined in Section 10.5.3
英語のヒント
10.5.3節で定義
get_dataloader(train)
Defined in Section 10.5.3
英語のヒント
10.5.3節で定義
class d2l.torch.MultiHeadAttention(num_hiddens, num_heads, dropout, bias=False, **kwargs)
Bases: Module
英語のヒント
基底クラス:Module
Multi-head attention.
英語のヒント
マルチヘッド注意。
Defined in Section 11.5
英語のヒント
11.5節で定義
forward(queries, keys, values, valid_lens)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
transpose_output(X)
Reverse the operation of transpose_qkv.
英語のヒント
transpose_qkvの演算を逆にする。
Defined in Section 11.5
英語のヒント
11.5節で定義
transpose_qkv(X)
Transposition for parallel computation of multiple attention heads.
英語のヒント
複数の注意ヘッドを並列に計算するための転置。
Defined in Section 11.5
英語のヒント
11.5節で定義
class d2l.torch.PositionalEncoding(num_hiddens, dropout, max_len=1000)
Bases: Module
英語のヒント
基底クラス:Module
Positional encoding.
英語のヒント
位置符号化。
Defined in Section 11.6
英語のヒント
11.6節で定義
forward(X)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.PositionWiseFFN(ffn_num_hiddens, ffn_num_outputs)
Bases: Module
英語のヒント
基底クラス:Module
The positionwise feed-forward network.
英語のヒント
位置ごとのフィードフォワードネットワーク。
Defined in Section 11.7
英語のヒント
11.7節で定義
forward(X)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.ProgressBoard(xlabel=None, ylabel=None, xlim=None, ylim=None, xscale='linear', yscale='linear', ls=['-', '--', '-.', ':'], colors=['C0', 'C1', 'C2', 'C3'], fig=None, axes=None, figsize=(3.5, 2.5), display=True)
英語のヒント
基底クラス:HyperParameters
The board that plots data points in animation.
英語のヒント
データ点をアニメーションでプロットするボード。
Defined in Section 3.2
英語のヒント
3.2節で定義
draw(x, y, label, every_n=1)
Defined in Section 23.7
英語のヒント
23.7節で定義
class d2l.torch.Residual(num_channels, use_1x1conv=False, strides=1)
Bases: Module
英語のヒント
基底クラス:Module
The Residual block of ResNet models.
英語のヒント
ResNetのモデルの残差ブロック。
Defined in Section 8.6
英語のヒント
8.6節で定義
forward(X)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.ResNeXtBlock(num_channels, groups, bot_mul, use_1x1conv=False, strides=1)
Bases: Module
英語のヒント
基底クラス:Module
The ResNeXt block.
英語のヒント
ResNeXtブロック。
Defined in Section 8.6.2
英語のヒント
8.6.2節で定義
forward(X)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.RNN(num_inputs, num_hiddens)
Bases: Module
英語のヒント
基底クラス:Module
The RNN model implemented with high-level APIs.
英語のヒント
高水準のAPIで実装したRNNのモデル。
Defined in Section 9.6
英語のヒント
9.6節で定義
forward(inputs, H=None)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.RNNLM(rnn, vocab_size, lr=0.01)
英語のヒント
基底クラス:RNNLMScratch
The RNN-based language model implemented with high-level APIs.
英語のヒント
高水準のAPIで実装したRNNベースの言語モデル。
Defined in Section 9.6
英語のヒント
9.6節で定義
init_params()
output_layer(hiddens)
Defined in Section 9.5
英語のヒント
9.5節で定義
class d2l.torch.RNNLMScratch(rnn, vocab_size, lr=0.01)
Bases: Classifier
英語のヒント
基底クラス:Classifier
The RNN-based language model implemented from scratch.
英語のヒント
ゼロから実装したRNNベースの言語モデル。
Defined in Section 9.5
英語のヒント
9.5節で定義
forward(X, state=None)
Defined in Section 9.5
英語のヒント
9.5節で定義
init_params()
one_hot(X)
Defined in Section 9.5
英語のヒント
9.5節で定義
output_layer(rnn_outputs)
Defined in Section 9.5
英語のヒント
9.5節で定義
predict(prefix, num_preds, vocab, device=None)
Defined in Section 9.5
英語のヒント
9.5節で定義
training_step(batch)
validation_step(batch)
class d2l.torch.RNNScratch(num_inputs, num_hiddens, sigma=0.01)
Bases: Module
英語のヒント
基底クラス:Module
The RNN model implemented from scratch.
英語のヒント
ゼロから実装したRNNのモデル。
Defined in Section 9.5
英語のヒント
9.5節で定義
forward(inputs, state=None)
Defined in Section 9.5
英語のヒント
9.5節で定義
class d2l.torch.Seq2Seq(encoder, decoder, tgt_pad, lr)
英語のヒント
基底クラス:EncoderDecoder
The RNN encoder–decoder for sequence to sequence learning.
英語のヒント
系列から系列への学習のためのRNNエンコーダ・デコーダ。
Defined in Section 10.7.3
英語のヒント
10.7.3節で定義
configure_optimizers()
Defined in Section 4.3
英語のヒント
4.3節で定義
validation_step(batch)
class d2l.torch.Seq2SeqEncoder(vocab_size, embed_size, num_hiddens, num_layers, dropout=0)
Bases: Encoder
英語のヒント
基底クラス:Encoder
The RNN encoder for sequence-to-sequence learning.
英語のヒント
系列から系列への学習のためのRNNエンコーダ。
Defined in Section 10.7
英語のヒント
10.7節で定義
forward(X, *args)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.SGD(params, lr)
英語のヒント
基底クラス:HyperParameters
Minibatch stochastic gradient descent.
英語のヒント
ミニバッチ確率的勾配降下法。
Defined in Section 3.4
英語のヒント
3.4節で定義
step()
zero_grad()
class d2l.torch.SoftmaxRegression(num_outputs, lr)
Bases: Classifier
英語のヒント
基底クラス:Classifier
The softmax regression model.
英語のヒント
ソフトマックス回帰のモデル。
Defined in Section 4.5
英語のヒント
4.5節で定義
forward(X)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.SyntheticRegressionData(w, b, noise=0.01, num_train=1000, num_val=1000, batch_size=32)
Bases: DataModule
英語のヒント
基底クラス:DataModule
Synthetic data for linear regression.
英語のヒント
線形回帰のための合成データ。
Defined in Section 3.3
英語のヒント
3.3節で定義
get_dataloader(train)
Defined in Section 3.3
英語のヒント
3.3節で定義
class d2l.torch.TimeMachine(batch_size, num_steps, num_train=10000, num_val=5000)
Bases: DataModule
英語のヒント
基底クラス:DataModule
The Time Machine dataset.
英語のヒント
『タイム・マシン』のデータセット。
Defined in Section 9.2
英語のヒント
9.2節で定義
build(raw_text, vocab=None)
Defined in Section 9.2
英語のヒント
9.2節で定義
get_dataloader(train)
Defined in Section 9.3.3
英語のヒント
9.3.3節で定義
class d2l.torch.Trainer(max_epochs, num_gpus=0, gradient_clip_val=0)
英語のヒント
基底クラス:HyperParameters
The base class for training models with data.
英語のヒント
データでモデルを訓練するための基底クラス。
Defined in Section 3.2.2
英語のヒント
3.2.2節で定義
clip_gradients(grad_clip_val, model)
Defined in Section 9.5
英語のヒント
9.5節で定義
fit(model, data)
fit_epoch()
Defined in Section 3.4
英語のヒント
3.4節で定義
prepare_batch(batch)
Defined in Section 6.7
英語のヒント
6.7節で定義
prepare_data(data)
prepare_model(model)
Defined in Section 6.7
英語のヒント
6.7節で定義
class d2l.torch.TransformerEncoder(vocab_size, num_hiddens, ffn_num_hiddens, num_heads, num_blks, dropout, use_bias=False)
Bases: Encoder
英語のヒント
基底クラス:Encoder
The Transformer encoder.
英語のヒント
Transformerのエンコーダ。
Defined in Section 11.7.4
英語のヒント
11.7.4節で定義
forward(X, valid_lens)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.TransformerEncoderBlock(num_hiddens, ffn_num_hiddens, num_heads, dropout, use_bias=False)
Bases: Module
英語のヒント
基底クラス:Module
The Transformer encoder block.
英語のヒント
Transformerのエンコーダブロック。
Defined in Section 11.7.2
英語のヒント
11.7.2節で定義
forward(X, valid_lens)
Defines the computation performed at every call.
英語のヒント
呼び出しのたびに実行される計算を定義する。
Should be overridden by all subclasses.
英語のヒント
すべてのサブクラスでオーバーライドされるべきである。

Note注意

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
英語のヒント
順伝播の手順はこの関数の中で定義する必要があるが、その後はこの関数ではなくModuleのインスタンスを呼び出すべきである。前者は登録されたフックの実行を引き受けるが、後者はそれらを黙って無視するからである。
class d2l.torch.Vocab(tokens=[], min_freq=0, reserved_tokens=[])
Bases: object
英語のヒント
基底クラス:object
Vocabulary for text.
英語のヒント
テキストのための語彙。
to_tokens(indices)
property unk