Options
All
  • Public
  • Public/Protected
  • All
Menu

Implements the Adam optimizer

This is currently quite slow on the CPU and WASM backends. On the GPU backend, one update step is only slightly slower than an update step of SGD and will converge a lot quicker.

Hierarchy

Index

Constructors

constructor

  • new Adam(model: Module, lr?: number, beta1?: number, beta2?: number, epsilon?: number): Adam

Properties

beta1

beta1: number = 0.9

beta2

beta2: number = 0.999

epsilon

epsilon: number = 10e-8

lr

lr: number = 0.001

model

model: Module

Optional moment1

moment1: undefined | (undefined | Tensor<any>)[]

Optional moment2

moment2: undefined | (undefined | Tensor<any>)[]

Optional moments

moments: undefined | GPUTensor<any>[]

parameters

parameters: Variable<any>[]

t

t: number = 0

Methods

getCorrectedMoments

  • getCorrectedMoments<DTpe>(moment1: Tensor<DTpe>, moment2: Tensor<DTpe>): { correctMoment1: Tensor<DTpe>; correctMoment2: Tensor<DTpe> }

gpuParamStep

  • gpuParamStep<DTpe>(value: GPUTensor<DTpe>, grad: GPUTensor<DTpe>, moments: GPUTensor<DTpe>): { moments: GPUTensorI; newValue: GPUTensorI }

paramStep

  • paramStep<DTpe>(value: Tensor<DTpe>, grad: Tensor<DTpe>, moment1: undefined | Tensor<DTpe>, moment2: undefined | Tensor<DTpe>): { moment1: undefined | Tensor<DTpe>; moment2: undefined | Tensor<DTpe>; newValue: Tensor<DTpe> }

step

  • step(): void

updateMoments

  • updateMoments<DTpe>(grad: Tensor<DTpe>, moment1: undefined | Tensor<DTpe>, moment2: undefined | Tensor<DTpe>): { moment1New: Tensor<DTpe>; moment2New: Tensor<DTpe> }

zeroGrads

  • zeroGrads(): void

Generated using TypeDoc