A `tf.Tensor` object represents an immutable, multidimensional array of numbers that has a shape and a data type.

For performance reasons, functions that create tensors do not necessarily perform a copy of the data passed to them (e.g. if the data is passed as a `Float32Array`), and changes to the data will change the tensor. This is not a feature and is not supported. To avoid this behavior, use the tensor before changing the input data or create a copy with `copy = tf.add(yourTensor, 0)`.

See `tf.tensor` for details on how to create a `tf.Tensor`.

doc

  {heading: 'Tensors', subheading: 'Classes'}

### Type parameters

- #### R: Rank = Rank

### Hierarchy

- Tensor

## Index

### Constructors

- constructor

### Properties

- dataId
- dtype
- id
- isDisposed
- kept
- rank
- rankType
- scopeId
- shape
- size
- strides

### Methods

- array
- arraySync
- buffer
- bufferSync
- bytes
- clone
- data
- dataSync
- dispose
- print
- throwIfDisposed
- toString
- variable

## Constructors

### constructor

- new Tensor<R>(shape: ShapeMap[R], dtype: keyof DataTypeMap, dataId: object, id: number): Tensor<R>

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:152

  #### Type parameters

  - #### R: Rank = Rank

  #### Parameters

  - ##### shape: ShapeMap[R]

  - ##### dtype: keyof DataTypeMap

  - ##### dataId: object

  - ##### id: number

  #### Returns Tensor<R>

## Properties

### dataId

dataId: object

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:133

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

### Readonly dtype

dtype: keyof DataTypeMap

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:139

The data type for the array.

### Readonly id

id: number

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:128

Unique id of this tensor.

### Readonly isDisposed

isDisposed: boolean

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:202

### kept

kept: boolean

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:143

Whether this tensor has been globally kept.

### Readonly rank

rank: number

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:153

### Readonly rankType

rankType: R

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:141

The rank type for the array (see `Rank` enum).

### scopeId

scopeId: number

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:145

The id of the scope this tensor is being tracked in.

### Readonly shape

shape: ShapeMap[R]

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:135

The shape of the tensor.

### Readonly size

size: number

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:137

Number of elements in the tensor.

### Readonly strides

strides: number[]

- Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:151

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

## Methods

### array

- array(): Promise<ArrayMap[R]>

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:171

  Returns the tensor data as a nested array. The transfer of data is done asynchronously.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Returns Promise<ArrayMap[R]>

### arraySync

- arraySync(): ArrayMap[R]

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:178

  Returns the tensor data as a nested array. The transfer of data is done synchronously.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Returns ArrayMap[R]

### buffer

- buffer<D>(): Promise<TensorBuffer<R, D>>

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:159

  Returns a promise of `tf.TensorBuffer` that holds the underlying data.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Type parameters

  - #### D: keyof DataTypeMap = "float32"

  #### Returns Promise<TensorBuffer<R, D>>

### bufferSync

- bufferSync<D>(): TensorBuffer<R, D>

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:164

  Returns a `tf.TensorBuffer` that holds the underlying data.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Type parameters

  - #### D: keyof DataTypeMap = "float32"

  #### Returns TensorBuffer<R, D>

### bytes

- bytes(): Promise<Uint8Array | Uint8Array[]>

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:194

  Returns the underlying bytes of the tensor's data.

  #### Returns Promise<Uint8Array | Uint8Array[]>

### clone

- clone<T>(): T

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:217

  Returns a copy of the tensor. See `tf.clone` for details.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Type parameters

  - #### T: Tensor<Rank, T>

  #### Returns T

### data

- data<D>(): Promise<DataTypeMap[D]>

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:185

  Asynchronously downloads the values from the `tf.Tensor`. Returns a promise of `TypedArray` that resolves when the computation has finished.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Type parameters

  - #### D: keyof DataTypeMap = NumericDataType

  #### Returns Promise<DataTypeMap[D]>

### dataSync

- dataSync<D>(): DataTypeMap[D]

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:192

  Synchronously downloads the values from the `tf.Tensor`. This blocks the UI thread until the values are ready, which can cause performance issues.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Type parameters

  - #### D: keyof DataTypeMap = NumericDataType

  #### Returns DataTypeMap[D]

### dispose

- dispose(): void

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:200

  Disposes `tf.Tensor` from memory.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Returns void

### print

- print(verbose?: boolean): void

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:212

  Prints the `tf.Tensor`. See `tf.print` for details.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Parameters

  - ##### Optional verbose: boolean

    Whether to print verbose information about the tensor, including dtype and size.

  #### Returns void

### throwIfDisposed

- throwIfDisposed(): void

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:203

  #### Returns void

### toString

- toString(verbose?: boolean): string

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:223

  Returns a human-readable description of the tensor. Useful for logging.

  doc

    {heading: 'Tensors', subheading: 'Classes'}

  #### Parameters

  - ##### Optional verbose: boolean

  #### Returns string

### variable

- variable(trainable?: boolean, name?: string, dtype?: keyof DataTypeMap): Variable<R>

- - Defined in node_modules/.pnpm/@tensorflow+tfjs-core@3.11.0/node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:224

  #### Parameters

  - ##### Optional trainable: boolean

  - ##### Optional name: string

  - ##### Optional dtype: keyof DataTypeMap

  #### Returns Variable<R>