Model

public class Model
extension Model: Hashable

A model is a base class for stateful operations on a dynamic graph. It can be use to construct computations statically, thus, more efficient.

  • IO

    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 more

    Declaration

    Swift

    public class IO
  • Whether the existing model is for testing or training.

    Declaration

    Swift

    public var isTest: Bool
  • Undocumented

    Declaration

    Swift

    public func callAsFunction(_ inputs: IO...) -> IO
  • Undocumented

    Declaration

    Swift

    public final class Parameters : IO
    extension Model.Parameters: DynamicGraph_AnyParameters
  • Abstract representation of the stateful components from the model.

    Declaration

    Swift

    public var parameters: Parameters { get }
  • Undocumented

    See more

    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.

  • Undocumented

    Declaration

    Swift

    public func callAsFunction<T: DynamicGraph.AnyTensorGroup>(
      inputs firstInput: T, _ restInputs: [DynamicGraph_Any], streamContext: StreamContext? = nil
    ) -> [T.AnyTensor]
  • Undocumented

    Declaration

    Swift

    public func callAsFunction<T: DynamicGraph.AnyTensorGroup>(
      inputs firstInput: T, _ restInputs: DynamicGraph_Any..., streamContext: StreamContext? = nil
    ) -> [T.AnyTensor]
  • You can compose a new model from old models when applying IO on them.

    Declaration

    Swift

    public convenience init(_ inputs: [IO], _ outputs: [IO], name: String = "")

    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], name: String = "")

    Parameters

    models

    The array of models.

    name

    The name of the new model.

  • Declaration

    Swift

    public static func == (lhs: Model, rhs: Model) -> Bool
  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)