torch
    Preparing search index...

    Class Parameter

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    grad: Tensor = null
    grad_fn: TorchFunction = null
    id: number = ...
    name: string = null
    requires_grad: boolean
    shape: number[]

    Accessors

    • get data(): number[]

      Returns the flat, contiguous data for this tensor.

      Fast path (non-view): returns the storage array directly — no allocation. View path: materialises a contiguous slice — one allocation per call, so callers inside tight loops should cache the result: const d = t.data.

      Returns number[]

    • set data(values: number[]): void

      Sets the tensor's data.

      Non-view (offset=0, storage covers exactly this tensor's numel): replaces the shared storage's data array in-place — all other views sharing the same TensorStorage immediately see the new values.

      View (offset≠0 or storage is larger than this tensor): copies values element-by-element into the shared storage at the correct offset — the original tensor and sibling views are updated.

      Parameters

      • values: number[]

      Returns void

    Methods

    • Parameters

      • other: Tensor
      • rtol: number = 1e-5
      • atol: number = 1e-8
      • equal_nan: boolean = false

      Returns boolean

    • Returns a view of this tensor along dimension 0.

      The returned tensor shares the same underlying TensorStorage — mutations to either tensor (via zero_(), the data setter, or the optimizer) are immediately visible in the other.

      Supports negative indices (e.g. index(-1) is the last row).

      Note: the view does not carry a grad_fn; autograd does not propagate through index() at this time.

      Parameters

      • i: number

      Returns Tensor

    • Parameters

      • Optionaldim: number | number[]
      • keepdim: boolean = false

      Returns Tensor

    • Parameters

      • Optionaldim: number | number[]
      • keepdim: boolean = false

      Returns Tensor

    • Parameters

      • Optionaldim: number | number[]
      • keepdim: boolean = false

      Returns Tensor

    • Parameters

      • Optionaldim: number

      Returns number | number[]

    • Parameters

      • Optionaldim: number | number[]
      • keepdim: boolean = false

      Returns Tensor