(Dl4j) performance improvments (#9078)
* Removed invoking the boolean constructor Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com> * Use bulk operations instead of iteration Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com> * Removed manuall array copy Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>master
parent
1de8837c39
commit
73b08c7254
|
@ -205,9 +205,7 @@ public class KerasTokenizer {
|
|||
ArrayList<String> sortedVocabulary = new ArrayList<>();
|
||||
if (outOfVocabularyToken != null)
|
||||
sortedVocabulary.add(outOfVocabularyToken);
|
||||
for (String word: sortedWordCounts.keySet()) {
|
||||
sortedVocabulary.add(word);
|
||||
}
|
||||
sortedVocabulary.addAll(sortedWordCounts.keySet());
|
||||
|
||||
for (int i = 0; i < sortedVocabulary.size(); i++)
|
||||
wordIndex.put(sortedVocabulary.get(i), i+1);
|
||||
|
|
|
@ -96,9 +96,7 @@ public class ReshapePreprocessor extends BaseInputPreProcessor {
|
|||
int shapeLength = shape.length;
|
||||
val miniBatchShape = new long[shapeLength + 1];
|
||||
miniBatchShape[0] = miniBatchSize;
|
||||
for (int i = 1; i < miniBatchShape.length; i++) {
|
||||
miniBatchShape[i] = shape[i - 1];
|
||||
}
|
||||
System.arraycopy(shape, 0, miniBatchShape, 1, miniBatchShape.length - 1);
|
||||
return miniBatchShape;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,9 +67,7 @@ public class BookRecognition implements Recognition {
|
|||
}
|
||||
|
||||
if (mergeList != null) {
|
||||
for (Term term : list) {
|
||||
list.add(term);
|
||||
}
|
||||
list.addAll(list);
|
||||
}
|
||||
|
||||
result.setTerms(list);
|
||||
|
|
|
@ -48,9 +48,7 @@ public class StopRecognition implements Recognition {
|
|||
* @return
|
||||
*/
|
||||
public StopRecognition insertStopWords(String... stopWords) {
|
||||
for (String words : stopWords) {
|
||||
stop.add(words);
|
||||
}
|
||||
stop.addAll(Arrays.asList(stopWords));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -60,9 +58,7 @@ public class StopRecognition implements Recognition {
|
|||
* @param stopWords
|
||||
*/
|
||||
public void insertStopNatures(String... stopNatures) {
|
||||
for (String natureStr : stopNatures) {
|
||||
natureStop.add(natureStr);
|
||||
}
|
||||
natureStop.addAll(Arrays.asList(stopNatures));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -345,9 +345,8 @@ public class VocabularyHolder implements Serializable {
|
|||
if (word.getRetentionStep() < retentionDelay - 1) {
|
||||
word.incrementRetentionStep();
|
||||
} else {
|
||||
for (int x = 1; x < retentionDelay; x++) {
|
||||
word.getFrequencyShift()[x - 1] = word.getFrequencyShift()[x];
|
||||
}
|
||||
if (retentionDelay - 1 >= 0)
|
||||
System.arraycopy(word.getFrequencyShift(), 1, word.getFrequencyShift(), 0, retentionDelay - 1);
|
||||
}
|
||||
}
|
||||
logger.info("Scavenger was activated. Vocab size before: [" + initialSize + "], after: [" + vocabulary.size()
|
||||
|
|
|
@ -77,9 +77,7 @@ public class StackVertex extends BaseGraphVertex {
|
|||
|
||||
// create the new shape
|
||||
outShape[0] = nStack * inShape[0];
|
||||
for (int i = 1; i < inShape.length; i++) {
|
||||
outShape[i] = inShape[i];
|
||||
}
|
||||
System.arraycopy(inShape, 1, outShape, 1, inShape.length - 1);
|
||||
|
||||
boolean variableLengthTS = false;
|
||||
if (inShape.length == 3) {
|
||||
|
|
|
@ -838,8 +838,7 @@ public class VariationalAutoencoder implements Layer {
|
|||
return;
|
||||
}
|
||||
|
||||
for (TrainingListener listener : listeners)
|
||||
trainingListeners.add(listener);
|
||||
trainingListeners.addAll(Arrays.asList(listeners));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -915,7 +915,7 @@ public class SharedTrainingMaster extends BaseTrainingMaster<SharedTrainingResul
|
|||
protected int numWorkersPerNode = -1;
|
||||
protected int workerPrefetchNumBatches = 2;
|
||||
protected Repartitioner repartitioner = new DefaultRepartitioner();
|
||||
protected Boolean workerTogglePeriodicGC = new Boolean(true);
|
||||
protected Boolean workerTogglePeriodicGC = Boolean.TRUE;
|
||||
protected Integer workerPeriodicGCFrequency = new Integer(5000);
|
||||
protected boolean encodingDebugMode = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue