Buckets:

download
raw
155 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/tensor&quot;,&quot;local&quot;:&quot;utilstensor&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;On this page&quot;,&quot;local&quot;:&quot;on-this-page&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Classes&quot;,&quot;local&quot;:&quot;classes&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Tensor&quot;,&quot;local&quot;:&quot;tensor&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Tensor.dims : number[]&quot;,&quot;local&quot;:&quot;tensordims--number&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.type : DataType&quot;,&quot;local&quot;:&quot;tensortype--datatype&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.data : DataArray&quot;,&quot;local&quot;:&quot;tensordata--dataarray&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.size : number&quot;,&quot;local&quot;:&quot;tensorsize--number&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.location : string&quot;,&quot;local&quot;:&quot;tensorlocation--string&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.constructor(args)&quot;,&quot;local&quot;:&quot;tensorconstructorargs&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.[Symbol.iterator]()&quot;,&quot;local&quot;:&quot;tensorsymboliterator&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.item()&quot;,&quot;local&quot;:&quot;tensoritem&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.tolist()&quot;,&quot;local&quot;:&quot;tensortolist&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sigmoid()&quot;,&quot;local&quot;:&quot;tensorsigmoid&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sigmoid_()&quot;,&quot;local&quot;:&quot;tensorsigmoid&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.map(callback)&quot;,&quot;local&quot;:&quot;tensormapcallback&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.map_(callback)&quot;,&quot;local&quot;:&quot;tensormapcallback&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.mul(val)&quot;,&quot;local&quot;:&quot;tensormulval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.mul_(val)&quot;,&quot;local&quot;:&quot;tensormulval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.div(val)&quot;,&quot;local&quot;:&quot;tensordivval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.div_(val)&quot;,&quot;local&quot;:&quot;tensordivval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.add(val)&quot;,&quot;local&quot;:&quot;tensoraddval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.add_(val)&quot;,&quot;local&quot;:&quot;tensoraddval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sub(val)&quot;,&quot;local&quot;:&quot;tensorsubval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sub_(val)&quot;,&quot;local&quot;:&quot;tensorsubval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.clone()&quot;,&quot;local&quot;:&quot;tensorclone&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.slice(slices)&quot;,&quot;local&quot;:&quot;tensorsliceslices&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.permute(dims)&quot;,&quot;local&quot;:&quot;tensorpermutedims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.transpose(dims)&quot;,&quot;local&quot;:&quot;tensortransposedims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sum([dim], keepdim)&quot;,&quot;local&quot;:&quot;tensorsumdim-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.norm([p], [dim], [keepdim])&quot;,&quot;local&quot;:&quot;tensornormp-dim-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.normalize_([p], [dim])&quot;,&quot;local&quot;:&quot;tensornormalizep-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.normalize([p], [dim])&quot;,&quot;local&quot;:&quot;tensornormalizep-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.stride()&quot;,&quot;local&quot;:&quot;tensorstride&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.squeeze([dim])&quot;,&quot;local&quot;:&quot;tensorsqueezedim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.squeeze_()&quot;,&quot;local&quot;:&quot;tensorsqueeze&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.unsqueeze(dim)&quot;,&quot;local&quot;:&quot;tensorunsqueezedim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.unsqueeze_(dim)&quot;,&quot;local&quot;:&quot;tensorunsqueezedim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.flatten_()&quot;,&quot;local&quot;:&quot;tensorflatten&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.flatten(start_dim, end_dim)&quot;,&quot;local&quot;:&quot;tensorflattenstartdim-enddim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.view(dims)&quot;,&quot;local&quot;:&quot;tensorviewdims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.gt(val)&quot;,&quot;local&quot;:&quot;tensorgtval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.lt(val)&quot;,&quot;local&quot;:&quot;tensorltval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.clamp_(min, max)&quot;,&quot;local&quot;:&quot;tensorclampmin-max&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.clamp(min, max)&quot;,&quot;local&quot;:&quot;tensorclampmin-max&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.round_()&quot;,&quot;local&quot;:&quot;tensorround&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.round()&quot;,&quot;local&quot;:&quot;tensorround&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.repeat(repeats)&quot;,&quot;local&quot;:&quot;tensorrepeatrepeats&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.tile(dims)&quot;,&quot;local&quot;:&quot;tensortiledims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.to(type)&quot;,&quot;local&quot;:&quot;tensortotype&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4}],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Functions&quot;,&quot;local&quot;:&quot;functions&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;permute(tensor, axes)&quot;,&quot;local&quot;:&quot;permutetensor-axes&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;interpolate(input, size, mode, align_corners)&quot;,&quot;local&quot;:&quot;interpolateinput-size-mode-aligncorners&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;interpolate_4d(input, options)&quot;,&quot;local&quot;:&quot;interpolate4dinput-options&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;matmul(a, b)&quot;,&quot;local&quot;:&quot;matmula-b&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rfft(x, a)&quot;,&quot;local&quot;:&quot;rfftx-a&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;topk(x, [k])&quot;,&quot;local&quot;:&quot;topkx-k&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;slice(data, starts, ends, axes, [steps])&quot;,&quot;local&quot;:&quot;slicedata-starts-ends-axes-steps&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;mean_pooling(last_hidden_state, attention_mask)&quot;,&quot;local&quot;:&quot;meanpoolinglasthiddenstate-attentionmask&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;layer_norm(input, normalized_shape, options)&quot;,&quot;local&quot;:&quot;layernorminput-normalizedshape-options&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;cat(tensors, dim)&quot;,&quot;local&quot;:&quot;cattensors-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;stack(tensors, dim)&quot;,&quot;local&quot;:&quot;stacktensors-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;std_mean(input, dim, correction, keepdim)&quot;,&quot;local&quot;:&quot;stdmeaninput-dim-correction-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;mean(input, dim, keepdim)&quot;,&quot;local&quot;:&quot;meaninput-dim-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;full(size, fill_value)&quot;,&quot;local&quot;:&quot;fullsize-fillvalue&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ones(size)&quot;,&quot;local&quot;:&quot;onessize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ones_like(tensor)&quot;,&quot;local&quot;:&quot;onesliketensor&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;zeros(size)&quot;,&quot;local&quot;:&quot;zerossize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;zeros_like(tensor)&quot;,&quot;local&quot;:&quot;zerosliketensor&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rand(size)&quot;,&quot;local&quot;:&quot;randsize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;randn(size)&quot;,&quot;local&quot;:&quot;randnsize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;quantize_embeddings(tensor, precision)&quot;,&quot;local&quot;:&quot;quantizeembeddingstensor-precision&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Type Definitions&quot;,&quot;local&quot;:&quot;type-definitions&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;DataType&quot;,&quot;local&quot;:&quot;datatype&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;DataArray&quot;,&quot;local&quot;:&quot;dataarray&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;NestArray&quot;,&quot;local&quot;:&quot;nestarray&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/transformers.js/pr_1665/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/entry/start.cb58eb6f.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/scheduler.6efaaf90.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/singletons.08239980.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/paths.611c3944.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/entry/app.9eafcf9d.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/preload-helper.4b821645.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/index.eb3e1f0f.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/nodes/0.d361a553.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/nodes/23.1b64aab6.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.699f2734.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/CodeBlock.b303f0b9.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/tensor&quot;,&quot;local&quot;:&quot;utilstensor&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;On this page&quot;,&quot;local&quot;:&quot;on-this-page&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Classes&quot;,&quot;local&quot;:&quot;classes&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Tensor&quot;,&quot;local&quot;:&quot;tensor&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Tensor.dims : number[]&quot;,&quot;local&quot;:&quot;tensordims--number&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.type : DataType&quot;,&quot;local&quot;:&quot;tensortype--datatype&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.data : DataArray&quot;,&quot;local&quot;:&quot;tensordata--dataarray&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.size : number&quot;,&quot;local&quot;:&quot;tensorsize--number&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.location : string&quot;,&quot;local&quot;:&quot;tensorlocation--string&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.constructor(args)&quot;,&quot;local&quot;:&quot;tensorconstructorargs&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.[Symbol.iterator]()&quot;,&quot;local&quot;:&quot;tensorsymboliterator&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.item()&quot;,&quot;local&quot;:&quot;tensoritem&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.tolist()&quot;,&quot;local&quot;:&quot;tensortolist&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sigmoid()&quot;,&quot;local&quot;:&quot;tensorsigmoid&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sigmoid_()&quot;,&quot;local&quot;:&quot;tensorsigmoid&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.map(callback)&quot;,&quot;local&quot;:&quot;tensormapcallback&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.map_(callback)&quot;,&quot;local&quot;:&quot;tensormapcallback&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.mul(val)&quot;,&quot;local&quot;:&quot;tensormulval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.mul_(val)&quot;,&quot;local&quot;:&quot;tensormulval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.div(val)&quot;,&quot;local&quot;:&quot;tensordivval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.div_(val)&quot;,&quot;local&quot;:&quot;tensordivval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.add(val)&quot;,&quot;local&quot;:&quot;tensoraddval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.add_(val)&quot;,&quot;local&quot;:&quot;tensoraddval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sub(val)&quot;,&quot;local&quot;:&quot;tensorsubval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sub_(val)&quot;,&quot;local&quot;:&quot;tensorsubval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.clone()&quot;,&quot;local&quot;:&quot;tensorclone&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.slice(slices)&quot;,&quot;local&quot;:&quot;tensorsliceslices&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.permute(dims)&quot;,&quot;local&quot;:&quot;tensorpermutedims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.transpose(dims)&quot;,&quot;local&quot;:&quot;tensortransposedims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.sum([dim], keepdim)&quot;,&quot;local&quot;:&quot;tensorsumdim-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.norm([p], [dim], [keepdim])&quot;,&quot;local&quot;:&quot;tensornormp-dim-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.normalize_([p], [dim])&quot;,&quot;local&quot;:&quot;tensornormalizep-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.normalize([p], [dim])&quot;,&quot;local&quot;:&quot;tensornormalizep-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.stride()&quot;,&quot;local&quot;:&quot;tensorstride&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.squeeze([dim])&quot;,&quot;local&quot;:&quot;tensorsqueezedim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.squeeze_()&quot;,&quot;local&quot;:&quot;tensorsqueeze&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.unsqueeze(dim)&quot;,&quot;local&quot;:&quot;tensorunsqueezedim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.unsqueeze_(dim)&quot;,&quot;local&quot;:&quot;tensorunsqueezedim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.flatten_()&quot;,&quot;local&quot;:&quot;tensorflatten&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.flatten(start_dim, end_dim)&quot;,&quot;local&quot;:&quot;tensorflattenstartdim-enddim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.view(dims)&quot;,&quot;local&quot;:&quot;tensorviewdims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.gt(val)&quot;,&quot;local&quot;:&quot;tensorgtval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.lt(val)&quot;,&quot;local&quot;:&quot;tensorltval&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.clamp_(min, max)&quot;,&quot;local&quot;:&quot;tensorclampmin-max&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.clamp(min, max)&quot;,&quot;local&quot;:&quot;tensorclampmin-max&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.round_()&quot;,&quot;local&quot;:&quot;tensorround&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.round()&quot;,&quot;local&quot;:&quot;tensorround&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.repeat(repeats)&quot;,&quot;local&quot;:&quot;tensorrepeatrepeats&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.tile(dims)&quot;,&quot;local&quot;:&quot;tensortiledims&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4},{&quot;title&quot;:&quot;Tensor.to(type)&quot;,&quot;local&quot;:&quot;tensortotype&quot;,&quot;sections&quot;:[],&quot;depth&quot;:4}],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Functions&quot;,&quot;local&quot;:&quot;functions&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;permute(tensor, axes)&quot;,&quot;local&quot;:&quot;permutetensor-axes&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;interpolate(input, size, mode, align_corners)&quot;,&quot;local&quot;:&quot;interpolateinput-size-mode-aligncorners&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;interpolate_4d(input, options)&quot;,&quot;local&quot;:&quot;interpolate4dinput-options&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;matmul(a, b)&quot;,&quot;local&quot;:&quot;matmula-b&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rfft(x, a)&quot;,&quot;local&quot;:&quot;rfftx-a&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;topk(x, [k])&quot;,&quot;local&quot;:&quot;topkx-k&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;slice(data, starts, ends, axes, [steps])&quot;,&quot;local&quot;:&quot;slicedata-starts-ends-axes-steps&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;mean_pooling(last_hidden_state, attention_mask)&quot;,&quot;local&quot;:&quot;meanpoolinglasthiddenstate-attentionmask&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;layer_norm(input, normalized_shape, options)&quot;,&quot;local&quot;:&quot;layernorminput-normalizedshape-options&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;cat(tensors, dim)&quot;,&quot;local&quot;:&quot;cattensors-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;stack(tensors, dim)&quot;,&quot;local&quot;:&quot;stacktensors-dim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;std_mean(input, dim, correction, keepdim)&quot;,&quot;local&quot;:&quot;stdmeaninput-dim-correction-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;mean(input, dim, keepdim)&quot;,&quot;local&quot;:&quot;meaninput-dim-keepdim&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;full(size, fill_value)&quot;,&quot;local&quot;:&quot;fullsize-fillvalue&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ones(size)&quot;,&quot;local&quot;:&quot;onessize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ones_like(tensor)&quot;,&quot;local&quot;:&quot;onesliketensor&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;zeros(size)&quot;,&quot;local&quot;:&quot;zerossize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;zeros_like(tensor)&quot;,&quot;local&quot;:&quot;zerosliketensor&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;rand(size)&quot;,&quot;local&quot;:&quot;randsize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;randn(size)&quot;,&quot;local&quot;:&quot;randnsize&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;quantize_embeddings(tensor, precision)&quot;,&quot;local&quot;:&quot;quantizeembeddingstensor-precision&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Type Definitions&quot;,&quot;local&quot;:&quot;type-definitions&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;DataType&quot;,&quot;local&quot;:&quot;datatype&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;DataArray&quot;,&quot;local&quot;:&quot;dataarray&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;NestArray&quot;,&quot;local&quot;:&quot;nestarray&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="utilstensor" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#utilstensor"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>utils/tensor</span></h1> <p data-svelte-h="svelte-1y0csdo">Tensors and tensor operations.</p> <p data-svelte-h="svelte-18xivwz"><code>Tensor</code> is the typed n-dimensional array used throughout the library for
model inputs and outputs. The functions in this module create, transform,
and combine tensors — shape manipulation, slicing, reductions, math ops,
and the <code>.tolist()</code> / <code>.item()</code> escape hatches back to plain JavaScript.</p> <h2 class="relative group"><a id="on-this-page" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#on-this-page"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>On this page</span></h2> <p data-svelte-h="svelte-16i1l1s"><strong>Classes</strong><a href="#module_utils/tensor.Tensor"><code>Tensor</code></a></p> <p data-svelte-h="svelte-1l9gt9z"><strong>Functions</strong><a href="#module_utils/tensor.permute"><code>permute</code></a> · <a href="#module_utils/tensor.interpolate"><code>interpolate</code></a> · <a href="#module_utils/tensor.interpolate_4d"><code>interpolate_4d</code></a> · <a href="#module_utils/tensor.matmul"><code>matmul</code></a> · <a href="#module_utils/tensor.rfft"><code>rfft</code></a> · <a href="#module_utils/tensor.topk"><code>topk</code></a> · <a href="#module_utils/tensor.slice"><code>slice</code></a> · <a href="#module_utils/tensor.mean_pooling"><code>mean_pooling</code></a> · <a href="#module_utils/tensor.layer_norm"><code>layer_norm</code></a> · <a href="#module_utils/tensor.cat"><code>cat</code></a> · <a href="#module_utils/tensor.stack"><code>stack</code></a> · <a href="#module_utils/tensor.std_mean"><code>std_mean</code></a> · <a href="#module_utils/tensor.mean"><code>mean</code></a> · <a href="#module_utils/tensor.full"><code>full</code></a> · <a href="#module_utils/tensor.ones"><code>ones</code></a> · <a href="#module_utils/tensor.ones_like"><code>ones_like</code></a> · <a href="#module_utils/tensor.zeros"><code>zeros</code></a> · <a href="#module_utils/tensor.zeros_like"><code>zeros_like</code></a> · <a href="#module_utils/tensor.rand"><code>rand</code></a> · <a href="#module_utils/tensor.randn"><code>randn</code></a> · <a href="#module_utils/tensor.quantize_embeddings"><code>quantize_embeddings</code></a></p> <h2 class="relative group"><a id="classes" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#classes"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Classes</span></h2> <a id="module_utils/tensor.Tensor"></a> <h3 class="relative group"><a id="tensor" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensor"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor</span></h3> <p data-svelte-h="svelte-23g681">A typed multi-dimensional array.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-javascript "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> { <span class="hljs-title class_">Tensor</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@huggingface/transformers&#x27;</span>;
<span class="hljs-keyword">const</span> tensor = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Tensor</span>(<span class="hljs-string">&#x27;float32&#x27;</span>, [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>], [<span class="hljs-number">2</span>, <span class="hljs-number">3</span>]);
tensor.<span class="hljs-property">dims</span>; <span class="hljs-comment">// [2, 3]</span>
tensor.<span class="hljs-title function_">tolist</span>(); <span class="hljs-comment">// [[1, 2, 3], [4, 5, 6]]</span><!-- HTML_TAG_END --></pre></div> <h4 class="relative group"><a id="tensordims--number" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensordims--number"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.dims : number[]</span></h4> <p data-svelte-h="svelte-1gc2rt4">Dimensions of the tensor.</p> <h4 class="relative group"><a id="tensortype--datatype" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensortype--datatype"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.type : DataType</span></h4> <p data-svelte-h="svelte-81y0bb">Type of the tensor.</p> <h4 class="relative group"><a id="tensordata--dataarray" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensordata--dataarray"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.data : DataArray</span></h4> <p data-svelte-h="svelte-1eqabt7">The data stored in the tensor.</p> <h4 class="relative group"><a id="tensorsize--number" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsize--number"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.size : number</span></h4> <p data-svelte-h="svelte-krrt97">The number of elements in the tensor.</p> <h4 class="relative group"><a id="tensorlocation--string" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorlocation--string"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.location : string</span></h4> <p data-svelte-h="svelte-1iaptgl">The location of the tensor data.</p> <a id="module_utils/tensor.Tensor.constructor"></a> <h4 class="relative group"><a id="tensorconstructorargs" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorconstructorargs"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.constructor(args)</span></h4> <p data-svelte-h="svelte-vkg6mw">Create a new Tensor.</p> <p data-svelte-h="svelte-d9h2za">Two call shapes are supported:</p> <ul data-svelte-h="svelte-1wd4y90"><li><code>new Tensor(dataType, data, dims)</code> — build from raw data, e.g.
<code>new Tensor(&#39;float32&#39;, new Float32Array([1, 2, 3]), [3])</code>.</li> <li><code>new Tensor(ortTensor)</code> — wrap an existing <code>onnxruntime</code> tensor.</li></ul> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1gyfgzx"><li><code>args</code> ([<a href="../transformers#module_transformers.DataType"><code>DataType</code></a>, <a href="./tensor#module_utils/tensor.DataArray"><code>DataArray</code></a>, <code>number[]</code>] | [<code>ONNXTensor</code>])</li></ul> <a id="module_utils/tensor.Tensor.[Symbol.iterator]"></a> <h4 class="relative group"><a id="tensorsymboliterator" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsymboliterator"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.[Symbol.iterator]()</span></h4> <p data-svelte-h="svelte-1adn56z">Returns an iterator object for iterating over the tensor data in row-major order.
If the tensor has more than one dimension, the iterator will yield subarrays.</p> <p data-svelte-h="svelte-1xd3xl9"><strong>Returns:</strong> <code>Iterator&lt;any&gt;</code> — An iterator object for iterating over the tensor data in row-major order.</p> <a id="module_utils/tensor.Tensor.item"></a> <h4 class="relative group"><a id="tensoritem" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensoritem"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.item()</span></h4> <p data-svelte-h="svelte-13nzfs3">Returns the value of this tensor as a standard JavaScript Number. This only works
for tensors with one element. For other cases, see <code>Tensor.tolist()</code>.</p> <p data-svelte-h="svelte-1cn97eu"><strong>Returns:</strong> <code>number</code> | <code>bigint</code> — The value of this tensor as a standard JavaScript Number.</p> <p data-svelte-h="svelte-sl4r8m"><strong>Throws</strong></p> <ul data-svelte-h="svelte-15cvnwf"><li><code>Error</code> — If the tensor has more than one element.</li></ul> <a id="module_utils/tensor.Tensor.tolist"></a> <h4 class="relative group"><a id="tensortolist" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensortolist"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.tolist()</span></h4> <p data-svelte-h="svelte-87xdyr">Convert tensor data to a n-dimensional JS list</p> <p data-svelte-h="svelte-x1ldh7"><strong>Returns:</strong> <code>any[]</code></p> <a id="module_utils/tensor.Tensor.sigmoid"></a> <h4 class="relative group"><a id="tensorsigmoid" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsigmoid"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.sigmoid()</span></h4> <p data-svelte-h="svelte-2wti2w">Return a new Tensor with the sigmoid function applied to each element.</p> <p data-svelte-h="svelte-19g4sv3"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The tensor with the sigmoid function applied.</p> <a id="module_utils/tensor.Tensor.sigmoid_"></a> <h4 class="relative group"><a id="tensorsigmoid" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsigmoid"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.sigmoid_()</span></h4> <p data-svelte-h="svelte-1edu6c8">Applies the sigmoid function to the tensor in place.</p> <p data-svelte-h="svelte-540ymd"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — Returns <code>this</code>.</p> <a id="module_utils/tensor.Tensor.map"></a> <h4 class="relative group"><a id="tensormapcallback" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensormapcallback"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.map(callback)</span></h4> <p data-svelte-h="svelte-az0crx">Return a new Tensor with a callback function applied to each element.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-g2t0ku"><li><code>callback</code> (<code>Function</code>) — The function to apply to each element. It should take three arguments:
the current element, its index, and the tensor’s data array.</li></ul> <p data-svelte-h="svelte-whye6o"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — A new Tensor with the callback function applied to each element.</p> <a id="module_utils/tensor.Tensor.map_"></a> <h4 class="relative group"><a id="tensormapcallback" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensormapcallback"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.map_(callback)</span></h4> <p data-svelte-h="svelte-jlfq15">Apply a callback function to each element of the tensor in place.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-g2t0ku"><li><code>callback</code> (<code>Function</code>) — The function to apply to each element. It should take three arguments:
the current element, its index, and the tensor’s data array.</li></ul> <p data-svelte-h="svelte-540ymd"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — Returns <code>this</code>.</p> <a id="module_utils/tensor.Tensor.mul"></a> <h4 class="relative group"><a id="tensormulval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensormulval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.mul(val)</span></h4> <p data-svelte-h="svelte-xg80lg">Return a new Tensor with every element multiplied by a constant.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-ww7jfe"><li><code>val</code> (<code>number</code>) — The value to multiply by.</li></ul> <p data-svelte-h="svelte-1vjb6j9"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The new tensor.</p> <a id="module_utils/tensor.Tensor.mul_"></a> <h4 class="relative group"><a id="tensormulval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensormulval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.mul_(val)</span></h4> <p data-svelte-h="svelte-1i12x1s">Multiply the tensor by a constant in place.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-ww7jfe"><li><code>val</code> (<code>number</code>) — The value to multiply by.</li></ul> <p data-svelte-h="svelte-540ymd"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — Returns <code>this</code>.</p> <a id="module_utils/tensor.Tensor.div"></a> <h4 class="relative group"><a id="tensordivval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensordivval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.div(val)</span></h4> <p data-svelte-h="svelte-45kvaw">Return a new Tensor with every element divided by a constant.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1mm9fh9"><li><code>val</code> (<code>number</code>) — The value to divide by.</li></ul> <p data-svelte-h="svelte-1vjb6j9"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The new tensor.</p> <a id="module_utils/tensor.Tensor.div_"></a> <h4 class="relative group"><a id="tensordivval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensordivval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.div_(val)</span></h4> <p data-svelte-h="svelte-6s524n">Divide the tensor by a constant in place.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1mm9fh9"><li><code>val</code> (<code>number</code>) — The value to divide by.</li></ul> <p data-svelte-h="svelte-540ymd"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — Returns <code>this</code>.</p> <a id="module_utils/tensor.Tensor.add"></a> <h4 class="relative group"><a id="tensoraddval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensoraddval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.add(val)</span></h4> <p data-svelte-h="svelte-1hl64jn">Return a new Tensor with every element added by a constant.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1s8jw11"><li><code>val</code> (<code>number</code>) — The value to add by.</li></ul> <p data-svelte-h="svelte-1vjb6j9"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The new tensor.</p> <a id="module_utils/tensor.Tensor.add_"></a> <h4 class="relative group"><a id="tensoraddval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensoraddval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.add_(val)</span></h4> <p data-svelte-h="svelte-bbf4x3">Add the tensor by a constant in place.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1s8jw11"><li><code>val</code> (<code>number</code>) — The value to add by.</li></ul> <p data-svelte-h="svelte-540ymd"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — Returns <code>this</code>.</p> <a id="module_utils/tensor.Tensor.sub"></a> <h4 class="relative group"><a id="tensorsubval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsubval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.sub(val)</span></h4> <p data-svelte-h="svelte-wbrx6g">Return a new Tensor with every element subtracted by a constant.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-esoi9q"><li><code>val</code> (<code>number</code>) — The value to subtract by.</li></ul> <p data-svelte-h="svelte-1vjb6j9"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The new tensor.</p> <a id="module_utils/tensor.Tensor.sub_"></a> <h4 class="relative group"><a id="tensorsubval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsubval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.sub_(val)</span></h4> <p data-svelte-h="svelte-wqxtec">Subtract the tensor by a constant in place.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-esoi9q"><li><code>val</code> (<code>number</code>) — The value to subtract by.</li></ul> <p data-svelte-h="svelte-540ymd"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — Returns <code>this</code>.</p> <a id="module_utils/tensor.Tensor.clone"></a> <h4 class="relative group"><a id="tensorclone" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorclone"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.clone()</span></h4> <p data-svelte-h="svelte-zftqbb">Creates a deep copy of the current Tensor.</p> <p data-svelte-h="svelte-1hldqqc"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — A new Tensor with the same type, data, and dimensions as the original.</p> <a id="module_utils/tensor.Tensor.slice"></a> <h4 class="relative group"><a id="tensorsliceslices" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsliceslices"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.slice(slices)</span></h4> <p data-svelte-h="svelte-yalim1">Performs a slice operation on the Tensor along specified dimensions.</p> <p data-svelte-h="svelte-v4sb1d">Consider a Tensor that has a dimension of [4, 7]:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=" "><!-- HTML_TAG_START --><span class="hljs-string">[ 1, 2, 3, 4, 5, 6, 7]</span>
<span class="hljs-string">[ 8, 9, 10, 11, 12, 13, 14]</span>
<span class="hljs-string">[15, 16, 17, 18, 19, 20, 21]</span>
<span class="hljs-string">[22, 23, 24, 25, 26, 27, 28]</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1qggjsc">We can slice against the two dims of row and column, for instance in this
case we can start at the second element, and return to the second last,
like this:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=" "><!-- HTML_TAG_START --><span class="hljs-attribute">tensor</span>.slice([<span class="hljs-number">1</span>, -<span class="hljs-number">1</span>],<span class="hljs-meta"> [1, -1]);</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-gtrr4w">which would return:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=" "><!-- HTML_TAG_START --><span class="hljs-string">[ 9, 10, 11, 12, 13 ]</span>
<span class="hljs-string">[ 16, 17, 18, 19, 20 ]</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1f3qdhn"><li><code>slices</code> (<code>...(number|number[]|null)</code>) — The slice specifications for each dimension.
<ul><li>If a number is given, then a single element is selected.</li> <li>If an array of two numbers is given, then a range of elements [start, end (exclusive)] is selected.</li> <li>If null is given, then the entire dimension is selected.</li></ul></li></ul> <p data-svelte-h="svelte-cyj2t0"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — A new Tensor containing the selected elements.</p> <p data-svelte-h="svelte-sl4r8m"><strong>Throws</strong></p> <ul data-svelte-h="svelte-pea7lz"><li><code>Error</code> — If the slice input is invalid.</li></ul> <a id="module_utils/tensor.Tensor.permute"></a> <h4 class="relative group"><a id="tensorpermutedims" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorpermutedims"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.permute(dims)</span></h4> <p data-svelte-h="svelte-1g8ouql">Return a permuted version of this Tensor, according to the provided dimensions.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1aqw5t0"><li><code>dims</code> (<code>...number</code>) — Dimensions to permute.</li></ul> <p data-svelte-h="svelte-scfnhj"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The permuted tensor.</p> <a id="module_utils/tensor.Tensor.transpose"></a> <h4 class="relative group"><a id="tensortransposedims" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensortransposedims"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.transpose(dims)</span></h4> <p data-svelte-h="svelte-1g8ouql">Return a permuted version of this Tensor, according to the provided dimensions.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1aqw5t0"><li><code>dims</code> (<code>...number</code>) — Dimensions to permute.</li></ul> <p data-svelte-h="svelte-scfnhj"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The permuted tensor.</p> <a id="module_utils/tensor.Tensor.sum"></a> <h4 class="relative group"><a id="tensorsumdim-keepdim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsumdim-keepdim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.sum([dim], keepdim)</span></h4> <p data-svelte-h="svelte-yjryb1">Returns the sum of each row of the input tensor in the given dimension dim.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-13ta4l4"><li><code>dim</code> (<code>number</code> | <code>null</code>) <em>optional</em> — defaults to <code>null</code> — The dimension or dimensions to reduce. If <code>null</code>, all dimensions are reduced.</li> <li><code>keepdim</code> (<code>boolean</code>) — Whether the output tensor has <code>dim</code> retained or not.</li></ul> <p data-svelte-h="svelte-11n48z3"><strong>Returns:</strong> The summed tensor</p> <a id="module_utils/tensor.Tensor.norm"></a> <h4 class="relative group"><a id="tensornormp-dim-keepdim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensornormp-dim-keepdim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.norm([p], [dim], [keepdim])</span></h4> <p data-svelte-h="svelte-1okfsqx">Returns the matrix norm or vector norm of a given tensor.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-xapbb9"><li><code>p</code> (<code>number</code> | <code>string</code>) <em>optional</em> — defaults to <code>&#39;fro&#39;</code> — The order of norm</li> <li><code>dim</code> (<code>number</code> | <code>null</code>) <em>optional</em> — defaults to <code>null</code> — Specifies which dimension of the tensor to calculate the norm across.
If dim is None, the norm will be calculated across all dimensions of input.</li> <li><code>keepdim</code> (<code>boolean</code>) <em>optional</em> — defaults to <code>false</code> — Whether the output tensors have dim retained or not.</li></ul> <p data-svelte-h="svelte-6o5d47"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The norm of the tensor.</p> <a id="module_utils/tensor.Tensor.normalize_"></a> <h4 class="relative group"><a id="tensornormalizep-dim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensornormalizep-dim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.normalize_([p], [dim])</span></h4> <p data-svelte-h="svelte-1htpbrk">Performs <code>L_p</code> normalization of inputs over specified dimension. Operates in place.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-14c2lu6"><li><code>p</code> (<code>number</code>) <em>optional</em> — defaults to <code>2</code> — The exponent value in the norm formulation</li> <li><code>dim</code> (<code>number</code>) <em>optional</em> — defaults to <code>1</code> — The dimension to reduce</li></ul> <p data-svelte-h="svelte-6tzt61"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a><code>this</code> for operation chaining.</p> <a id="module_utils/tensor.Tensor.normalize"></a> <h4 class="relative group"><a id="tensornormalizep-dim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensornormalizep-dim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.normalize([p], [dim])</span></h4> <p data-svelte-h="svelte-1ztgqp">Performs <code>L_p</code> normalization of inputs over specified dimension.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-14c2lu6"><li><code>p</code> (<code>number</code>) <em>optional</em> — defaults to <code>2</code> — The exponent value in the norm formulation</li> <li><code>dim</code> (<code>number</code>) <em>optional</em> — defaults to <code>1</code> — The dimension to reduce</li></ul> <p data-svelte-h="svelte-1oavdpy"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The normalized tensor.</p> <a id="module_utils/tensor.Tensor.stride"></a> <h4 class="relative group"><a id="tensorstride" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorstride"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.stride()</span></h4> <p data-svelte-h="svelte-1a7u185">Compute and return the stride of this tensor.
Stride is the jump necessary to go from one element to the next one in the specified dimension dim.</p> <p data-svelte-h="svelte-6s9se0"><strong>Returns:</strong> <code>number[]</code> — The stride of this tensor.</p> <a id="module_utils/tensor.Tensor.squeeze"></a> <h4 class="relative group"><a id="tensorsqueezedim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsqueezedim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.squeeze([dim])</span></h4> <p data-svelte-h="svelte-qls17b">Returns a tensor with all specified dimensions of input of size 1 removed.</p> <p data-svelte-h="svelte-5nabmy">NOTE: The returned tensor shares the storage with the input tensor, so changing the contents of one will change the contents of the other.
If you would like a copy, use <code>tensor.clone()</code> before squeezing.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1k717xm"><li><code>dim</code> (<code>number</code> | <code>number[]</code> | <code>null</code>) <em>optional</em> — defaults to <code>null</code> — If given, the input will be squeezed only in the specified dimensions.</li></ul> <p data-svelte-h="svelte-y5gynj"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The squeezed tensor</p> <a id="module_utils/tensor.Tensor.squeeze_"></a> <h4 class="relative group"><a id="tensorsqueeze" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorsqueeze"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.squeeze_()</span></h4> <p data-svelte-h="svelte-1h868f7">In-place version of <a href="./tensor#module_utils/tensor.Tensor.squeeze"><code>Tensor.squeeze</code></a></p> <a id="module_utils/tensor.Tensor.unsqueeze"></a> <h4 class="relative group"><a id="tensorunsqueezedim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorunsqueezedim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.unsqueeze(dim)</span></h4> <p data-svelte-h="svelte-18ws76n">Returns a new tensor with a dimension of size one inserted at the specified position.</p> <p data-svelte-h="svelte-1tnr5gm">NOTE: The returned tensor shares the same underlying data with this tensor.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1etksbg"><li><code>dim</code> (<code>number</code>) — The index at which to insert the singleton dimension</li></ul> <p data-svelte-h="svelte-1gr7kfq"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The unsqueezed tensor</p> <a id="module_utils/tensor.Tensor.unsqueeze_"></a> <h4 class="relative group"><a id="tensorunsqueezedim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorunsqueezedim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.unsqueeze_(dim)</span></h4> <p data-svelte-h="svelte-fft3zr">In-place version of <a href="./tensor#module_utils/tensor.Tensor.unsqueeze"><code>Tensor.unsqueeze</code></a></p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1etksbg"><li><code>dim</code> (<code>number</code>) — The index at which to insert the singleton dimension</li></ul> <p data-svelte-h="svelte-1gr7kfq"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The unsqueezed tensor</p> <a id="module_utils/tensor.Tensor.flatten_"></a> <h4 class="relative group"><a id="tensorflatten" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorflatten"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.flatten_()</span></h4> <p data-svelte-h="svelte-1dz4klb">In-place version of <a href="./tensor#module_utils/tensor.Tensor.flatten"><code>Tensor.flatten</code></a></p> <a id="module_utils/tensor.Tensor.flatten"></a> <h4 class="relative group"><a id="tensorflattenstartdim-enddim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorflattenstartdim-enddim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.flatten(start_dim, end_dim)</span></h4> <p data-svelte-h="svelte-1gguudf">Flattens input by reshaping it into a one-dimensional tensor.
If <code>start_dim</code> or <code>end_dim</code> are passed, only dimensions starting with <code>start_dim</code>
and ending with <code>end_dim</code> are flattened. The order of elements in input is unchanged.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-lmm6g9"><li><code>start_dim</code> (<code>number</code>) — the first dim to flatten</li> <li><code>end_dim</code> (<code>number</code>) — the last dim to flatten</li></ul> <p data-svelte-h="svelte-1mrrajc"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The flattened tensor.</p> <a id="module_utils/tensor.Tensor.view"></a> <h4 class="relative group"><a id="tensorviewdims" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorviewdims"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.view(dims)</span></h4> <p data-svelte-h="svelte-d6gvut">Returns a new tensor with the same data as the <code>self</code> tensor but of a different <code>shape</code>.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-c014wo"><li><code>dims</code> (<code>...number</code>) — the desired size</li></ul> <p data-svelte-h="svelte-4zmit3"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The tensor with the same data but different shape</p> <a id="module_utils/tensor.Tensor.gt"></a> <h4 class="relative group"><a id="tensorgtval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorgtval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.gt(val)</span></h4> <p data-svelte-h="svelte-1tydf2w">Computes input &gt; val element-wise.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-i8swq2"><li><code>val</code> (<code>number</code>) — The value to compare with.</li></ul> <p data-svelte-h="svelte-pycdow"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — A boolean tensor that is <code>true</code> where input is greater than other and <code>false</code> elsewhere.</p> <a id="module_utils/tensor.Tensor.lt"></a> <h4 class="relative group"><a id="tensorltval" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorltval"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.lt(val)</span></h4> <p data-svelte-h="svelte-j2lp5o">Computes input &lt; val element-wise.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-i8swq2"><li><code>val</code> (<code>number</code>) — The value to compare with.</li></ul> <p data-svelte-h="svelte-q9kxal"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — A boolean tensor that is <code>true</code> where input is less than other and <code>false</code> elsewhere.</p> <a id="module_utils/tensor.Tensor.clamp_"></a> <h4 class="relative group"><a id="tensorclampmin-max" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorclampmin-max"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.clamp_(min, max)</span></h4> <p data-svelte-h="svelte-n34wwb">In-place version of <a href="./tensor#module_utils/tensor.Tensor.clamp"><code>Tensor.clamp</code></a></p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1tg8ykh"><li><code>min</code> (<code>number</code>) — lower-bound of the range to be clamped to</li> <li><code>max</code> (<code>number</code>) — upper-bound of the range to be clamped to</li></ul> <p data-svelte-h="svelte-1tzilly"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — the output tensor.</p> <a id="module_utils/tensor.Tensor.clamp"></a> <h4 class="relative group"><a id="tensorclampmin-max" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorclampmin-max"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.clamp(min, max)</span></h4> <p data-svelte-h="svelte-1hm8vtj">Clamps all elements in input into the range [ min, max ]</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1tg8ykh"><li><code>min</code> (<code>number</code>) — lower-bound of the range to be clamped to</li> <li><code>max</code> (<code>number</code>) — upper-bound of the range to be clamped to</li></ul> <p data-svelte-h="svelte-1tzilly"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — the output tensor.</p> <a id="module_utils/tensor.Tensor.round_"></a> <h4 class="relative group"><a id="tensorround" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorround"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.round_()</span></h4> <p data-svelte-h="svelte-xr24af">In-place version of <a href="./tensor#module_utils/tensor.Tensor.round"><code>Tensor.round</code></a></p> <a id="module_utils/tensor.Tensor.round"></a> <h4 class="relative group"><a id="tensorround" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorround"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.round()</span></h4> <p data-svelte-h="svelte-t5k6jp">Rounds elements of input to the nearest integer.</p> <p data-svelte-h="svelte-1tzilly"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — the output tensor.</p> <a id="module_utils/tensor.Tensor.repeat"></a> <h4 class="relative group"><a id="tensorrepeatrepeats" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorrepeatrepeats"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.repeat(repeats)</span></h4> <p data-svelte-h="svelte-1odz2y0">Repeats this tensor along the specified dimensions.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-3qluen"><li><code>repeats</code> (<code>...number</code>) — The number of times to repeat this tensor along each dimension.</li></ul> <p data-svelte-h="svelte-uciykv"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The repeated tensor.</p> <p data-svelte-h="svelte-sl4r8m"><strong>Throws</strong></p> <ul data-svelte-h="svelte-1baawd6"><li><code>Error</code> — If the number of repeats is less than the number of dimensions.</li></ul> <a id="module_utils/tensor.Tensor.tile"></a> <h4 class="relative group"><a id="tensortiledims" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensortiledims"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.tile(dims)</span></h4> <p data-svelte-h="svelte-278726">Constructs a tensor by repeating the elements of input. The dims argument specifies the number of repetitions in each dimension.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-g20lf6"><li><code>dims</code> (<code>...number</code>) — The number of repetitions per dimension.</li></ul> <p data-svelte-h="svelte-12pqw1z"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The tiled tensor.</p> <a id="module_utils/tensor.Tensor.to"></a> <h4 class="relative group"><a id="tensortotype" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensortotype"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Tensor.to(type)</span></h4> <p data-svelte-h="svelte-avw2a1">Performs Tensor dtype conversion.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-4na0e7"><li><code>type</code> (<a href="../transformers#module_transformers.DataType"><code>DataType</code></a>) — The desired data type.</li></ul> <p data-svelte-h="svelte-tksvp1"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The converted tensor.</p> <h2 class="relative group"><a id="functions" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#functions"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Functions</span></h2> <a id="module_utils/tensor.permute"></a> <h3 class="relative group"><a id="permutetensor-axes" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#permutetensor-axes"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>permute(tensor, axes)</span></h3> <p data-svelte-h="svelte-167n5bd">Permutes a tensor according to the provided axes.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-p3vq0o"><li><code>tensor</code> (<code>any</code>) — The input tensor to permute.</li> <li><code>axes</code> (<code>number[]</code>) — The axes to permute the tensor along.</li></ul> <p data-svelte-h="svelte-scfnhj"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The permuted tensor.</p> <a id="module_utils/tensor.interpolate"></a> <h3 class="relative group"><a id="interpolateinput-size-mode-aligncorners" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#interpolateinput-size-mode-aligncorners"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>interpolate(input, size, mode, align_corners)</span></h3> <p data-svelte-h="svelte-fju8tm">Interpolates an Tensor to the given size.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-zj5aqa"><li><code>input</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — The input tensor to interpolate. Data must be channel-first (i.e., [c, h, w])</li> <li><code>size</code> (<code>number[]</code>) — The output size of the image</li> <li><code>mode</code> (<code>string</code>) — The interpolation mode</li> <li><code>align_corners</code> (<code>boolean</code>) — Whether to align corners.</li></ul> <p data-svelte-h="svelte-la9u5u"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The interpolated tensor.</p> <a id="module_utils/tensor.interpolate_4d"></a> <h3 class="relative group"><a id="interpolate4dinput-options" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#interpolate4dinput-options"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>interpolate_4d(input, options)</span></h3> <p data-svelte-h="svelte-18v04la">Down/up samples the input.
Inspired by <a href="https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html" rel="nofollow">https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html</a>.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-pyxnkh"><li><code>input</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — the input tensor</li> <li><code>options</code> (<code>Object</code>) — the options for the interpolation
<ul><li><code>size</code> ([<code>number</code>, <code>number</code>] | [<code>number</code>, <code>number</code>, <code>number</code>] | [<code>number</code>, <code>number</code>, <code>number</code>, <code>number</code>]) <em>optional</em> — defaults to <code>null</code> — output spatial size.</li> <li><code>mode</code> (<code>&#39;nearest&#39;</code> | <code>&#39;bilinear&#39;</code> | <code>&#39;bicubic&#39;</code>) <em>optional</em> — defaults to <code>&#39;bilinear&#39;</code> — algorithm used for upsampling</li></ul></li></ul> <p data-svelte-h="svelte-1orx95k"><strong>Returns:</strong> <code>Promise</code>&lt;<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>&gt; — The interpolated tensor.</p> <a id="module_utils/tensor.matmul"></a> <h3 class="relative group"><a id="matmula-b" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#matmula-b"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>matmul(a, b)</span></h3> <p data-svelte-h="svelte-1yvow13">Matrix product of two tensors.
Inspired by <a href="https://pytorch.org/docs/stable/generated/torch.matmul.html" rel="nofollow">https://pytorch.org/docs/stable/generated/torch.matmul.html</a></p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-2woral"><li><code>a</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — the first tensor to be multiplied</li> <li><code>b</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — the second tensor to be multiplied</li></ul> <p data-svelte-h="svelte-177j51m"><strong>Returns:</strong> <code>Promise</code>&lt;<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>&gt; — The matrix product of the two tensors.</p> <a id="module_utils/tensor.rfft"></a> <h3 class="relative group"><a id="rfftx-a" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rfftx-a"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rfft(x, a)</span></h3> <p data-svelte-h="svelte-19dtamh">Computes the one dimensional Fourier transform of real-valued input.
Inspired by <a href="https://pytorch.org/docs/stable/generated/torch.fft.rfft.html" rel="nofollow">https://pytorch.org/docs/stable/generated/torch.fft.rfft.html</a></p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-jro1t8"><li><code>x</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — the real input tensor</li> <li><code>a</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — The dimension along which to take the one dimensional real FFT.</li></ul> <p data-svelte-h="svelte-1htfx44"><strong>Returns:</strong> <code>Promise</code>&lt;<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>&gt; — the output tensor.</p> <a id="module_utils/tensor.topk"></a> <h3 class="relative group"><a id="topkx-k" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#topkx-k"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>topk(x, [k])</span></h3> <p data-svelte-h="svelte-bd7moq">Returns the k largest elements of the given input tensor.
Inspired by <a href="https://pytorch.org/docs/stable/generated/torch.topk.html" rel="nofollow">https://pytorch.org/docs/stable/generated/torch.topk.html</a></p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-8ifejo"><li><code>x</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — the input tensor</li> <li><code>k</code> (<code>number</code>) <em>optional</em> — the k in “top-k”</li></ul> <p data-svelte-h="svelte-fxzvxn"><strong>Returns:</strong> <code>Promise</code>&lt;[<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>, <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>]&gt; — the output tuple of (Tensor, LongTensor) of top-k elements and their indices.</p> <a id="module_utils/tensor.slice"></a> <h3 class="relative group"><a id="slicedata-starts-ends-axes-steps" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#slicedata-starts-ends-axes-steps"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>slice(data, starts, ends, axes, [steps])</span></h3> <p data-svelte-h="svelte-9z0ni1">Slice a multidimensional float32 tensor.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1sx1mfv"><li><code>data</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — : Tensor of data to extract slices from</li> <li><code>starts</code> (<code>number[]</code>) — : 1-D array of starting indices of corresponding axis in axes</li> <li><code>ends</code> (<code>number[]</code>) — : 1-D array of ending indices (exclusive) of corresponding axis in axes</li> <li><code>axes</code> (<code>number[]</code>) — : 1-D array of axes that starts and ends apply to</li> <li><code>steps</code> (<code>number[]</code>) <em>optional</em> — : 1-D array of slice step of corresponding axis in axes.</li></ul> <p data-svelte-h="svelte-1yotckk"><strong>Returns:</strong> <code>Promise</code>&lt;<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>&gt; — Sliced data tensor.</p> <a id="module_utils/tensor.mean_pooling"></a> <h3 class="relative group"><a id="meanpoolinglasthiddenstate-attentionmask" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#meanpoolinglasthiddenstate-attentionmask"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>mean_pooling(last_hidden_state, attention_mask)</span></h3> <p data-svelte-h="svelte-11ei68w">Perform mean pooling of the last hidden state followed by a normalization step.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-rl06zt"><li><code>last_hidden_state</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — Tensor of shape [batchSize, seqLength, embedDim]</li> <li><code>attention_mask</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — Tensor of shape [batchSize, seqLength]</li></ul> <p data-svelte-h="svelte-1fe9adk"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — Returns a new Tensor of shape [batchSize, embedDim].</p> <a id="module_utils/tensor.layer_norm"></a> <h3 class="relative group"><a id="layernorminput-normalizedshape-options" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#layernorminput-normalizedshape-options"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>layer_norm(input, normalized_shape, options)</span></h3> <p data-svelte-h="svelte-7ivim4">Apply Layer Normalization for last certain number of dimensions.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-al6w2x"><li><code>input</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — The input tensor</li> <li><code>normalized_shape</code> (<code>number[]</code>) — input shape from an expected input of size</li> <li><code>options</code> (<code>Object</code>) — The options for the layer normalization
<ul><li><code>eps</code> (<code>number</code>) <em>optional</em> — defaults to <code>1e-5</code> — A value added to the denominator for numerical stability.</li></ul></li></ul> <p data-svelte-h="svelte-1oavdpy"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The normalized tensor.</p> <a id="module_utils/tensor.cat"></a> <h3 class="relative group"><a id="cattensors-dim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cattensors-dim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>cat(tensors, dim)</span></h3> <p data-svelte-h="svelte-k6p1db">Concatenates an array of tensors along a specified dimension.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-snreoa"><li><code>tensors</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>[]) — The array of tensors to concatenate.</li> <li><code>dim</code> (<code>number</code>) — The dimension to concatenate along.</li></ul> <p data-svelte-h="svelte-1cff1fo"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The concatenated tensor.</p> <a id="module_utils/tensor.stack"></a> <h3 class="relative group"><a id="stacktensors-dim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#stacktensors-dim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>stack(tensors, dim)</span></h3> <p data-svelte-h="svelte-8afo9v">Stack an array of tensors along a specified dimension.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1qd4xxq"><li><code>tensors</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>[]) — The array of tensors to stack.</li> <li><code>dim</code> (<code>number</code>) — The dimension to stack along.</li></ul> <p data-svelte-h="svelte-1rbuau6"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The stacked tensor.</p> <a id="module_utils/tensor.std_mean"></a> <h3 class="relative group"><a id="stdmeaninput-dim-correction-keepdim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#stdmeaninput-dim-correction-keepdim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>std_mean(input, dim, correction, keepdim)</span></h3> <p data-svelte-h="svelte-11plveb">Calculates the standard deviation and mean over the dimensions specified by dim. dim can be a single dimension or <code>null</code> to reduce over all dimensions.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-el24rd"><li><code>input</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — the input tenso</li> <li><code>dim</code> (<code>number</code> | <code>null</code>) — the dimension to reduce. If None, all dimensions are reduced.</li> <li><code>correction</code> (<code>number</code>) — difference between the sample size and sample degrees of freedom. Defaults to Bessel’s correction, correction=1.</li> <li><code>keepdim</code> (<code>boolean</code>) — whether the output tensor has dim retained or not.</li></ul> <p data-svelte-h="svelte-d6tqsa"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>[] — A tuple of (std, mean) tensors.</p> <a id="module_utils/tensor.mean"></a> <h3 class="relative group"><a id="meaninput-dim-keepdim" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#meaninput-dim-keepdim"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>mean(input, dim, keepdim)</span></h3> <p data-svelte-h="svelte-17f4oxi">Returns the mean value of each row of the input tensor in the given dimension dim.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-dm6fj4"><li><code>input</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — the input tensor.</li> <li><code>dim</code> (<code>number</code> | <code>null</code>) — the dimension to reduce.</li> <li><code>keepdim</code> (<code>boolean</code>) — whether the output tensor has dim retained or not.</li></ul> <p data-svelte-h="svelte-1drg8vk"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — A new tensor with means taken along the specified dimension.</p> <a id="module_utils/tensor.full"></a> <h3 class="relative group"><a id="fullsize-fillvalue" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#fullsize-fillvalue"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>full(size, fill_value)</span></h3> <p data-svelte-h="svelte-10qu7f7">Creates a tensor of size size filled with fill_value. The tensor’s dtype is inferred from fill_value.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-k977zc"><li><code>size</code> (<code>number[]</code>) — A sequence of integers defining the shape of the output tensor.</li> <li><code>fill_value</code> (<code>number</code> | <code>bigint</code> | <code>boolean</code>) — The value to fill the output tensor with.</li></ul> <p data-svelte-h="svelte-cy0yop"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The filled tensor.</p> <a id="module_utils/tensor.ones"></a> <h3 class="relative group"><a id="onessize" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#onessize"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>ones(size)</span></h3> <p data-svelte-h="svelte-1ayje0f">Returns a tensor filled with the scalar value 1, with the shape defined by the variable argument size.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-y7k42y"><li><code>size</code> (<code>number[]</code>) — A sequence of integers defining the shape of the output tensor.</li></ul> <p data-svelte-h="svelte-19ouz4u"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The ones tensor.</p> <a id="module_utils/tensor.ones_like"></a> <h3 class="relative group"><a id="onesliketensor" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#onesliketensor"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>ones_like(tensor)</span></h3> <p data-svelte-h="svelte-1wvb8sq">Returns a tensor filled with the scalar value 1, with the same size as input.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1p6un2q"><li><code>tensor</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — The size of input will determine size of the output tensor.</li></ul> <p data-svelte-h="svelte-19ouz4u"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The ones tensor.</p> <a id="module_utils/tensor.zeros"></a> <h3 class="relative group"><a id="zerossize" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#zerossize"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>zeros(size)</span></h3> <p data-svelte-h="svelte-1798kaw">Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-y7k42y"><li><code>size</code> (<code>number[]</code>) — A sequence of integers defining the shape of the output tensor.</li></ul> <p data-svelte-h="svelte-xkwmdg"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The zeros tensor.</p> <a id="module_utils/tensor.zeros_like"></a> <h3 class="relative group"><a id="zerosliketensor" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#zerosliketensor"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>zeros_like(tensor)</span></h3> <p data-svelte-h="svelte-9nnpip">Returns a tensor filled with the scalar value 0, with the same size as input.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1p6un2q"><li><code>tensor</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — The size of input will determine size of the output tensor.</li></ul> <p data-svelte-h="svelte-xkwmdg"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The zeros tensor.</p> <a id="module_utils/tensor.rand"></a> <h3 class="relative group"><a id="randsize" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#randsize"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>rand(size)</span></h3> <p data-svelte-h="svelte-106iz9p">Returns a tensor filled with random numbers from a uniform distribution on the interval [0, 1)</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-y7k42y"><li><code>size</code> (<code>number[]</code>) — A sequence of integers defining the shape of the output tensor.</li></ul> <p data-svelte-h="svelte-1crup90"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The random tensor.</p> <a id="module_utils/tensor.randn"></a> <h3 class="relative group"><a id="randnsize" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#randnsize"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>randn(size)</span></h3> <p data-svelte-h="svelte-m7g8n2">Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution).</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-y7k42y"><li><code>size</code> (<code>number[]</code>) — A sequence of integers defining the shape of the output tensor.</li></ul> <p data-svelte-h="svelte-1crup90"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The random tensor.</p> <a id="module_utils/tensor.quantize_embeddings"></a> <h3 class="relative group"><a id="quantizeembeddingstensor-precision" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#quantizeembeddingstensor-precision"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>quantize_embeddings(tensor, precision)</span></h3> <p data-svelte-h="svelte-185sm1b">Quantizes the embeddings tensor to binary or unsigned binary precision.</p> <p data-svelte-h="svelte-11fqvcp"><strong>Parameters</strong></p> <ul data-svelte-h="svelte-1debnw4"><li><code>tensor</code> (<a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a>) — The tensor to quantize.</li> <li><code>precision</code> (<code>&#39;binary&#39;</code> | <code>&#39;ubinary&#39;</code>) — The precision to use for quantization.</li></ul> <p data-svelte-h="svelte-18ho7nu"><strong>Returns:</strong> <a href="./tensor#module_utils/tensor.Tensor"><code>Tensor</code></a> — The quantized tensor.</p> <h2 class="relative group"><a id="type-definitions" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#type-definitions"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Type Definitions</span></h2> <a id="module_utils/tensor.DataType"></a> <h3 class="relative group"><a id="datatype" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#datatype"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>DataType</span></h3> <p data-svelte-h="svelte-czvi65"><em>Type:</em> <code>keyof typeof DataTypeMap</code></p> <a id="module_utils/tensor.DataArray"></a> <h3 class="relative group"><a id="dataarray" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#dataarray"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>DataArray</span></h3> <p data-svelte-h="svelte-19dv4sv"><em>Type:</em> <a href="./maths#module_utils/maths.AnyTypedArray"><code>AnyTypedArray</code></a> | <code>any[]</code></p> <a id="module_utils/tensor.NestArray"></a> <h3 class="relative group"><a id="nestarray" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#nestarray"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>NestArray</span></h3> <p data-svelte-h="svelte-2mif9c">This creates a nested array of a given type and depth (see examples).</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/transformers.js/blob/main/packages/transformers/docs/source/api/utils/tensor.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_1t06csc = {
assets: "/docs/transformers.js/pr_1665/en",
base: "/docs/transformers.js/pr_1665/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/transformers.js/pr_1665/en/_app/immutable/entry/start.cb58eb6f.js"),
import("/docs/transformers.js/pr_1665/en/_app/immutable/entry/app.9eafcf9d.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 23],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
155 kB
·
Xet hash:
9d0116914c272bdb15b24c6489080b0eab99f3f66faa11a89f8753880342b210

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.