Skip to content

Commit

Permalink
Style.
Browse files Browse the repository at this point in the history
  • Loading branch information
dickensc committed Feb 22, 2024
1 parent d06243e commit e6d5e18
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
*/
package org.linqs.psl.application.learning.weight.gradient.optimalvalue;

import org.linqs.psl.database.AtomStore;
import org.linqs.psl.database.Database;
import org.linqs.psl.model.atom.GroundAtom;
import org.linqs.psl.model.atom.RandomVariableAtom;
import org.linqs.psl.model.predicate.DeepPredicate;
import org.linqs.psl.model.rule.Rule;
import org.linqs.psl.util.Logger;

Expand Down Expand Up @@ -64,17 +60,6 @@ protected void addLearningLossWeightGradient() {

@Override
protected void addTotalAtomGradient() {
AtomStore atomStore = trainInferenceApplication.getTermStore().getAtomStore();

System.arraycopy(deepLatentAtomGradient, 0, deepGradient, 0, deepLatentAtomGradient.length);

// for (int atomIndex = 0; atomIndex < atomStore.size(); atomIndex++) {
// GroundAtom atom = atomStore.getAtom(atomIndex);
//
// if ((atom instanceof RandomVariableAtom) && (atom.getPredicate() instanceof DeepPredicate)) {
// log.trace("Atom: {} deepLatentEnergyGradient:{}",
// atom, deepGradient[atomIndex]);
// }
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,6 @@ protected void addTotalAtomGradient() {
}
}

private void addActionValue(float reward) {
AtomStore atomStore = trainInferenceApplication.getTermStore().getAtomStore();
for (int atomIndex = 0; atomIndex < atomStore.size(); atomIndex++) {
GroundAtom atom = atomStore.getAtom(atomIndex);

// Skip atoms that are not DeepAtoms.
if (!((atom instanceof RandomVariableAtom) && (atom.getPredicate() instanceof DeepPredicate))) {
continue;
}

addCategoryActionValue(atomIndex, (RandomVariableAtom) atom, reward);
}
}

private void addCategoryActionValue(int atomIndex, RandomVariableAtom atom, float reward) {
// Skip atoms not selected by the policy.
if (MathUtils.isZero(atom.getValue())) {
Expand Down
4 changes: 2 additions & 2 deletions psl-core/src/main/java/org/linqs/psl/database/AtomStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ public void close() {
}

if (connectedComponentsAtomIndexes != null) {
for (Integer componentIndex : connectedComponentsAtomIndexes.keySet()) {
connectedComponentsAtomIndexes.get(componentIndex).clear();
for (List<Integer> component : connectedComponentsAtomIndexes.values()) {
component.clear();
}

connectedComponentsAtomIndexes.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ public abstract class DeepModel {
protected static final String CONFIG_RELATIVE_DIR = "relative-dir";

private static final long SERVER_SLEEP_TIME_MS = (long)(0.5 * 1000);
private static int startingPort = Options.PREDICATE_DEEP_PYTHON_PORT.getInt();
private static Map<Integer, DeepModel> usedPorts = new HashMap<Integer, DeepModel>();
private static final int startingPort = Options.PREDICATE_DEEP_PYTHON_PORT.getInt();
private static final Map<Integer, DeepModel> usedPorts = new HashMap<Integer, DeepModel>();

protected String deepModel;
protected Map<String, String> pythonOptions;
protected String application;

protected int port;
protected static String pythonModule = Options.PREDICATE_DEEP_PYTHON_WRAPPER_MODULE.getString();
protected static String sharedMemoryPath = Options.PREDICATE_DEEP_SHARED_MEMORY_PATH.getString();
protected static final String pythonModule = Options.PREDICATE_DEEP_PYTHON_WRAPPER_MODULE.getString();
protected static final String sharedMemoryPath = Options.PREDICATE_DEEP_SHARED_MEMORY_PATH.getString();
protected Process pythonServerProcess;
protected RandomAccessFile sharedFile;
protected MappedByteBuffer sharedBuffer;
Expand Down

0 comments on commit e6d5e18

Please sign in to comment.