|
Java example source code file (LocalUnstructuredDataFormatterTest.java)
The LocalUnstructuredDataFormatterTest.java Java example source codepackage org.deeplearning4j.datasets.rearrange; import org.apache.commons.io.FileUtils; import org.deeplearning4j.datasets.iterator.impl.LFWDataSetIterator; import org.junit.Test; import java.io.File; import java.util.Iterator; import static org.junit.Assert.*; /** * Created by agibsonccc on 9/11/15. */ public class LocalUnstructuredDataFormatterTest { @Test public void testRearrange() throws Exception { //ensure exists new LFWDataSetIterator(new int[] {10,28,28}).next(); File destinationDir = new File(System.getProperty("user.home"),"rearrangedlfw"); if(destinationDir.exists()) FileUtils.deleteDirectory(destinationDir); LocalUnstructuredDataFormatter formatter = new LocalUnstructuredDataFormatter(destinationDir,new File(System.getProperty("user.home"),"lfw"), LocalUnstructuredDataFormatter.LabelingType.DIRECTORY,0.8); formatter.rearrange(); //train and test in the split directory File splitRoot = new File(destinationDir,"split"); assertEquals(2,splitRoot.listFiles().length); Iterator<File> files = FileUtils.iterateFiles(splitRoot,null,true); int count = 0; while(files.hasNext()) { files.next(); count++; } Iterator<File> trainFiles = FileUtils.iterateFiles(new File(splitRoot,"train"),null,true); int trainFilesCount = 0; while(trainFiles.hasNext()) { trainFiles.next(); trainFilesCount++; } //assert the number of files is the same in the split test train as the original dataset assertEquals(formatter.getNumExamplesTotal(),count); assertEquals(formatter.getNumExamplesToTrainOn(),trainFilesCount); Iterator<File> testFiles = FileUtils.iterateFiles(new File(splitRoot,"test"),null,true); int testFilesCount = 0; while(testFiles.hasNext()) { testFiles.next(); testFilesCount++; } assertEquals(formatter.getNumTestExamples(),testFilesCount); } } Other Java examples (source code examples)Here is a short list of links related to this Java LocalUnstructuredDataFormatterTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.