レイヤ

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

    レイヤーへの入力。

    戻り値

    出力とバックプロパゲーション関数を含むタプル。バックプロパゲーション関数 (別名バックプロパゲータ) は方向ベクトルを受け取り、それぞれ層と入力の勾配を返します。

`入力`: `DifferentiableTensorProtocol`、`出力`: `DifferentiableTensorProtocol` で利用可能です。
  • callAsFunction(_:)デフォルトの実装

    デフォルトの実装

    宣言

    @differentiable(wrt: self)
    @differentiable
    public func callAsFunction(_ input: Input) -> Output