(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<>();
|
ArrayList<String> sortedVocabulary = new ArrayList<>();
|
||||||
if (outOfVocabularyToken != null)
|
if (outOfVocabularyToken != null)
|
||||||
sortedVocabulary.add(outOfVocabularyToken);
|
sortedVocabulary.add(outOfVocabularyToken);
|
||||||
for (String word: sortedWordCounts.keySet()) {
|
sortedVocabulary.addAll(sortedWordCounts.keySet());
|
||||||
sortedVocabulary.add(word);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < sortedVocabulary.size(); i++)
|
for (int i = 0; i < sortedVocabulary.size(); i++)
|
||||||
wordIndex.put(sortedVocabulary.get(i), i+1);
|
wordIndex.put(sortedVocabulary.get(i), i+1);
|
||||||
|
|
|
@ -96,9 +96,7 @@ public class ReshapePreprocessor extends BaseInputPreProcessor {
|
||||||
int shapeLength = shape.length;
|
int shapeLength = shape.length;
|
||||||
val miniBatchShape = new long[shapeLength + 1];
|
val miniBatchShape = new long[shapeLength + 1];
|
||||||
miniBatchShape[0] = miniBatchSize;
|
miniBatchShape[0] = miniBatchSize;
|
||||||
for (int i = 1; i < miniBatchShape.length; i++) {
|
System.arraycopy(shape, 0, miniBatchShape, 1, miniBatchShape.length - 1);
|
||||||
miniBatchShape[i] = shape[i - 1];
|
|
||||||
}
|
|
||||||
return miniBatchShape;
|
return miniBatchShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,9 +67,7 @@ public class BookRecognition implements Recognition {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mergeList != null) {
|
if (mergeList != null) {
|
||||||
for (Term term : list) {
|
list.addAll(list);
|
||||||
list.add(term);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.setTerms(list);
|
result.setTerms(list);
|
||||||
|
|
|
@ -48,9 +48,7 @@ public class StopRecognition implements Recognition {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public StopRecognition insertStopWords(String... stopWords) {
|
public StopRecognition insertStopWords(String... stopWords) {
|
||||||
for (String words : stopWords) {
|
stop.addAll(Arrays.asList(stopWords));
|
||||||
stop.add(words);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +58,7 @@ public class StopRecognition implements Recognition {
|
||||||
* @param stopWords
|
* @param stopWords
|
||||||
*/
|
*/
|
||||||
public void insertStopNatures(String... stopNatures) {
|
public void insertStopNatures(String... stopNatures) {
|
||||||
for (String natureStr : stopNatures) {
|
natureStop.addAll(Arrays.asList(stopNatures));
|
||||||
natureStop.add(natureStr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -345,9 +345,8 @@ public class VocabularyHolder implements Serializable {
|
||||||
if (word.getRetentionStep() < retentionDelay - 1) {
|
if (word.getRetentionStep() < retentionDelay - 1) {
|
||||||
word.incrementRetentionStep();
|
word.incrementRetentionStep();
|
||||||
} else {
|
} else {
|
||||||
for (int x = 1; x < retentionDelay; x++) {
|
if (retentionDelay - 1 >= 0)
|
||||||
word.getFrequencyShift()[x - 1] = word.getFrequencyShift()[x];
|
System.arraycopy(word.getFrequencyShift(), 1, word.getFrequencyShift(), 0, retentionDelay - 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("Scavenger was activated. Vocab size before: [" + initialSize + "], after: [" + vocabulary.size()
|
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
|
// create the new shape
|
||||||
outShape[0] = nStack * inShape[0];
|
outShape[0] = nStack * inShape[0];
|
||||||
for (int i = 1; i < inShape.length; i++) {
|
System.arraycopy(inShape, 1, outShape, 1, inShape.length - 1);
|
||||||
outShape[i] = inShape[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean variableLengthTS = false;
|
boolean variableLengthTS = false;
|
||||||
if (inShape.length == 3) {
|
if (inShape.length == 3) {
|
||||||
|
|
|
@ -838,8 +838,7 @@ public class VariationalAutoencoder implements Layer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TrainingListener listener : listeners)
|
trainingListeners.addAll(Arrays.asList(listeners));
|
||||||
trainingListeners.add(listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -915,7 +915,7 @@ public class SharedTrainingMaster extends BaseTrainingMaster<SharedTrainingResul
|
||||||
protected int numWorkersPerNode = -1;
|
protected int numWorkersPerNode = -1;
|
||||||
protected int workerPrefetchNumBatches = 2;
|
protected int workerPrefetchNumBatches = 2;
|
||||||
protected Repartitioner repartitioner = new DefaultRepartitioner();
|
protected Repartitioner repartitioner = new DefaultRepartitioner();
|
||||||
protected Boolean workerTogglePeriodicGC = new Boolean(true);
|
protected Boolean workerTogglePeriodicGC = Boolean.TRUE;
|
||||||
protected Integer workerPeriodicGCFrequency = new Integer(5000);
|
protected Integer workerPeriodicGCFrequency = new Integer(5000);
|
||||||
protected boolean encodingDebugMode = false;
|
protected boolean encodingDebugMode = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue