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]Content copied to clipboard
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)