Unsqueeze

class Unsqueeze<T : DType, V>(ctx: ExecutionContext, val dim: Int) : TensorTransform<T, V> (source)

Adds a dimension of size 1 at the specified position.

Usage

val unsqueeze = Unsqueeze<FP32, Float>(ctx, dim = 0)
val batched = unsqueeze.apply(imageTensor) // [C, H, W] -> [1, C, H, W]

Parameters

T

The tensor data type

V

The value type

ctx

The execution context for tensor operations

dim

The dimension to add

Constructors

Link copied to clipboard
constructor(ctx: ExecutionContext, dim: Int)

Properties

Link copied to clipboard
val dim: Int

Functions

Link copied to clipboard
open override fun apply(input: Tensor<T, V>): Tensor<T, V>

Applies this transformation to the given input.

Link copied to clipboard
open override fun getOutputShape(inputShape: Shape): Shape

By default, tensor transforms preserve the input shape. Override this method if the transform changes the shape.

Link copied to clipboard
open override fun toString(): String