Skip to content

Instantly share code, notes, and snippets.

@tastyminerals
Created January 30, 2018 13:32
Show Gist options
  • Save tastyminerals/149a47c86747cae7bac9692bcd5e262c to your computer and use it in GitHub Desktop.
Save tastyminerals/149a47c86747cae7bac9692bcd5e262c to your computer and use it in GitHub Desktop.
MultiDataSetIterator
// init DL4J seq readers
val seqWordsReader = new CSVSequenceRecordReader()
seqWordsReader.initialize(new FileSplit(new File(wordsFileSavePath)))
val seqFeatsReader = new CSVSequenceRecordReader()
seqFeatsReader.initialize(new FileSplit(new File(featsFileSavePath)))
val seqLabelsReader = new CSVSequenceRecordReader()
seqLabelsReader.initialize(new FileSplit(new File(labelsFileSavePath)))
// wrap the readers into multi iterator
val batchSize = 1
val numOfClasses = 2
val multiIter = new RecordReaderMultiDataSetIterator.Builder(batchSize)
.addSequenceReader("wordsReader", seqWordsReader)
.addSequenceReader("featsReader", seqFeatsReader)
.addSequenceReader("labelsReader", seqLabelsReader)
.addInput("wordsReader")
.addInput("featsReader")
.addOutputOneHot("labelsReader", 0, numOfClasses)
.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment