ModelBuilder
public final class ModelBuilder<T> : AnyModelBuilder
A model builder is a more generic type of model. A model can be quite static, thus, you have to be quite careful to have a model work with dynamic inputs. You cannot use reshape, or anything that can generate fixed tensor outputs from a fixed inputs.
A model builder on the other hand doesn’t have that restriction. When input changes, it simply calls the given builder closure to construct a new model. In such way, you can continue to use reshape etc to assume fixed inputs and outputs, it will just work for dynamic inputs. The newly built model will carry over stateful components (parameters) from the old models, thus, it doesn’t reset your training. This also means you need to make sure parameter shape won’t change when input changes, otherwise we will fatal.
-
Declaration
Swift
public init(_ builder: @escaping (T, [DynamicGraph_Any]) -> Model, name: String = "")
-
Compile a model with the given inputs without executing it. After this, you can load parameters from the store.
Declaration
Swift
public func compile(_ t: T, inputs: [DynamicGraph_Any], isEager: Bool = false)
-
Compile a model with the given inputs without executing it. After this, you can load parameters from the store.
Declaration
Swift
public func compile(_ t: T, inputs: DynamicGraph_Any..., isEager: Bool = false)
-
Declaration
Swift
public func callAsFunction<U: DynamicGraph.AnyTensorGroup>( _ t: T, inputs firstInput: U, _ restInputs: [DynamicGraph_Any], streamContext: StreamContext? = nil ) -> [U.AnyTensor]
-
Declaration
Swift
public func callAsFunction<U: DynamicGraph.AnyTensorGroup>( _ t: T, inputs firstInput: U, _ restInputs: DynamicGraph_Any..., streamContext: StreamContext? = nil ) -> [U.AnyTensor]
-
Declaration
Swift
public func callAsFunction<U: DynamicGraph.AnyTensorGroup>( inputs firstInput: U, _ restInputs: [DynamicGraph_Any], streamContext: StreamContext? = nil ) -> [U.AnyTensor]
-
Declaration
Swift
public func callAsFunction<U: DynamicGraph.AnyTensorGroup>( inputs firstInput: U, _ restInputs: DynamicGraph_Any..., streamContext: StreamContext? = nil ) -> [U.AnyTensor]
-
Declaration
Swift
public convenience init(_ builder: @escaping ([DynamicGraph_Any]) -> Model, name: String = "")
-
Compile a model with the given inputs without executing it. After this, you can load parameters from the store.
Declaration
Swift
public func compile(inputs: [DynamicGraph_Any], isEager: Bool = false)
-
Compile a model with the given inputs without executing it. After this, you can load parameters from the store.
Declaration
Swift
public func compile(inputs: DynamicGraph_Any..., isEager: Bool = false)