Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
IntroductionRenderer GalleryRenderersAnalysis
computeQuantilescomputePercentilescomputeCorrelationcomputeCovariancedetectOutliersdetectOutliersZScorecomputeExtendedStatsdescribeExtendedStatsQuantileResultCorrelationResultOutlierResultExtendedStatscreateDBSCANdbscanDBSCANDBSCAN.fitDBSCAN.destroyDBSCANOptionsDBSCANResultcreateHierarchicalClusteringhierarchicalClusteringHierarchicalClusteringHierarchicalClustering.fitHierarchicalClustering.destroyLinkageMethodDistanceMetricHierarchicalOptionsDendrogramNodeHierarchicalResultcomputeHistogramgetHistogramCentersnormalizeHistogramHistogramResultcreateKDEkdeKDEKDE.fitKDE.destroyKernelTypeKDEOptionsKDEResultcreateKMeanskmeansKMeansKMeans.fitKMeans.destroyKMeansOptionsKMeansResultcreatePCApcaPCAPCA.fitPCA.destroyPCAOptionsPCAResultthrottleProgressconsoleProgressProgressInfoProgressCallbackcomputeStatscomputeMinMaxdescribeStatsTensorStatscreateTSNEtsneTSNETSNE.fitTSNE.destroyTSNEOptionsTSNEResultcreateUMAPumapUMAPUMAP.fitUMAP.destroyUMAPOptionsUMAPResult
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. viz
  3. viz
  4. analysis
  5. computeMinMax

viz.analysis.computeMinMax

function computeMinMax(tensor: Tensor): Promise<{ min: number; max: number }>

Compute just min and max values (for performance when other stats not needed).

Returns only min and max by calling computeStats and extracting those values. Faster than computeStats if you only need the extremes. Useful for checking if values are within expected range or detecting overflow/underflow.

Parameters

tensorTensor
Input tensor on WebGPU device

Returns

Promise<{ min: number; max: number }>– Promise resolving to object with: - min: Minimum value - max: Maximum value

Examples

const {min, max} = await computeMinMax(weights);
if (max > 1000 || min < -1000) console.warn('Weights exploding!');

See Also

  • computeStats - For full statistics (mean, std, sum)
Previous
computeHistogram
Next
computePercentiles