Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Variable<D, R>

Type parameters

Hierarchy

Index

Constructors

Protected constructor

  • new Variable(shape: number[], dtype: D, values?: DataTypeMap[D], dataId?: number, math?: NDArrayMath): Variable

Properties

dataId

dataId: number

Id of the bucket holding the data for this ndarray. Multiple arrays can point to the same bucket (e.g. when calling array.reshape()).

dtype

dtype: D

The data type for the array.

id

id: number

Unique id of this ndarray.

Protected math

name

name: string

rankType

rankType: R

The rank type for the array ('0','1','2','3','4','higher').

shape

shape: ShapeMap[R]

The shape of the ndarray.

size

size: number

Number of elements in the ndarray.

strides

strides: number[]

Number of elements to skip in each dimension when indexing. See https://docs.scipy.org/doc/numpy/reference/generated /numpy.ndarray.strides.html

Accessors

rank

  • get rank(): number

Methods

add

  • add(value: number, ...locs: number[]): void

as1D

as2D

  • as2D(rows: number, columns: number): Array2D<D>

as3D

  • as3D(rows: number, columns: number, depth: number): Array3D<D>

as4D

  • as4D(rows: number, columns: number, depth: number, depth2: number): Array4D<D>

asScalar

asType

  • asType<D2>(dtype: D2): NDArray<D2, R>

assign

  • assign(newValue: NDArray<D, R>): void
  • Assign a new array to this variable. The old array will be disposed.

    Parameters

    Returns void

data

  • data(): Promise<DataTypeMap[D]>
  • Asynchronously downloads the values from the NDArray. Returns a promise that resolves when the data is ready.

    Returns Promise<DataTypeMap[D]>

dataSync

  • dataSync(): DataTypeMap[D]
  • Synchronously downloads the values from the NDArray. This blocks the UI thread until the values are ready, which can cause performance issues.

    Returns DataTypeMap[D]

dispose

  • dispose(): void

equals

  • equals(t: NDArray<D, R>): boolean

fill

  • fill(value: number): void

flatten

get

  • get(...locs: number[]): number

getValues

  • getValues(): DataTypeMap[D]

getValuesAsync

  • getValuesAsync(): Promise<DataTypeMap[D]>

indexToLoc

  • indexToLoc(index: number): ShapeMap[R]

locToIndex

  • locToIndex(locs: ShapeMap[R]): number

reshape

  • reshape<R2>(newShape: number[]): RankMap<D>[R2]
  • Reshapes the current ndarray into the provided shape.

    Type parameters

    Parameters

    • newShape: number[]

    Returns RankMap<D>[R2]

set

  • set(value: number, ...locs: number[]): void

val

  • val(...locs: number[]): Promise<number>

Static fromPixels

  • fromPixels(pixels: ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, numChannels?: number, math?: NDArrayMath): Array3D<"int32">

Static like

  • like<T>(another: T): T
  • Creates a ndarray with the same values/shape as the specified ndarray.

    Type parameters

    Parameters

    • another: T

    Returns T

Static make

  • make<D, R>(shape: number[], data: NDArrayData<D>, dtype?: D, math?: NDArrayMath): RankMap<D>[R]
  • Makes a new ndarray with the provided shape and values. Values should be in a flat array.

    Type parameters

    Parameters

    • shape: number[]
    • data: NDArrayData<D>
    • Optional dtype: D
    • Optional math: NDArrayMath

    Returns RankMap<D>[R]

Static ones

  • ones<D, R>(shape: number[], dtype?: D): RankMap<D>[R]
  • Creates a ndarray of ones with the specified shape.

    Type parameters

    Parameters

    • shape: number[]
    • Optional dtype: D

    Returns RankMap<D>[R]

Static onesLike

  • onesLike<T>(another: T): T

Static rand

  • rand<D, R>(shape: number[], randFunction: function, dtype?: D): RankMap<D>[R]
  • Type parameters

    Parameters

    • shape: number[]
    • randFunction: function
        • (): number
        • Returns number

    • Optional dtype: D

    Returns RankMap<D>[R]

Static randNormal

  • randNormal<D, R>(shape: number[], mean?: number, stdDev?: number, dtype?: D, seed?: number): RankMap<D>[R]
  • Type parameters

    • D: "float32" | "int32"

    • R: Rank

    Parameters

    • shape: number[]
    • Default value mean: number = 0
    • Default value stdDev: number = 1
    • Optional dtype: D
    • Optional seed: number

    Returns RankMap<D>[R]

Static randTruncatedNormal

  • randTruncatedNormal<D, R>(shape: number[], mean?: number, stdDev?: number, dtype?: D, seed?: number): RankMap<D>[R]
  • Type parameters

    • D: "float32" | "int32"

    • R: Rank

    Parameters

    • shape: number[]
    • Default value mean: number = 0
    • Default value stdDev: number = 1
    • Optional dtype: D
    • Optional seed: number

    Returns RankMap<D>[R]

Static randUniform

  • randUniform<D, R>(shape: number[], a: number, b: number, dtype?: D): RankMap<D>[R]

Static variable

  • variable<D, R>(initialValue: NDArray<D, R>, trainable?: boolean, name?: string, dtype?: D): Variable<D, R>
  • Creates a new variable with the provided initial value.

    Type parameters

    Parameters

    • initialValue: NDArray<D, R>

      An ndarray.

    • Default value trainable: boolean = true

      If true, optimizers are allowed to update it.

    • Optional name: string

      Name of the variable. Defaults to a unique id.

    • Optional dtype: D

      If set, initialValue will be converted to the given type.

    Returns Variable<D, R>

Static zeros

  • zeros<D, R>(shape: number[], dtype?: D): RankMap<D>[R]
  • Creates a ndarray of zeros with the specified shape.

    Type parameters

    Parameters

    • shape: number[]
    • Optional dtype: D

    Returns RankMap<D>[R]

Static zerosLike

  • zerosLike<T>(another: T): T

Generated using TypeDoc