Interface TrainingSession

Represent a runtime instance of an ONNX training session, which contains a model that can be trained, and, optionally, an eval and optimizer model.

Hierarchy

  • TrainingSession

Properties

evalInputNames: readonly string[]

Get input names of the loaded eval model. Is an empty array if no eval model is loaded.

evalOutputNames: readonly string[]

Get output names of the loaded eval model. Is an empty array if no eval model is loaded.

trainingInputNames: readonly string[]

Get input names of the loaded training model.

trainingOutputNames: readonly string[]

Get output names of the loaded training model.

Methods

  • Copies the model parameters to a contiguous buffer. Usually used in the context of Federated Learning. Currently, only supporting models with parameters of type Float32.

    Returns

    A promise that resolves to a Float32 OnnxValue of the requested parameters.

    Parameters

    • trainableOnly: boolean

      When set to true, only trainable parameters are copied. Trainable parameters are parameters for which requires_grad is set to true. Default value is true.

    Returns Promise<Tensor>

  • Retrieves the size of all parameters for the training state. Calculates the total number of primitive (datatype of the parameters) elements of all the parameters in the training state.

    Parameters

    • trainableOnly: boolean

      When set to true, the size is calculated for trainable params only. Default value is true.

    Returns Promise<number>

  • Lazily resets the gradients of all trainable parameters to zero. Should happen after the invocation of runOptimizerStep.

    Returns Promise<void>

  • Copies parameter values from the given array to the training state. Currently, only supporting models with parameters of type Float32.

    Parameters

    • array: Uint8Array
    • trainableOnly: boolean

      True if trainable parameters only to be modified, false otherwise. Default value is true.

    Returns Promise<void>

  • Release the inference session and the underlying resources.

    Returns Promise<void>

  • Runs a single optimizer step, which performs weight updates for the trainable parameters using the optimizer model.

    Parameters

    • Optional options: RunOptions

      Optional. A set of options that controls the behavior of model optimizing.

    Returns Promise<void>

Generated using TypeDoc