92 references to MathUtils
Microsoft.ML.Core (3)
Utilities\Stats.cs (3)
191double logkFac = MathUtils.LogFactorial(k); 209ret -= scale * MathUtils.Log(1 - 2 * u); 211ret += scale * MathUtils.Log(1 + 2 * u);
Microsoft.ML.Core.Tests (3)
UnitTests\TestVBuffer.cs (3)
99float l2 = MathUtils.Sqrt(l2Squared); 831var l2Dist2 = a.Items(all: true).Zip(b.Items(all: true), (av, bv) => MathUtils.Pow(av.Value - bv.Value, 2)).Sum(); 832var l2Dist = MathUtils.Sqrt(l2Dist2);
Microsoft.ML.Data (19)
Deprecated\Vector\VBufferMathUtils.cs (3)
41return MathUtils.Sqrt(NormSquared(in a)); 416int ind = MathUtils.ArgMax(srcValues); 452int ind = MathUtils.ArgMin(srcValues);
Deprecated\Vector\VectorUtils.cs (2)
385return MathUtils.Sqrt(L2DistSquared(in a, in b)); 512return MathUtils.Sqrt(CpuMathUtils.SumSq(a));
Evaluators\BinaryClassifierEvaluator.cs (2)
456return MathUtils.Entropy((NumTruePos + NumFalseNeg) / 478var priorLogLoss = MathUtils.Entropy(priorPos);
Evaluators\MultiOutputRegressionEvaluator.cs (1)
536dst = MathUtils.Sqrt(VectorUtils.L2DistSquared(in label, in score));
Prediction\Calibrator.cs (4)
1124float minC = MathUtils.Min(cOutputs); 1125float maxC = MathUtils.Max(cOutputs); 1128float minNC = MathUtils.Min(ncOutputs); 1129float maxNC = MathUtils.Max(ncOutputs);
Utils\LossFunctions.cs (7)
135float prediction = MathUtils.Sigmoid(output); 141float prediction = MathUtils.Sigmoid(output); 160var fullUpdate = (MathUtils.Sigmoid(-label * output) * label - dual) * invariant; 174return MathUtils.Entropy(dual, useLnNotLog2: true); 450return MathUtils.ExpSlow(-_beta * truth * output); 457return factor * MathUtils.ExpSlow(factor * output); 633return output - label * Math.Log(output) + MathUtils.LogGamma(label);
Microsoft.ML.Ensemble (2)
OutputCombiners\Median.cs (1)
85dst = MathUtils.GetMedianInPlace(src, src.Length);
OutputCombiners\MultiMedian.cs (1)
93editor.Values[i] = MathUtils.GetMedianInPlace(raw, count);
Microsoft.ML.FastTree (1)
FastTreeTweedie.cs (1)
558dst = MathUtils.ExpSlow(dst);
Microsoft.ML.KMeansClustering (7)
KMeansPlusPlusTrainer.cs (7)
642MathUtils.Sqrt(newClusterL2 - 2 * VectorUtils.DotProduct(in newClusterFeatures, in oldClusterFeatures) + oldClusterL2); 710float pointDistance = MathUtils.Sqrt(pointDistanceSquared); 1218float clusterDelta = MathUtils.Sqrt(VectorUtils.L2DistSquared(in Centroids[i], in centroids[i])); 1306_upperBound[n] = MathUtils.Sqrt(instanceNormSquared + minDistance); 1307_lowerBound[n] = MathUtils.Sqrt(instanceNormSquared + secMinDistance); 1337float bestDistance = MathUtils.Sqrt(VectorUtils.L2DistSquared(in features, in centroids[_bestCluster[n]])); 1343float distance = MathUtils.Sqrt(VectorUtils.L2DistSquared(in features, in centroids[j]));
Microsoft.ML.Mkl.Components (2)
OlsLinearRegression.cs (1)
529pValues[i] = (float)MathUtils.TStatisticToPValue(tValues[i], n - m);
VectorWhitening.cs (1)
416eigValues[i] = MathUtils.Sqrt(Math.Max(0, eigValues[i]) + ex.Epsilon);
Microsoft.ML.Parquet (1)
ParquetLoader.cs (1)
470var numBlocks = MathUtils.DivisionCeiling((long)parent.GetRowCount(), _readerOptions.Count);
Microsoft.ML.PCA (1)
PcaTrainer.cs (1)
651return MathUtils.Sqrt((norm2X - norm2U) / norm2X); // normalized error
Microsoft.ML.StandardTrainers (24)
FactorizationMachine\FactorizationMachineTrainer.cs (5)
347return MathUtils.Log(1 + MathUtils.ExpSlow(-margin)); 349return -margin + MathUtils.Log(1 + MathUtils.ExpSlow(margin)); 356return -sign * MathUtils.Sigmoid(-margin);
FactorizationMachine\FieldAwareFactorizationMachineUtils.cs (2)
47featureNorm = MathUtils.Sqrt(featureNorm); 132value = MathUtils.SigmoidSlow(value);
Optimizer\DifferentiableFunction.cs (1)
360return (float)(Math.Sqrt(-2 * Math.Log(a)) * MathUtils.Cos(2 * Math.PI * b));
Optimizer\LineSearch.cs (2)
102float t2 = Math.Sign(b.Step - a.Step) * MathUtils.Sqrt(t1 * t1 - a.Deriv * b.Deriv); 224private static readonly float _phi = (1 + MathUtils.Sqrt(5)) / 2;
Optimizer\OptimizationMonitor.cs (1)
172float crit = _unnormMeanImprovement * (1 - _lambda) / (1 - MathUtils.Pow(_lambda, state.Iter));
Optimizer\SgdOptimizer.cs (1)
192stepSize = 1 / (_t0 + MathUtils.Sqrt(n));
Standard\LinearModelParameters.cs (1)
756return MathUtils.ExpSlow(base.Score(in src));
Standard\LogisticRegression\LogisticRegression.cs (3)
199float logZ = MathUtils.SoftMax(s, -s); 202float modelProb1 = MathUtils.ExpSlow(s - logZ); 2610f : (float)(2 * WeightSum * MathUtils.Entropy(priorPosRate, true));
Standard\LogisticRegression\MulticlassLogisticRegression.cs (4)
257float logZ = MathUtils.SoftMax(scores.AsSpan(0, _numClasses)); 267float modelProb = MathUtils.ExpSlow(scores[c] - logZ); 1245float softmax = MathUtils.SoftMax(dst.Slice(0, NumberOfClasses)); 1247dst[i] = MathUtils.ExpSlow(dst[i] - softmax);
Standard\Online\AveragedLinear.cs (1)
247rate /= MathUtils.Sqrt((float)NumWeightUpdates + NumNoUpdates + 1);
Standard\Online\LinearSvm.cs (1)
243float normalizer = 1 / (MathUtils.Sqrt(_lambda) * VectorUtils.Norm(Weights) * Math.Abs(WeightsScale));
Standard\PoissonRegression\PoissonRegression.cs (2)
147_lossNormalizer += MathUtils.LogGamma(label + 1); 172float lambda = MathUtils.ExpSlow(dot);
Microsoft.ML.Tests (11)
CalibratedModelParametersTests.cs (1)
146rawScores[i] = MathUtils.Sigmoid(rawScores[i] - averageScore) > 0.5 ? 1 : 0;
FeatureContributionTests.cs (3)
336rawScores[i] = MathUtils.Sigmoid(rawScores[i] - averageScore) > 0.5 ? 1 : 0; 341var min = MathUtils.Min(rawScores); 342var max = MathUtils.Max(rawScores);
PermutationFeatureImportanceTests.cs (3)
979rawScores[i] = MathUtils.Sigmoid(rawScores[i] - averageScore) > 0.5 ? 1 : 0; 984var min = MathUtils.Min(rawScores); 985var max = MathUtils.Max(rawScores);
TrainerEstimators\TreeEstimators.cs (4)
569sum += MathUtils.SigmoidSlow(sigmoidScale * (float)nativeResult1[j + i * _classNumber]); 573double prob = MathUtils.SigmoidSlow(sigmoidScale * (float)nativeResult1[j + i * _classNumber]); 605sum += MathUtils.SigmoidSlow((float)sigmoidScale * (float)nativeResult1[j + i * _classNumber]); 609double prob = MathUtils.SigmoidSlow((float)sigmoidScale * (float)nativeResult1[j + i * _classNumber]);
Microsoft.ML.TimeSeries (4)
SrCnnAnomalyDetectionBase.cs (4)
187magList.Add(MathUtils.Sqrt((fftRe[i] * fftRe[i] + fftIm[i] * fftIm[i]))); 191List<Single> magLogList = magList.Select(x => x != 0 ? MathUtils.Log(x) : 0).ToList(); 196spectralList.Add(MathUtils.ExpSlow(magLogList[i] - filteredLogList[i])); 224ifftMagList.Add(MathUtils.Sqrt((ifftRe[i] * ifftRe[i] + ifftIm[i] * ifftIm[i])));
Microsoft.ML.Transforms (14)
Expression\BuiltinFunctions.cs (4)
563return MathUtils.Sin(a); 575return MathUtils.Sin(a * (Math.PI / 180)); 587return MathUtils.Cos(a); 599return MathUtils.Cos(a * (Math.PI / 180));
FourierDistributionSampler.cs (1)
186return (float)Stats.SampleFromGaussian(rand) * MathUtils.Sqrt(2 * _gamma);
GcnTransform.cs (3)
542return MathUtils.Sqrt(sumSq / length); 562return MathUtils.Sqrt(sumSq / length); 573return MathUtils.Sqrt(CpuMathUtils.SumSq(mean, values));
RandomFourierFeaturizing.cs (6)
377float median = MathUtils.GetMedianInPlace(distances, distances.Length); 558scale = MathUtils.Sqrt(2.0f / transformInfo.NewDim); 563scale = MathUtils.Sqrt(1.0f / transformInfo.NewDim); 588dstEditor.Values[i] = (float)MathUtils.Cos(dotProduct + transformInfo.RotationTerms[i]) * scale; 591dstEditor.Values[2 * i] = (float)MathUtils.Cos(dotProduct) * scale; 592dstEditor.Values[2 * i + 1] = (float)MathUtils.Sin(dotProduct) * scale;