use of org.datavec.api.split.FileSplit in project deeplearning4j by deeplearning4j.
the class RecordReaderDataSetiteratorTest method testSequenceRecordReaderTwoReadersWithEmptyFeatureSequenceThrows.
@Test(expected = ZeroLengthSequenceException.class)
public void testSequenceRecordReaderTwoReadersWithEmptyFeatureSequenceThrows() throws Exception {
SequenceRecordReader featureReader = new CSVSequenceRecordReader(1, ",");
SequenceRecordReader labelReader = new CSVSequenceRecordReader(1, ",");
featureReader.initialize(new FileSplit(new ClassPathResource("empty.txt").getTempFileFromArchive()));
labelReader.initialize(new FileSplit(new ClassPathResource("csvsequencelabels_0.txt").getTempFileFromArchive()));
new SequenceRecordReaderDataSetIterator(featureReader, labelReader, 1, -1, true).next();
}
use of org.datavec.api.split.FileSplit in project deeplearning4j by deeplearning4j.
the class RecordReaderDataSetiteratorTest method testRecordReaderMaxBatchLimit.
@Test
public void testRecordReaderMaxBatchLimit() throws Exception {
RecordReader recordReader = new CSVRecordReader();
FileSplit csv = new FileSplit(new ClassPathResource("csv-example.csv").getTempFileFromArchive());
recordReader.initialize(csv);
DataSetIterator iter = new RecordReaderDataSetIterator(recordReader, 10, -1, -1, 2);
iter.next();
iter.next();
assertEquals(false, iter.hasNext());
}
use of org.datavec.api.split.FileSplit in project deeplearning4j by deeplearning4j.
the class RecordReaderDataSetiteratorTest method testSequenceRecordReaderTwoReadersWithEmptyLabelSequenceThrows.
@Test(expected = ZeroLengthSequenceException.class)
public void testSequenceRecordReaderTwoReadersWithEmptyLabelSequenceThrows() throws Exception {
SequenceRecordReader featureReader = new CSVSequenceRecordReader(1, ",");
SequenceRecordReader labelReader = new CSVSequenceRecordReader(1, ",");
featureReader.initialize(new FileSplit(new ClassPathResource("csvsequence_0.txt").getTempFileFromArchive()));
labelReader.initialize(new FileSplit(new ClassPathResource("empty.txt").getTempFileFromArchive()));
new SequenceRecordReaderDataSetIterator(featureReader, labelReader, 1, -1, true).next();
}
use of org.datavec.api.split.FileSplit in project deeplearning4j by deeplearning4j.
the class RecordReaderDataSetiteratorTest method testRecordReaderMultiRegression.
@Test
public void testRecordReaderMultiRegression() throws Exception {
RecordReader csv = new CSVRecordReader();
csv.initialize(new FileSplit(new ClassPathResource("iris.txt").getTempFileFromArchive()));
int batchSize = 3;
int labelIdxFrom = 3;
int labelIdxTo = 4;
DataSetIterator iter = new RecordReaderDataSetIterator(csv, batchSize, labelIdxFrom, labelIdxTo, true);
DataSet ds = iter.next();
INDArray f = ds.getFeatureMatrix();
INDArray l = ds.getLabels();
assertArrayEquals(new int[] { 3, 3 }, f.shape());
assertArrayEquals(new int[] { 3, 2 }, l.shape());
//Check values:
double[][] fExpD = new double[][] { { 5.1, 3.5, 1.4 }, { 4.9, 3.0, 1.4 }, { 4.7, 3.2, 1.3 } };
double[][] lExpD = new double[][] { { 0.2, 0 }, { 0.2, 0 }, { 0.2, 0 } };
INDArray fExp = Nd4j.create(fExpD);
INDArray lExp = Nd4j.create(lExpD);
assertEquals(fExp, f);
assertEquals(lExp, l);
}
use of org.datavec.api.split.FileSplit in project deeplearning4j by deeplearning4j.
the class RecordReaderDataSetiteratorTest method testRecordReader.
@Test
public void testRecordReader() throws Exception {
RecordReader recordReader = new CSVRecordReader();
FileSplit csv = new FileSplit(new ClassPathResource("csv-example.csv").getTempFileFromArchive());
recordReader.initialize(csv);
DataSetIterator iter = new RecordReaderDataSetIterator(recordReader, 34);
DataSet next = iter.next();
assertEquals(34, next.numExamples());
}
Aggregations