Rescale

class Rescale<T : DType, V>(ctx: ExecutionContext, val scale: Float = 255.0f) : TensorTransform<T, V> (source)

Rescales tensor values by dividing by a constant factor.

output = input / scale

This is commonly used to convert pixel values from 0, 255 to 0, 1 range.

Usage

val rescale = Rescale<FP32, Float>(ctx, scale = 255f)
val normalized = rescale.apply(imageData) // [0, 255] -> [0, 1]

Parameters

T

The tensor data type

V

The value type

ctx

The execution context for tensor operations

scale

The value to divide by (default: 255.0f for image normalization)

Constructors

Link copied to clipboard
constructor(ctx: ExecutionContext, scale: Float = 255.0f)

Properties

Link copied to clipboard

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 toString(): String