use of org.datavec.api.util.ClassPathResource in project deeplearning4j by deeplearning4j.
the class MultipleEpochsIteratorTest method testNextAndReset.
@Test
public void testNextAndReset() throws Exception {
int epochs = 3;
RecordReader rr = new CSVRecordReader();
rr.initialize(new FileSplit(new ClassPathResource("iris.txt").getFile()));
DataSetIterator iter = new RecordReaderDataSetIterator(rr, 150);
MultipleEpochsIterator multiIter = new MultipleEpochsIterator(epochs, iter);
assertTrue(multiIter.hasNext());
while (multiIter.hasNext()) {
DataSet path = multiIter.next();
assertFalse(path == null);
}
assertEquals(epochs, multiIter.epochs);
}
use of org.datavec.api.util.ClassPathResource in project deeplearning4j by deeplearning4j.
the class MultipleEpochsIteratorTest method testLoadFullDataSet.
@Test
public void testLoadFullDataSet() throws Exception {
int epochs = 3;
RecordReader rr = new CSVRecordReader();
rr.initialize(new FileSplit(new ClassPathResource("iris.txt").getFile()));
DataSetIterator iter = new RecordReaderDataSetIterator(rr, 150);
DataSet ds = iter.next(50);
MultipleEpochsIterator multiIter = new MultipleEpochsIterator(epochs, ds);
assertTrue(multiIter.hasNext());
while (multiIter.hasNext()) {
DataSet path = multiIter.next();
assertEquals(path.numExamples(), 50, 0.0);
assertFalse(path == null);
}
assertEquals(epochs, multiIter.epochs);
}
use of org.datavec.api.util.ClassPathResource in project deeplearning4j by deeplearning4j.
the class WordVectorSerializerTest method before.
@Before
public void before() throws Exception {
if (textFile == null) {
textFile = new ClassPathResource("word2vecserialization/google_news_30.txt").getFile();
}
if (binaryFile == null) {
binaryFile = new ClassPathResource("word2vecserialization/google_news_30.bin.gz").getFile(".gz");
}
pathToWriteto = new ClassPathResource("word2vecserialization/testing_word2vec_serialization.txt").getFile().getAbsolutePath();
FileUtils.deleteDirectory(new File("word2vec-index"));
}
use of org.datavec.api.util.ClassPathResource in project deeplearning4j by deeplearning4j.
the class VectorsConfigurationTest method testFromW2V.
@Test
public void testFromW2V() throws Exception {
VectorsConfiguration configuration = new VectorsConfiguration();
configuration.setHugeModelExpected(true);
configuration.setWindow(5);
configuration.setIterations(3);
configuration.setLayersSize(200);
configuration.setLearningRate(1.4d);
configuration.setSampling(0.0005d);
configuration.setMinLearningRate(0.25d);
configuration.setEpochs(1);
File inputFile = new ClassPathResource("/big/raw_sentences.txt").getFile();
SentenceIterator iter = UimaSentenceIterator.createWithPath(inputFile.getAbsolutePath());
Word2Vec vec = new Word2Vec.Builder(configuration).iterate(iter).build();
VectorsConfiguration configuration2 = vec.getConfiguration();
assertEquals(configuration, configuration2);
}
use of org.datavec.api.util.ClassPathResource in project deeplearning4j by deeplearning4j.
the class Word2VecTests method before.
@Before
public void before() throws Exception {
File googleModelTextFile = new ClassPathResource("word2vecserialization/google_news_30.txt").getFile();
googleModel = WordVectorSerializer.loadGoogleModel(googleModelTextFile, false);
inputFile = new ClassPathResource("/big/raw_sentences.txt").getFile();
File ptwt = new File(System.getProperty("java.io.tmpdir"), "testing_word2vec_serialization.txt");
pathToWriteto = ptwt.getAbsolutePath();
FileUtils.deleteDirectory(new File("word2vec-index"));
}
Aggregations