Skip to content

Commit b635e93

Browse files
author
Daniel Drews
committed
Round #2
1 parent 8886bd8 commit b635e93

File tree

21 files changed

+182
-558
lines changed

21 files changed

+182
-558
lines changed

src/Microsoft.ML.CpuMath/Thunk.cs

Lines changed: 122 additions & 122 deletions
Large diffs are not rendered by default.

src/Microsoft.ML.Data/DataLoadSave/Text/TextLoaderParser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ private sealed class ParseStats
137137
private volatile int _cref;
138138

139139
// Total number of rows, number of unparsable values, number of format errors.
140-
private /*volatile*/ long _rowCount;
141-
private /*volatile*/ long _badCount;
142-
private /*volatile*/ long _fmtCount;
140+
private long _rowCount;
141+
private long _badCount;
142+
private long _fmtCount;
143143

144144
public ParseStats(IChannelProvider provider, int cref, long maxShow = MaxShow)
145145
{

src/Microsoft.ML.FastTree/Application/LogLossApplication.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,7 @@ protected override void GetGradientInOneQuery(int query, int threadIndex)
106106
double delta = (_coef * labelDiff) / (1.0 + Math.Exp(_coef * labelDiff * (_scores[d1] - _scores[d2])));
107107

108108
_gradient[d1] += delta;
109-
_gradient[d2] -= delta;
110-
/*
111-
double labelDiff = (labels[d1] - labels[d2]);
112-
double margin = labelDiff * (_scores[d1] - _scores[d2]);
113-
if (_coef - margin > 0)
114-
{
115-
_gradient[d1] += 0.01 * labelDiff;
116-
_gradient[d2] -= 0.01 * labelDiff;
117-
}
118-
*/
109+
_gradient[d2] -= delta;
119110
}
120111
}
121112
}

src/Microsoft.ML.FastTree/Application/WinLossSurplusApplication.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ protected override void GetGradientInOneQuery(int query, int threadIndex)
120120

121121
double inverseMaxDCG = _inverseMaxDCGT[query];
122122

123-
//int[] permutation = (threadIndex < 0 ? new int[numDocuments] : _permutationBuffers[threadIndex]);
124123
int[] permutation = _permutationBuffers[threadIndex];
125124

126125
short[] labels = Labels;

src/Microsoft.ML.FastTree/Dataset/FeatureFlock.cs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -698,20 +698,6 @@ public void FillSplitCandidatesCategoricalLowPopulation(LeastSquaresRegressionTr
698698
var binStats = virtualBins[i];
699699
catFeatureCount += 1 + binStats.SubFeatures.Length;
700700

701-
/*int feature = features[i];
702-
int subfeature = feature - featureMin;
703-
Contracts.Assert(0 <= subfeature && subfeature < Flock.Count);
704-
Contracts.Assert(subfeature <= feature);
705-
Contracts.Assert(learner.TrainData.FlockToFirstFeature(flock) == feature - subfeature);
706-
Contracts.Assert(featureUseCount[feature] >= 0);
707-
Contracts.Assert(Flock.BinCount(subfeature) == 2);
708-
Contracts.Assert(GetMaxBorder(subfeature) == GetMinBorder(subfeature));
709-
710-
var binStats = GetBinStats(GetMinBorder(subfeature));
711-
sumGTTargets += binStats.SumTargets;
712-
if (hasWeights)
713-
sumGTWeights += binStats.SumWeights;*/
714-
715701
sumGTTargets += binStats.SumTargets;
716702
gtCount += binStats.Count;
717703
docsInCurrentGroup += binStats.Count;
@@ -933,21 +919,7 @@ public void FillSplitCandidatesCategoricalNeighborBundling(LeastSquaresRegressio
933919
{
934920
var binStats = virtualBins[i];
935921
catFeatureCount += 1 + binStats.SubFeatures.Length;
936-
937-
/*int feature = features[i];
938-
int subfeature = feature - featureMin;
939-
Contracts.Assert(0 <= subfeature && subfeature < Flock.Count);
940-
Contracts.Assert(subfeature <= feature);
941-
Contracts.Assert(learner.TrainData.FlockToFirstFeature(flock) == feature - subfeature);
942-
Contracts.Assert(featureUseCount[feature] >= 0);
943-
Contracts.Assert(Flock.BinCount(subfeature) == 2);
944-
Contracts.Assert(GetMaxBorder(subfeature) == GetMinBorder(subfeature));
945-
946-
var binStats = GetBinStats(GetMinBorder(subfeature));
947-
sumGTTargets += binStats.SumTargets;
948-
if (hasWeights)
949-
sumGTWeights += binStats.SumWeights;*/
950-
922+
951923
sumGTTargets += binStats.SumTargets;
952924
gtCount += binStats.Count;
953925
docsInCurrentGroup += binStats.Count;

src/Microsoft.ML.FastTree/Dataset/SegmentIntArray.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,8 @@ public static void StatsOfBestEncoding(uint[] ivalues, int bitsForMaxItem, bool
168168

169169
max = 0;
170170
bits = TransitionCost;
171-
//IEnumerator<int> ienum = ivalues.GetEnumerator();
172-
//while (ienum.MoveNext())
173171
for (int i = 0; i < ivalues.Length; ++i)
174172
{
175-
//uint val = (uint)ienum.Current;
176173
uint val = (uint)ivalues[i];
177174
if (val > max)
178175
max = val;

src/Microsoft.ML.FastTree/Dataset/SparseIntArray.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,13 +546,9 @@ public unsafe int this[int virtualIndex]
546546
{
547547
get
548548
{
549-
//if (virtualIndex < _index) throw new Exception("Index must move forward");
550-
551549
if (virtualIndex < _nextIndex)
552550
return 0;
553551

554-
//if (virtualIndex >= _array._length) throw new IndexOutOfRangeException();
555-
556552
if (virtualIndex == _nextIndex)
557553
return _array._values[_pos];
558554

@@ -561,7 +557,6 @@ public unsafe int this[int virtualIndex]
561557
{
562558
while (_pos < _array._values.Length)
563559
{
564-
//_index = _nextIndex;
565560
_nextIndex += pDeltas[_pos];
566561
if (virtualIndex < _nextIndex)
567562
return 0;

src/Microsoft.ML.FastTree/FastTreeRanking.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ private void SetupSecondaryGains(Arguments args)
579579
_secondaryMetricShare = 0.0;
580580
return;
581581
}
582-
//for (int i = 0; i < _secondaryGains.Length; ++i) _secondaryGains[i] *= cmd.secondaryMetricShare;
583582
_secondaryInverseMaxDCGT = DCGCalculator.MaxDCG(_secondaryGains, Dataset.Boundaries,
584583
new int[] { args.lambdaMartMaxTruncation })[0].Select(d => 1.0 / d).ToArray();
585584
}
@@ -726,7 +725,6 @@ protected override void GetGradientInOneQuery(int query, int threadIndex)
726725
double inverseMaxDcg = _inverseMaxDcgt[query];
727726
double secondaryInverseMaxDcg = _secondaryMetricShare == 0 ? 0.0 : _secondaryInverseMaxDcgt[query];
728727

729-
//int[] permutation = (threadIndex < 0 ? new int[numDocuments] : _permutationBuffers[threadIndex]);
730728
int[] permutation = _permutationBuffers[threadIndex];
731729

732730
short[] labels = _labels;

src/Microsoft.ML.FastTree/Training/ScoreTracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void Initialize(ScoreTracker scores1, RegressionTree tree, DocumentPartit
5353
}
5454

5555
//InitScores -initScores can be null in such case the scores are reinitialized to Zero
56-
private void InitializeScores(double[] initScores /* = null */)
56+
private void InitializeScores(double[] initScores)
5757
{
5858
if (initScores == null)
5959
{

0 commit comments

Comments
 (0)