Skip to content

Commit

Permalink
Add regularization to prox value.
Browse files Browse the repository at this point in the history
  • Loading branch information
dickensc committed Sep 8, 2023
1 parent 5c49c87 commit ad1c05c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ protected void doLearn() {
clipWeightGradient();
}

gradientStep(epoch);

float batchObjective = computeTotalLoss();

gradientStep(epoch);

long batchEnd = System.currentTimeMillis();

log.trace("Batch: {} -- Weight Learning Objective: {}, Gradient Magnitude: {}, Iteration Time: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,17 @@ private float computeEnergyDifference(float[] incompatibilityDifference){
}

private float computeTotalProxValue(float[] proxRuleIncompatibility) {
float regularizationParameter = 0.0f;
if (trainInferenceApplication.getReasoner() instanceof DualBCDReasoner) {
regularizationParameter = (float)((DualBCDReasoner)trainInferenceApplication.getReasoner()).regularizationParameter;
}

float totalProxValue = 0.0f;
for (int i = 0; i < proxRules.length; i++) {
proxRuleIncompatibility[i] = proxRuleObservedAtoms[i].getValue() - augmentedInferenceAtomValueState[proxRuleIndexToRVAtomIndex.get(i)];
totalProxValue += Math.pow(proxRuleIncompatibility[i], 2.0f);
}
totalProxValue = proxRuleWeight * totalProxValue;
totalProxValue = (proxRuleWeight + regularizationParameter) * totalProxValue;

return totalProxValue;
}
Expand Down

0 comments on commit ad1c05c

Please sign in to comment.