public struct TensorVisitorPlan<Base>
TensorVisitorPlan は[WritableKeyPath<Base, Tensor<Float>]
を近似しますが、より効率的です。これは、勾配、既存の重み、補助的に保存された重みを見つけるために使用できるインデックスをマッピングする汎用オプティマイザーを作成する場合に便利です。これは若干効率的 (~2 倍) ですが、個々の KeyPath を追跡するために単純なリストで必要とされる O( Depth_of_tree) 作業を実行する必要がないため、わずかに高いオーバーヘッド (追加のポインタ逆参照) をトレードオフするため、より良い可能性があります。
計画を単一の
[WritableKeyPath<Base, Tensor<Float>]
としてフラット化します。宣言
public var allTensorKeyPaths: [WritableKeyPath<Base, Tensor<Float>>] { get }
すべてのテンソルを効率的に収集します。
宣言
public func allTensors(_ v: Base) -> [Tensor<Float>]
宣言
func populateMask<Base>(_ mask: inout [Bool], _ kp: WritableKeyPath<Base, Tensor<Float>>)
特定のキーパスで終わるすべてのキーを検索します。
宣言
public func keysEnding<Base>(with kp: WritableKeyPath<Base, Tensor<Float>>) -> [Bool]
宣言
func findFirstIndex<TrueBase, T>( _ rootKeyPath: WritableKeyPath<TrueBase, Base>, _ prefix: WritableKeyPath<TrueBase, T>, _ i: inout Int ) -> Bool
特定のプレフィックスで始まる最初のキーパスのインデックスを見つけます。注: すべての配列レイヤーは、1-past-the-end インデックス付けをサポートしています。
宣言
func firstIndex<T>(withPrefix prefix: WritableKeyPath<Base, T>) -> Int
2 つの KeyPath プレフィックスで定義された範囲内のすべてのキー インデックスを検索します: [ lower, upper)
宣言
public func allKeysBetween<T, U>(lower: WritableKeyPath<Base, T>, upper: WritableKeyPath<Base, U>) -> [Bool]
Base
の特定のインスタンス内のすべてのテンソルを訪問する計画を作成します。この計画は、構造的に同等のバージョンの Base に移行できます。宣言
public init(_ obj: Base)