Model
public class Model
A model is a base class for stateful operations on a dynamic graph. It can be use to construct computations statically, thus, more efficient.
-
A IO class represent the abstract input / output for a model. It can correspond to one or more tensors when the model is materialized.
See moreDeclaration
Swift
public class IO : ModelIOConvertible
-
Whether the existing model is for testing or training.
Declaration
Swift
public var testing: Bool
-
Declaration
Swift
public let cModel: OpaquePointer
-
Declaration
Swift
@inlinable public func callAsFunction(_ inputs: ModelIOConvertible...) -> IO
-
Declaration
Swift
@inlinable public func callAsFunction(_ inputs: [ModelIOConvertible]) -> IO
-
Declaration
-
Abstract representation of the stateful components from the model.
Declaration
Swift
public var parameters: Parameters { get }
-
Shortcut for weight parameter.
Declaration
Swift
public var weight: Parameters { get }
-
Shortcut for bias parameter.
Declaration
Swift
public var bias: Parameters { get }
-
Whether this is initialized as trainable model or not.
Declaration
Swift
public var trainable: Bool? { get }
-
Setting the directory for parameters to be backed by files.
Declaration
Swift
public var directoryForFileBackedParameters: String? { get set }
-
Declaration
Swift
public var maxConcurrency: StreamContext.Concurrency { get set }
-
Declaration
Swift
public enum ParametersType
-
Broadly speaking, you can have two types of parameters, weight and bias. You can get them in abstract fashion with this method.
Declaration
Swift
public func parameters(for type: ParametersType) -> Parameters
Parameters
type
Whether it is weight or bias.
Return Value
An abstract representation of parameters.
-
Declaration
Swift
public func callAsFunction<T: DynamicGraph.AnyTensorGroup>( inputs firstInput: T, _ restInputs: [DynamicGraph_Any], streamContext: StreamContext? = nil ) -> [T.AnyTensor]
-
Declaration
Swift
public func callAsFunction<T: DynamicGraph.AnyTensorGroup>( inputs firstInput: T, _ restInputs: DynamicGraph_Any..., streamContext: StreamContext? = nil ) -> [T.AnyTensor]
-
Make a copy of the model. This won’t copy over the parameters. If you want, you need to copy parameters over explicitly.
Declaration
Swift
public func copied() -> Self
-
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])
-
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...)
-
You can compose a new model from old models when applying IO on them.
Declaration
Parameters
inputs
The input IOs for the new model, usually it is some set of Input objects.
outputs
The output IOs for the new model, usually it is outputs of some other models.
name
The name of the new model.
-
You can compose a new model of a list of models assuming one’s output is another’s input.
Declaration
Swift
public convenience init(_ models: [Model], trainable: Bool? = nil, name: String = "")
Parameters
models
The array of models.
name
The name of the new model.