(rontolisp) docs
← 関数

torch:linear

(torch:linear in-features out-features &key bias)

全結合レイヤー (PyTorch の nn.Linear) を返します。フィールド :weight(in-features out-features) のパラメータ、:bias(out-features) のパラメータ (:bias nil では nil) です。順伝播は x . W (+ b) なので、バイアスは先行するすべての軸にブロードキャストし、ランク 3 の入力はバッチごとに変換されます。

どちらのパラメータも PyTorch のデフォルトである U(-1/sqrt(in-features), 1/sqrt(in-features)) から、シード可能な linalg:seed の生成器で引かれます。シードを固定した実行はどのバックエンドでも再現します。重みは PyTorch の転置形 (out in) ではなく (in out) で保持するため、順伝播は素の torch:matmul です。