Skip to content

Commit

Permalink
Parameter movement.
Browse files Browse the repository at this point in the history
  • Loading branch information
dickensc committed Sep 11, 2023
1 parent 2bc8296 commit 3028ff9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,18 @@ protected void measureEpochParameterMovement() {
float deepAtomValueMovement = 0.0f;

for (int i = 0; i < mutableRules.size(); i++) {
weightMovement += Math.abs(epochStartWeights[i] - mutableRules.get(i).getWeight());
weightMovement += Math.pow(epochStartWeights[i] - mutableRules.get(i).getWeight(), 2.0f);
}
log.trace("Epoch Weight Movement: {}", weightMovement);

int numDeepAtoms = 0;
for (int i = 0; i < epochStartDeepAtomValues.length; i++) {
if (trainFullTermStore.getAtomStore().getAtom(i).getPredicate() instanceof DeepPredicate) {
deepAtomValueMovement += Math.abs(epochStartDeepAtomValues[i] - trainFullTermStore.getAtomStore().getAtomValues()[i]);
numDeepAtoms++;
deepAtomValueMovement += Math.pow(epochStartDeepAtomValues[i] - trainFullTermStore.getAtomStore().getAtomValues()[i], 2.0f);
}
}
deepAtomValueMovement = deepAtomValueMovement / numDeepAtoms;
log.trace("Epoch Deep Atom Value Movement: {}", deepAtomValueMovement);

// By default, there are no internal parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ protected void epochStart(int epoch) {
protected void measureEpochParameterMovement() {
super.measureEpochParameterMovement();

log.trace("Epoch Internal Parameter Movement: {}", proxRuleObservedAtomsValueEpochMovement);

parameterMovement += proxRuleObservedAtomsValueEpochMovement;

log.trace("Epoch Internal Parameter Movement: {}", proxRuleObservedAtomsValueEpochMovement);
}

@Override
Expand Down Expand Up @@ -438,7 +438,7 @@ protected void internalParameterGradientStep(int epoch) {
for (int i = 0; i < proxRules.length; i++) {
float newProxRuleObservedAtomsValue = Math.min(Math.max(
proxRuleObservedAtoms[i].getValue() - proxRuleObservedAtomValueStepSize * proxRuleObservedAtomValueGradient[i], 0.0f), 1.0f);
proxRuleObservedAtomsValueEpochMovement += Math.abs(proxRuleObservedAtoms[i].getValue() - newProxRuleObservedAtomsValue);
proxRuleObservedAtomsValueEpochMovement += Math.pow(proxRuleObservedAtoms[i].getValue() - newProxRuleObservedAtomsValue, 2.0f);

proxRuleObservedAtoms[i]._assumeValue(newProxRuleObservedAtomsValue);
atomValues[proxRuleObservedAtomIndexes[i]] = newProxRuleObservedAtomsValue;
Expand Down

0 comments on commit 3028ff9

Please sign in to comment.