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