Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Session

A Session maintains the runtime state required to efficiently evaluate nodes. On their own, graph objects are very lightweight logical topologies; they have no relationship with the GPU. Sessions encapsulate the evaluation of nodes, the management of GPU resources, the caching of evaluation paths, and anything else required to evaluate or train a network.

Hierarchy

  • Session

Index

Constructors

constructor

Properties

activationArrayMap

activationArrayMap: TensorArrayMap = new TensorArrayMap()

Maps each output tensor of the graph to its activation value.

gradientArrayMap

gradientArrayMap: SummedTensorArrayMap

Maps each tensor of the graph to its derivative wrt the cost function.

Methods

dispose

  • dispose(): void
  • Release all system resources associated with this Session.

    Returns void

eval

  • Evaluate a tensor, using the provided feed entries to provide upstream NDArray input.

    Parameters

    • tensor: Tensor

      The tensor to evaluate.

    • feedEntries: FeedEntry[]

      List of FeedEntry to read when replacing graph tensors with NDArrays.

    Returns NDArray

    The computed value of the tensor.

evalAll

  • Evaluate a list of tensors, using the provided feed entries to provide upstream NDArray input. When using a NDArrayMath object in safe mode this must be used in a math.scope().

    Parameters

    • tensors: Tensor[]

      The list of tensors to evaluate.

    • feedEntries: FeedEntry[]

      List of FeedEntry to read when replacing graph tensors with NDArrays.

    Returns NDArray[]

    The computed values of the tensors.

train

  • train(costTensor: Tensor, feedEntries: FeedEntry[], batchSize: number, optimizer: Optimizer, costReduction?: CostReduction.NONE | CostReduction.SUM | CostReduction.MEAN): Scalar
  • Trains a batch. Returns a reduced cost if the costReduction parameter is set. When using a NDArrayMath object in safe mode this must be used in a math.scope().

    Parameters

    • costTensor: Tensor

      A tensor representing the cost to optimize. Should be a scalar.

    • feedEntries: FeedEntry[]

      Feed entries for this train run. Provides inputs.

    • batchSize: number

      Batch size for this train loop.

    • optimizer: Optimizer

      An optimizer to perform weight updates.

    • Default value costReduction: CostReduction.NONE | CostReduction.SUM | CostReduction.MEAN = CostReduction.NONE

      An option to allow the user to get a summed, averaged, or no cost back.

    Returns Scalar

    The reduced cost, if cost reduction is not NONE. The user is responsible for disposing the cost NDArray between train loops.

Generated using TypeDoc