Parameters
public final class Parameters : IO
extension Model.Parameters: DynamicGraph_AnyParameters
-
The internal name for this parameter.
Declaration
Swift
public var name: String { get } -
Get index into the parameters.
Declaration
Swift
public subscript(position: Int) -> Parameters { get } -
Get the total number of parameters.
Declaration
Swift
public var count: Int { get } -
Get a parameter by loop over internally to find the matching one.
Declaration
Swift
public func first(where block: @escaping (String) -> Bool) -> Parameters? -
Get a list of parameters matching the condition.
Declaration
Swift
public func filter(where block: @escaping (String) -> Bool) -> [Parameters] -
Copy parameters from one model to another.
Declaration
Swift
public func copy(from parameters: Model.Parameters)Parameters
parametersThe 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
tensorThe 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 : TensorNumericParameters
tensorThe 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
tensorThe 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 : TensorNumericParameters
typeThe element type of a tensor.
-
Copy parameters to a tensor.
Declaration
Swift
public func copy<Element>(to tensor: DynamicGraph.Tensor<Element>) where Element : TensorNumericParameters
tensorThe 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
parametersThe 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
weightHow much the other parameter should weight, it must be between [0, 1].
parametersThe parameters of another model, it must match the parameters to update.
streamContextThe 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 )
Parameters Class Reference