/** * Sets each value of target to be target[k]-arg[k] for all keys k in target. */ public static <E> void subtractInPlace(Counter<E> target, Counter<E> arg) { for (E key : arg.keySet()) { target.decrementCount(key, arg.getCount(key)); } }
public void learn(Pair<CandidateAction, CandidateAction> actions) { CandidateAction goodAction = actions.first; CandidateAction badAction = actions.second; if (badAction.cost == 0) { CandidateAction tmp = goodAction; goodAction = badAction; badAction = tmp; } Counter<String> features = new ClassicCounter<>(goodAction.features); for (Map.Entry<String, Double> e : badAction.features.entrySet()) { features.decrementCount(e.getKey(), e.getValue()); } learn(features, 0, badAction.cost); } }
public void learn(Example correct, Example incorrect, Map<Integer, CompressedFeatureVector> mentionFeatures, Compressor<String> compressor, ErrorType errorType) { Counter<String> cFeatures = meta.getFeatures(correct, mentionFeatures, compressor); Counter<String> iFeatures = meta.getFeatures(incorrect, mentionFeatures, compressor); for (Map.Entry<String, Double> e : cFeatures.entrySet()) { iFeatures.decrementCount(e.getKey(), e.getValue()); } if (multiplicativeCost) { classifier.learn(iFeatures, 1.0, costs[errorType.id], loss); } else { classifier.learn(iFeatures, 1.0, 1.0, losses[errorType.id]); } } }
/** * Sets each value of target to be target[k]-arg[k] for all keys k in target. */ public static <E> void subtractInPlace(Counter<E> target, Counter<E> arg) { for (E key : arg.keySet()) { target.decrementCount(key, arg.getCount(key)); } }
/** * Sets each value of target to be target[k]-arg[k] for all keys k in target. */ public static <E> void subtractInPlace(Counter<E> target, Counter<E> arg) { for (E key : arg.keySet()) { target.decrementCount(key, arg.getCount(key)); } }
/** * Sets each value of target to be target[k]-arg[k] for all keys k in target. */ public static <E> void subtractInPlace(Counter<E> target, Counter<E> arg) { for (E key : arg.keySet()) { target.decrementCount(key, arg.getCount(key)); } }
/** * Sets each value of target to be target[k]-arg[k] for all keys k in target. */ public static <E> void subtractInPlace(Counter<E> target, Counter<E> arg) { for (E key : arg.keySet()) { target.decrementCount(key, arg.getCount(key)); } }
public void learn(Pair<CandidateAction, CandidateAction> actions) { CandidateAction goodAction = actions.first; CandidateAction badAction = actions.second; if (badAction.cost == 0) { CandidateAction tmp = goodAction; goodAction = badAction; badAction = tmp; } Counter<String> features = new ClassicCounter<>(goodAction.features); for (Map.Entry<String, Double> e : badAction.features.entrySet()) { features.decrementCount(e.getKey(), e.getValue()); } learn(features, 0, badAction.cost); } }
public void learn(Example correct, Example incorrect, Map<Integer, CompressedFeatureVector> mentionFeatures, Compressor<String> compressor, ErrorType errorType) { Counter<String> cFeatures = meta.getFeatures(correct, mentionFeatures, compressor); Counter<String> iFeatures = meta.getFeatures(incorrect, mentionFeatures, compressor); for (Map.Entry<String, Double> e : cFeatures.entrySet()) { iFeatures.decrementCount(e.getKey(), e.getValue()); } if (multiplicativeCost) { classifier.learn(iFeatures, 1.0, costs[errorType.id], loss); } else { classifier.learn(iFeatures, 1.0, 1.0, losses[errorType.id]); } } }