Package org.deeplearning4j.iterator
Class BertIterator
- java.lang.Object
-
- org.deeplearning4j.iterator.BertIterator
-
- All Implemented Interfaces:
Serializable,Iterator<org.nd4j.linalg.dataset.api.MultiDataSet>,org.nd4j.linalg.dataset.api.iterator.MultiDataSetIterator
public class BertIterator extends Object implements org.nd4j.linalg.dataset.api.iterator.MultiDataSetIterator
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBertIterator.Builderstatic classBertIterator.FeatureArraysstatic classBertIterator.LengthHandlingstatic classBertIterator.Taskstatic classBertIterator.UnsupervisedLabelFormat
-
Field Summary
Fields Modifier and Type Field Description protected StringappendTokenprotected BertIterator.FeatureArraysfeatureArraysprotected BertIterator.LengthHandlinglengthHandlingprotected BertSequenceMaskermaskerprotected StringmaskTokenprotected intmaxTokensprotected intminibatchSizeprotected booleanpadMinibatchesprotected StringprependTokenprotected org.nd4j.linalg.dataset.api.MultiDataSetPreProcessorpreProcessorprotected LabeledPairSentenceProvidersentencePairProviderprotected LabeledSentenceProvidersentenceProviderprotected BertIterator.Tasktaskprotected TokenizerFactorytokenizerFactoryprotected BertIterator.UnsupervisedLabelFormatunsupervisedLabelFormatprotected List<String>vocabKeysAsListprotected Map<String,Integer>vocabMap
-
Constructor Summary
Constructors Modifier Constructor Description protectedBertIterator(BertIterator.Builder b)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanasyncSupported()static BertIterator.Builderbuilder()org.nd4j.common.primitives.Pair<org.nd4j.linalg.api.ndarray.INDArray[],org.nd4j.linalg.api.ndarray.INDArray[]>featurizeSentencePairs(List<org.nd4j.common.primitives.Pair<String,String>> listOnlySentencePairs)For use during inference.org.nd4j.common.primitives.Pair<org.nd4j.linalg.api.ndarray.INDArray[],org.nd4j.linalg.api.ndarray.INDArray[]>featurizeSentences(List<String> listOnlySentences)For use during inference.booleanhasNext()org.nd4j.linalg.dataset.api.MultiDataSetnext()org.nd4j.linalg.dataset.api.MultiDataSetnext(int num)voidremove()voidreset()booleanresetSupported()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
task
protected BertIterator.Task task
-
tokenizerFactory
protected TokenizerFactory tokenizerFactory
-
maxTokens
protected int maxTokens
-
minibatchSize
protected int minibatchSize
-
padMinibatches
protected boolean padMinibatches
-
preProcessor
protected org.nd4j.linalg.dataset.api.MultiDataSetPreProcessor preProcessor
-
sentenceProvider
protected LabeledSentenceProvider sentenceProvider
-
sentencePairProvider
protected LabeledPairSentenceProvider sentencePairProvider
-
lengthHandling
protected BertIterator.LengthHandling lengthHandling
-
featureArrays
protected BertIterator.FeatureArrays featureArrays
-
masker
protected BertSequenceMasker masker
-
unsupervisedLabelFormat
protected BertIterator.UnsupervisedLabelFormat unsupervisedLabelFormat
-
maskToken
protected String maskToken
-
prependToken
protected String prependToken
-
appendToken
protected String appendToken
-
-
Constructor Detail
-
BertIterator
protected BertIterator(BertIterator.Builder b)
-
-
Method Detail
-
hasNext
public boolean hasNext()
-
next
public org.nd4j.linalg.dataset.api.MultiDataSet next()
-
remove
public void remove()
-
next
public org.nd4j.linalg.dataset.api.MultiDataSet next(int num)
- Specified by:
nextin interfaceorg.nd4j.linalg.dataset.api.iterator.MultiDataSetIterator
-
featurizeSentences
public org.nd4j.common.primitives.Pair<org.nd4j.linalg.api.ndarray.INDArray[],org.nd4j.linalg.api.ndarray.INDArray[]> featurizeSentences(List<String> listOnlySentences)
For use during inference. Will convert a given list of sentences to features and feature masks as appropriate.- Parameters:
listOnlySentences-- Returns:
- Pair of INDArrays[], first element is feature arrays and the second is the masks array
-
featurizeSentencePairs
public org.nd4j.common.primitives.Pair<org.nd4j.linalg.api.ndarray.INDArray[],org.nd4j.linalg.api.ndarray.INDArray[]> featurizeSentencePairs(List<org.nd4j.common.primitives.Pair<String,String>> listOnlySentencePairs)
For use during inference. Will convert a given pair of a list of sentences to features and feature masks as appropriate.- Parameters:
listOnlySentencePairs-- Returns:
- Pair of INDArrays[], first element is feature arrays and the second is the masks array
-
resetSupported
public boolean resetSupported()
- Specified by:
resetSupportedin interfaceorg.nd4j.linalg.dataset.api.iterator.MultiDataSetIterator
-
asyncSupported
public boolean asyncSupported()
- Specified by:
asyncSupportedin interfaceorg.nd4j.linalg.dataset.api.iterator.MultiDataSetIterator
-
reset
public void reset()
- Specified by:
resetin interfaceorg.nd4j.linalg.dataset.api.iterator.MultiDataSetIterator
-
builder
public static BertIterator.Builder builder()
-
-