torch.is_anomaly_enabled
function is_anomaly_enabled(): booleanChecks if anomaly detection is enabled for gradient computation.
Anomaly detection detects NaN/Inf values in gradients during backpropagation and raises an error if found. This helps catch numerical instabilities early. PyTorch uses this to debug gradient flow problems.
Anomaly detection is not implemented in torch.js. Monitor gradients manually or use assertions if needed.
Returns
boolean– Always false in torch.js (anomaly detection not implemented)Examples
// Check if anomaly detection is enabled
const enabled = torch.is_anomaly_enabled();
// torch.js: always falseSee Also
- PyTorch torch.autograd.anomaly_mode.is_anomaly_enabled()
- is_anomaly_check_nan_enabled - Check NaN detection specifically