Skip to content

Commit

Permalink
Updated logging and gradlew permissons
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankitanovski committed Apr 30, 2019
1 parent 361a285 commit 2523fdd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ publishing {
mavenJava(MavenPublication) {
groupId 'com.github.fair-search'
artifactId 'fairsearchdeltr-java'
version '1.0.0'

version '0.0.1'
from components.java
}
}
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
20 changes: 9 additions & 11 deletions src/main/java/com/github/fairsearch/deltr/Trainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ public double[] train(int[] queryIds, int[] protectedElementFeature, INDArray fe

});

LOGGER.info("pred: " + (System.currentTimeMillis() - stepStart));
LOGGER.info(String.format("Prediction computed in %d ms", (System.currentTimeMillis() - stepStart)));
stepStart = System.currentTimeMillis();

//get the cost/loss for all queries
TrainStep trainStep = calculateCost(trainingScores, predictedScores, queryIds,
protectedElementFeature, dataPerQueryPredicted);

LOGGER.info(" cost: " + (System.currentTimeMillis() - stepStart));
LOGGER.info("Cost: " + (System.currentTimeMillis() - stepStart));
stepStart = System.currentTimeMillis();

INDArray J = trainStep.getCost().add(predictedScores.mul(predictedScores).mul(this.lambda));
Expand All @@ -107,7 +107,7 @@ public double[] train(int[] queryIds, int[] protectedElementFeature, INDArray fe
INDArray grad = calculateGradient(featureMatrix, trainingScores, predictedScores, queryIds,
protectedElementFeature, dataPerQueryPredicted);

LOGGER.info(" grad: " + (System.currentTimeMillis() - stepStart));
LOGGER.info(String.format("Gradient computed in %d ms", (System.currentTimeMillis() - stepStart)));

//add additional items in trainStep
trainStep.setOmega(omega);
Expand All @@ -125,7 +125,7 @@ public double[] train(int[] queryIds, int[] protectedElementFeature, INDArray fe
this.log.add(trainStep);

// log iteration
LOGGER.info("Iteration-" + t +":" + (System.currentTimeMillis() - startTime));
LOGGER.info(String.format("Iteration %d done in %d ms", t, (System.currentTimeMillis() - startTime)));

}

Expand Down Expand Up @@ -160,13 +160,13 @@ private INDArray calculateGradient(INDArray trainingFeatures, INDArray trainingS
//L2
long stepTime = System.currentTimeMillis();
if(i % 100 == 0) {
LOGGER.info(" grad-step-1:" + (System.currentTimeMillis()-stepTime));
LOGGER.info(String.format("Gradient Step 1 computed in %d ms", (System.currentTimeMillis()-stepTime)));
stepTime = System.currentTimeMillis();
}
double l2 = 1.0 / Transforms.exp(dataPerQueryPredicted.get(keyGen(q, predictedScores)))
.sumNumber().doubleValue();
if(i % 100 == 0) {
LOGGER.info(" grad-step-2:" + (System.currentTimeMillis()-stepTime));
LOGGER.info(String.format("Gradient Step 2 computed in %d ms", (System.currentTimeMillis()-stepTime)));
stepTime = System.currentTimeMillis();
}

Expand All @@ -175,7 +175,7 @@ private INDArray calculateGradient(INDArray trainingFeatures, INDArray trainingS
.mmul(Transforms.exp(dataPerQueryPredicted.get(keyGen(q, predictedScores))))
.mul(l2);
if(i % 100 == 0) {
LOGGER.info(" grad-step-3:" + (System.currentTimeMillis()-stepTime));
LOGGER.info(String.format("Gradient Step 3 computed in %d ms", (System.currentTimeMillis()-stepTime)));
stepTime = System.currentTimeMillis();
}
//L1
Expand All @@ -187,7 +187,7 @@ private INDArray calculateGradient(INDArray trainingFeatures, INDArray trainingS
//L deriv
res = res.div(Math.log(predictedScores.length()));
if(i % 100 == 0) {
LOGGER.info(" grad-step-4:" + (System.currentTimeMillis()-stepTime));
LOGGER.info(String.format("Gradient Step 4 computed in %d ms", (System.currentTimeMillis()-stepTime)));
stepTime = System.currentTimeMillis();
}
if(!this.noExposure) {
Expand All @@ -197,8 +197,7 @@ private INDArray calculateGradient(INDArray trainingFeatures, INDArray trainingS
.mul(exposureDiff(predictedScores, queryIds, q, protectedIdxs)).transpose());
}
if(i % 100 == 0) {
LOGGER.info(" grad-step-5:" + (System.currentTimeMillis()-stepTime));
stepTime = System.currentTimeMillis();
LOGGER.info(String.format("Gradient Step 5 computed in %d ms", (System.currentTimeMillis()-stepTime)));
}
gradient.putRow(i, res);
});
Expand All @@ -225,7 +224,6 @@ private INDArray normalizedToppProtDerivPerGroupDiff(INDArray trainingScores, IN
predictionsGroup.getProtectedItemsPerQuery(),
predictionsGroup.getJudgementsPerQuery());

// return u2.sub(u3);
this.normalizedToppProtDerivPerGroupDiffCache.put(key, u2.sub(u3));
}
//
Expand Down

0 comments on commit 2523fdd

Please sign in to comment.