@Override protected double[] rawScore(int n, NGram key) { final float[] f = map.get(key); if (f == null) { return null; } else { double[] d = new double[f.length]; for (int i = 0; i < d.length; i++) { d[i] = f[i]; } return d; } }
/** * Utility method to pull up the version number at which a walker was deprecated and the suggested replacement, if any * * @param walkerName the walker class name (not the full package) to check */ public static String getWalkerDeprecationInfo(final String walkerName) { return deprecatedGATKWalkers.get(walkerName).toString(); }
/** * Utility method to pull up the version number at which an annotation was deprecated and the suggested replacement, if any * * @param annotationName the annotation class name (not the full package) to check */ public static String getAnnotationDeprecationInfo(final String annotationName) { return deprecatedGATKAnnotations.get(annotationName).toString(); }
public void logTrainingScore(String prefix, int epoch, double trainingScore) { List<Performance> values = log.get(prefix); Performance perf = values.stream().filter(performance -> performance.epoch == epoch).findFirst().get(); perf.trainingScore = trainingScore; }
public void show(String prefix) { List<Performance> perfs = log.get(prefix); Performance perf = perfs.get(perfs.size() - 1); System.out.printf("%d\t%f\t%s%n", perf.epoch, perf.trainingScore, perf.formatValues()); }
/** * Sort records inside each chromosome by start position. */ public void sort() { for (String chromosome: store.keySet()){ List<BEDRecord> recordList = store.get(chromosome); recordList.sort(Comparator.comparingInt(value -> value.startPosition)); } } Comparator<BEDRecord> COMPARATOR = (r1, r2) -> Integer.compare(r1.startPosition,r2.startPosition);
@Override public float getW(@Nonnull Feature x) { String j = x.getFeature(); assert (j != null); Entry entry = _map.get(j); if (entry == null) { return 0.f; } return entry.W; }
public boolean contains(T key, int value) { IntCollection collection = map.get(key); return collection != null && collection.contains(value); }
/** * Gets the world with the given name out of the world manager if any such * world exists. * * @param name The name of the world to be retrieved * @return The world if found or null otherwise */ public WorldAdapter getWorld(String name) { if (!GoMint.instance().isMainThread()) { LOGGER.warn("Getting a world from an async thread. This is not safe and can lead to CME", new Exception()); } return this.loadedWorlds.get(name); }
@Override public int get(K k, K cond) { if (!distributions.containsKey(cond)) { return 0; } return distributions.get(cond).get(k); }
@Override public Object2IntFrequencyDistribution<K> getConditionalDistribution(K cond) { if (distributions.containsKey(cond)) { return distributions.get(cond); } return new Object2IntFrequencyDistributionFastutil<K>(); }
private Object get(Object arg) { Object key = keyInputOI.getPrimitiveJavaObject(arg); Object value = cache.get(lookupKey(key)); return (value == null) ? defaultValue : value; }
@Override public LabelMapper getLabelMapper(String outputName) { LabelMapper cached = cachedLabelMaper.get(outputName); if (cached != null) { return cached; } else { cached = getInternalLabelMapper(outputName, 0); cachedLabelMaper.put(outputName, cached); return cached; } }
@Override public float update(@Nonnull final Object feature, final float weight, final float gradient) { IWeightValue auxWeight = auxWeights.get(feature); if (auxWeight == null) { auxWeight = new WeightValue.WeightValueParamsF2(weight, 0.f, 0.f); auxWeights.put(feature, auxWeight); } else { auxWeight.set(weight); } return update(auxWeight, gradient); }
@Override public float update(@Nonnull final Object feature, final float weight, final float gradient) { IWeightValue auxWeight = auxWeights.get(feature); if (auxWeight == null) { auxWeight = new WeightValue.WeightValueParamsF2(weight, 0.f, 0.f); auxWeights.put(feature, auxWeight); } else { auxWeight.set(weight); } return update(auxWeight, gradient); }
@Override public float update(@Nonnull final Object feature, final float weight, final float gradient) { IWeightValue auxWeight = auxWeights.get(feature); if (auxWeight == null) { auxWeight = new WeightValue.WeightValueParamsF2(weight, 0.f, 0.f); auxWeights.put(feature, auxWeight); } else { auxWeight.set(weight); } return update(auxWeight, gradient); }
public void remove(T key, int value) { IntCollection collection = map.get(key); if (collection != null) { collection.rem(value); if (collection.isEmpty()) { map.remove(key); } } }
@Override protected void setW(@Nonnull Feature x, float nextWi) { String j = x.getFeature(); assert (j != null); Entry entry = _map.get(j); if (entry == null) { float[] Vf = initV(); entry = new Entry(nextWi, Vf); _map.put(j, entry); } else { entry.W = nextWi; } }
/** * Add a record to the set of records. * * @param record */ public void add(BEDRecord record) { ObjectArrayList<BEDRecord> recordList = store.get(record.chromosome); if (recordList == null) { recordList = new ObjectArrayList<>(); store.put(record.chromosome, recordList); } recordList.add(record); }
@Override public float update(@Nonnull final Object feature, final float weight, final float gradient) { IWeightValue auxWeight = auxWeights.get(feature); if (auxWeight == null) { auxWeight = new WeightValue.WeightValueParamsF2(weight, 0.f, 0.f); auxWeights.put(feature, auxWeight); } else { auxWeight.set(weight); } final float newWeight = update(auxWeight, gradient); if (newWeight == 0.f) { auxWeights.remove(feature); } return newWeight; }