Reshape
class Reshape<T : DType, V>(ctx: ExecutionContext, val newShape: Shape) : TensorTransform<T, V> (source)
Reshapes a tensor to a new shape without changing the data.
The total number of elements must remain the same.
Usage
val reshape = Reshape<FP32, Float>(ctx, Shape(1, 3, 224, 224))
val batched = reshape.apply(imageTensor) // Add batch dimensionContent copied to clipboard
Parameters
T
The tensor data type
V
The value type
ctx
The execution context for tensor operations
newShape
The target shape