Skip to content

Instantly share code, notes, and snippets.

@plankes-projects
Last active May 27, 2016 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plankes-projects/9422b48759e9332d9d85a40ba205e113 to your computer and use it in GitHub Desktop.
Save plankes-projects/9422b48759e9332d9d85a40ba205e113 to your computer and use it in GitHub Desktop.
How to train a DeepLearning4j model with custom images. 'new File("directory")' is the directory wich has 1 subdirectory with images for each category you have.
RecordReader recordReader = new ImageRecordReader(Config.IMAGE_WIDTH, Config.IMAGE_HEIGHT, Config.CHANNELS, true);
recordReader.initialize(new FileSplit(new File("directory"), BaseImageLoader.ALLOWED_FORMATS));
DataSetIterator dataIter = new RecordReaderDataSetIterator(recordReader, batchSize, -1, numLabels);
while (dataIter.hasNext()) {
dsNext = dataIter.next();
dsNext.scale();
network.fit(dsNext);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment