MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / MinMaxNormalization

Function MinMaxNormalization

optimizers/AdaFisher.py:30–45  ·  view source on GitHub ↗

Scales tensor values to range [0,1] using min-max normalization. Args: tensor: Input tensor epsilon: Small value to prevent division by zero (default: 1e-6) Returns: Normalized tensor with values in [0,1]

(tensor: Tensor, epsilon: float = 1e-6)

Source from the content-addressed store, hash-verified

28
29
30def MinMaxNormalization(tensor: Tensor, epsilon: float = 1e-6) -> Tensor:
31 """
32 Scales tensor values to range [0,1] using min-max normalization.
33
34 Args:
35 tensor: Input tensor
36 epsilon: Small value to prevent division by zero (default: 1e-6)
37
38 Returns:
39 Normalized tensor with values in [0,1]
40 """
41 tensor = smart_detect_inf(tensor)
42 min_tensor = tensor.min()
43 max_tensor = tensor.max()
44 range_tensor = max_tensor - min_tensor
45 return tensor.add_(-min_tensor).div_(range_tensor + epsilon)
46
47
48def update_running_avg(new: Tensor, current: Tensor, gamma: float):

Callers 2

_save_inputMethod · 0.70
_save_grad_outputMethod · 0.70

Calls 1

smart_detect_infFunction · 0.85

Tested by

no test coverage detected