public protocol Layer : Module where Self.Input : Differentiable
ニューラルネットワーク層。
Layer
準拠するタイプは、入力を出力にマップする関数を表します。それらは、重みテンソルなどのパラメーターによって表される内部状態を持っている場合があります。
Layer
インスタンスは、入力を出力にマッピングするための微分可能なcallAsFunction(_:)
メソッドを定義します。
指定された入力にレイヤーを適用して得られた出力を返します。
宣言
@differentiable func callAsFunction(_ input: Input) -> Output
パラメーター
input
レイヤーへの入力。
戻り値
出力。
デフォルトの実装
宣言
@differentiable func forward(_ input: Input) -> Output
指定された入力にレイヤーを適用して得られた推論出力を返します。
宣言
public func inferring(from input: Input) -> Output
パラメーター
input
レイヤーへの入力。
戻り値
推論出力。
宣言
public typealias Backpropagator = (_ direction: Output.TangentVector) -> (layerGradient: TangentVector, inputGradient: Input.TangentVector)
指定された入力にレイヤーを適用して得られた推論出力とバックプロパゲーション関数を返します。
宣言
public func appliedForBackpropagation(to input: Input) -> (output: Output, backpropagator: Backpropagator)
パラメーター
input
レイヤーへの入力。
戻り値
出力とバックプロパゲーション関数を含むタプル。バックプロパゲーション関数(別名バックプロパゲーション)は方向ベクトルを取り、レイヤーと入力でそれぞれ勾配を返します。
デフォルトの実装
宣言
@differentiable(wrt: self) @differentiable public func callAsFunction(_ input: Input) -> Output