Fix deeplearning4j-util dependency + update remnants still using it (#428)
Signed-off-by: Alex Black <blacka101@gmail.com>master
parent
092e6b9891
commit
b70e02a915
|
@ -8,12 +8,14 @@ import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.nd4j.common.resources.Resources;
|
||||||
import org.nd4j.linalg.activations.Activation;
|
import org.nd4j.linalg.activations.Activation;
|
||||||
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
|
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
|
||||||
import org.nd4j.linalg.factory.Nd4j;
|
import org.nd4j.linalg.factory.Nd4j;
|
||||||
import org.nd4j.linalg.learning.config.RmsProp;
|
import org.nd4j.linalg.learning.config.RmsProp;
|
||||||
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
|
|
|
@ -21,9 +21,9 @@ import lombok.val;
|
||||||
import org.apache.commons.lang3.RandomUtils;
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.optimize.solvers.accumulation.SmartFancyBlockingQueue;
|
import org.deeplearning4j.optimize.solvers.accumulation.SmartFancyBlockingQueue;
|
||||||
import org.deeplearning4j.core.util.ThreadUtils;
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.nd4j.linalg.factory.Nd4j;
|
import org.nd4j.linalg.factory.Nd4j;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -31,11 +31,6 @@
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.deeplearning4j</groupId>
|
|
||||||
<artifactId>deeplearning4j-util</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.nd4j</groupId>
|
<groupId>org.nd4j</groupId>
|
||||||
<artifactId>nd4j-api</artifactId>
|
<artifactId>nd4j-api</artifactId>
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2015-2018 Skymind, Inc.
|
|
||||||
*
|
|
||||||
* This program and the accompanying materials are made available under the
|
|
||||||
* terms of the Apache License, Version 2.0 which is available at
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
package org.deeplearning4j.datasets.iterator.impl;
|
|
||||||
|
|
||||||
import org.deeplearning4j.util.MovingWindowMatrix;
|
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
|
||||||
import org.nd4j.linalg.dataset.DataSet;
|
|
||||||
import org.nd4j.linalg.dataset.api.iterator.fetcher.BaseDataFetcher;
|
|
||||||
import org.nd4j.common.util.ArrayUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Moving window data fetcher. Handles rotation of matrices in all directions
|
|
||||||
* to generate more examples.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Adam Gibson
|
|
||||||
*/
|
|
||||||
public class MovingWindowDataSetFetcher extends BaseDataFetcher {
|
|
||||||
|
|
||||||
private DataSet data;
|
|
||||||
private int windowRows = 28, windowColumns = 28;
|
|
||||||
private int cursor = 0;
|
|
||||||
|
|
||||||
public MovingWindowDataSetFetcher(DataSet data, int windowRows, int windowColumns) {
|
|
||||||
this.data = data;
|
|
||||||
this.windowRows = windowRows;
|
|
||||||
this.windowColumns = windowColumns;
|
|
||||||
List<DataSet> list = data.asList();
|
|
||||||
List<DataSet> flipped = new ArrayList<>();
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
INDArray label = list.get(i).getLabels();
|
|
||||||
List<INDArray> windows =
|
|
||||||
new MovingWindowMatrix(list.get(i).getFeatures(), windowRows, windowColumns, true)
|
|
||||||
.windows(true);
|
|
||||||
for (int j = 0; j < windows.size(); j++) {
|
|
||||||
flipped.add(new DataSet(windows.get(j), label));
|
|
||||||
}
|
|
||||||
flipped.add(list.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.data = DataSet.merge(flipped);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the next dataset. You need to call this
|
|
||||||
* to get a new dataset, otherwise {@link #next()}
|
|
||||||
* just returns the last data applyTransformToDestination fetch
|
|
||||||
*
|
|
||||||
* @param numExamples the number of examples to fetch
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void fetch(int numExamples) {
|
|
||||||
initializeCurrFromList(data.get(ArrayUtil.range(cursor, cursor + numExamples)).asList());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,7 +29,7 @@ import org.deeplearning4j.text.sentenceiterator.PrefetchingSentenceIterator;
|
||||||
import org.deeplearning4j.text.sentenceiterator.SentenceIterator;
|
import org.deeplearning4j.text.sentenceiterator.SentenceIterator;
|
||||||
import org.deeplearning4j.text.sentenceiterator.SynchronizedSentenceIterator;
|
import org.deeplearning4j.text.sentenceiterator.SynchronizedSentenceIterator;
|
||||||
import org.deeplearning4j.common.util.DL4JFileUtils;
|
import org.deeplearning4j.common.util.DL4JFileUtils;
|
||||||
import org.deeplearning4j.core.util.ThreadUtils;
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.nd4j.linalg.factory.Nd4j;
|
import org.nd4j.linalg.factory.Nd4j;
|
||||||
import org.nd4j.common.primitives.Pair;
|
import org.nd4j.common.primitives.Pair;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
|
@ -47,7 +47,7 @@ import org.deeplearning4j.text.sentenceiterator.SentenceIterator;
|
||||||
import org.deeplearning4j.text.sentenceiterator.interoperability.SentenceIteratorConverter;
|
import org.deeplearning4j.text.sentenceiterator.interoperability.SentenceIteratorConverter;
|
||||||
import org.deeplearning4j.text.sentenceiterator.labelaware.LabelAwareSentenceIterator;
|
import org.deeplearning4j.text.sentenceiterator.labelaware.LabelAwareSentenceIterator;
|
||||||
import org.deeplearning4j.text.tokenization.tokenizerfactory.TokenizerFactory;
|
import org.deeplearning4j.text.tokenization.tokenizerfactory.TokenizerFactory;
|
||||||
import org.deeplearning4j.core.util.ThreadUtils;
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.exception.ND4JIllegalStateException;
|
import org.nd4j.linalg.exception.ND4JIllegalStateException;
|
||||||
import org.nd4j.linalg.factory.Nd4j;
|
import org.nd4j.linalg.factory.Nd4j;
|
||||||
|
|
|
@ -47,7 +47,7 @@ import org.deeplearning4j.models.word2vec.VocabWord;
|
||||||
import org.deeplearning4j.models.word2vec.wordstore.VocabCache;
|
import org.deeplearning4j.models.word2vec.wordstore.VocabCache;
|
||||||
import org.deeplearning4j.models.word2vec.wordstore.VocabConstructor;
|
import org.deeplearning4j.models.word2vec.wordstore.VocabConstructor;
|
||||||
import org.deeplearning4j.models.word2vec.wordstore.inmemory.AbstractCache;
|
import org.deeplearning4j.models.word2vec.wordstore.inmemory.AbstractCache;
|
||||||
import org.deeplearning4j.core.util.ThreadUtils;
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.nd4j.linalg.api.memory.conf.WorkspaceConfiguration;
|
import org.nd4j.linalg.api.memory.conf.WorkspaceConfiguration;
|
||||||
import org.nd4j.linalg.api.memory.enums.LearningPolicy;
|
import org.nd4j.linalg.api.memory.enums.LearningPolicy;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.deeplearning4j.models.sequencevectors.sequence.SequenceElement;
|
||||||
import org.deeplearning4j.models.word2vec.Huffman;
|
import org.deeplearning4j.models.word2vec.Huffman;
|
||||||
import org.deeplearning4j.models.word2vec.wordstore.inmemory.AbstractCache;
|
import org.deeplearning4j.models.word2vec.wordstore.inmemory.AbstractCache;
|
||||||
import org.deeplearning4j.text.invertedindex.InvertedIndex;
|
import org.deeplearning4j.text.invertedindex.InvertedIndex;
|
||||||
import org.deeplearning4j.core.util.ThreadUtils;
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.threadly.concurrent.PriorityScheduler;
|
import org.threadly.concurrent.PriorityScheduler;
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.deeplearning4j.text.sentenceiterator;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import org.deeplearning4j.core.util.ThreadUtils;
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import lombok.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import org.deeplearning4j.nn.api.Model;
|
||||||
import org.deeplearning4j.optimize.api.BaseTrainingListener;
|
import org.deeplearning4j.optimize.api.BaseTrainingListener;
|
||||||
import org.deeplearning4j.util.ThreadUtils;
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.deeplearning4j.optimize.solvers.accumulation.encoding.ResidualPostPro
|
||||||
import org.deeplearning4j.optimize.solvers.accumulation.encoding.ThresholdAlgorithm;
|
import org.deeplearning4j.optimize.solvers.accumulation.encoding.ThresholdAlgorithm;
|
||||||
import org.deeplearning4j.optimize.solvers.accumulation.encoding.residual.ResidualClippingPostProcessor;
|
import org.deeplearning4j.optimize.solvers.accumulation.encoding.residual.ResidualClippingPostProcessor;
|
||||||
import org.deeplearning4j.optimize.solvers.accumulation.encoding.threshold.AdaptiveThresholdAlgorithm;
|
import org.deeplearning4j.optimize.solvers.accumulation.encoding.threshold.AdaptiveThresholdAlgorithm;
|
||||||
import org.deeplearning4j.util.ThreadUtils;
|
|
||||||
import org.nd4j.common.base.Preconditions;
|
import org.nd4j.common.base.Preconditions;
|
||||||
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
import org.nd4j.linalg.api.memory.MemoryWorkspace;
|
import org.nd4j.linalg.api.memory.MemoryWorkspace;
|
||||||
import org.nd4j.linalg.api.memory.conf.WorkspaceConfiguration;
|
import org.nd4j.linalg.api.memory.conf.WorkspaceConfiguration;
|
||||||
import org.nd4j.linalg.api.memory.enums.*;
|
import org.nd4j.linalg.api.memory.enums.*;
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.deeplearning4j.optimize.solvers.accumulation;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nd4j.common.util.ThreadUtils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -28,8 +29,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
import org.deeplearning4j.util.ThreadUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This BlockingQueue implementation is suited only for symmetric gradients updates, and should NOT be used anywhere else.
|
* This BlockingQueue implementation is suited only for symmetric gradients updates, and should NOT be used anywhere else.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2020 Konduit K.K.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Apache License, Version 2.0 which is available at
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package org.nd4j.common.util;
|
||||||
|
|
||||||
|
public class ThreadUtils {
|
||||||
|
|
||||||
|
private ThreadUtils(){ }
|
||||||
|
|
||||||
|
public static void uncheckedSleep(long sleepTimeMs){
|
||||||
|
try{
|
||||||
|
Thread.sleep(sleepTimeMs);
|
||||||
|
} catch (InterruptedException e){ }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue