Parameters

public final class Parameters : IO
extension Model.Parameters: DynamicGraph_AnyParameters
  • The internal name for this parameter.

    Declaration

    Swift

    public var name: String { get }
  • Copy parameters from one model to another.

    Declaration

    Swift

    public func copy(from parameters: Model.Parameters)

    Parameters

    parameters

    The parameters of another model, it must match the parameters copy to.

  • Copy parameters from a tensor.

    Declaration

    Swift

    public func copy(from tensor: AnyTensor)

    Parameters

    tensor

    The tensor contains some values, it must match the parameters copy to.

  • Copy parameters from a tensor.

    Declaration

    Swift

    public func copy<Element>(from tensor: DynamicGraph.Tensor<Element>) where Element : TensorNumeric

    Parameters

    tensor

    The tensor contains some values, it must match the parameters copy to.

  • Copy parameters to a tensor.

    Declaration

    Swift

    public func copy(to tensor: AnyTensor)

    Parameters

    tensor

    The tensor to copy to, it must match the parameters copy from.

  • Copy parameter out into a tensor.

    Declaration

    Swift

    public func copied<Element>(_ type: Element.Type = Element.self) -> Tensor<Element> where Element : TensorNumeric

    Parameters

    type

    The element type of a tensor.

  • Copy parameters to a tensor.

    Declaration

    Swift

    public func copy<Element>(to tensor: DynamicGraph.Tensor<Element>) where Element : TensorNumeric

    Parameters

    tensor

    The tensor to copy to, it must match the parameters copy from.

  • Declaration

    Swift

    public enum ModelParametersShareResult
  • Share parameters from another model. This is a specific memory optimization.

    Declaration

    Swift

    public func share(
      from parameters: Model.Parameters,
      renamer: ((String, String) -> ModelParametersShareResult)? = nil
    )

    Parameters

    parameters

    The model parameter to share from.

  • Interpolate from current parameters to the another.

    parameters = (1 - weight) * parameters + weight * other

    Declaration

    Swift

    public func lerp(
      _ weight: Float, to parameters: Model.Parameters, streamContext: StreamContext? = nil
    )

    Parameters

    weight

    How much the other parameter should weight, it must be between [0, 1].

    parameters

    The parameters of another model, it must match the parameters to update.

    streamContext

    The stream context to apply the lerp operation.

  • Clamp current parameters between two values.

    Declaration

    Swift

    public func clamp(_ range: ClosedRange<Float>, streamContext: StreamContext? = nil)
  • Clamp current parameters with a lower bound.

    Declaration

    Swift

    public func clamp(_ range: PartialRangeFrom<Float>, streamContext: StreamContext? = nil)
  • Clamp current parameters with an upper bound.

    Declaration

    Swift

    public func clamp(_ range: PartialRangeThrough<Float>, streamContext: StreamContext? = nil)
  • Declaration

    Swift

    public enum NormType : Int32
  • Declaration

    Swift

    public func clipGradNorm(
      maxNorm: Float, normType: NormType = .norm2, streamContext: StreamContext? = nil
    )