Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/vectorizer/src/utils/misc/tensor.ts>Tensor

Machine Learning utilities for TypeScript
Latest
class Tensor
implements Sliceable, TensorLike<DT, O>
import { Tensor } from "https://deno.land/x/vectorizer@v0.7.5/src/utils/misc/tensor.ts";

A Tensor of order O.

Constructors

new
Tensor(tensor: TensorLike<DT, O>)
new
Tensor(array: NDArray<DT>[O], dType: DT)
new
Tensor(data: DType<DT>, shape: Shape<O>)
new
Tensor(dType: DT, shape: Shape<O>)
new
Tensor(data:
| NDArray<DT>[O]
| DType<DT>
| DT
, shape?: Shape<O> | DType<DT>
)

Type Parameters

DT extends DataType
O extends Order

Properties

data: DType<DT>
dType: DT
readonly
length: number

For compat with useSplit()

order: O
shape: Shape<O>
strides: Shape<O>

Methods

filter(fn: (
value: DType<DT>,
row: number,
_: DType<DT>[],
) => boolean
): Tensor<DT, O>

Filter the tensor by 0th axis

item(...indices: number[]): DTypeValue<DT>

Get an item using indices

slice(
start?,
end?: number,
axis?,
): Tensor<DT, O>

Slice matrix by axis

toJSON(): { data: DTypeValue<DT>[]; shape: Shape<O>; }