Class FtTextClassification
java.lang.Object
ai.djl.nn.AbstractBaseBlock
ai.djl.nn.AbstractSymbolBlock
ai.djl.fasttext.FtAbstractBlock
ai.djl.fasttext.zoo.nlp.textclassification.FtTextClassification
- All Implemented Interfaces:
ai.djl.nn.Block,ai.djl.nn.SymbolBlock,AutoCloseable
A
FtAbstractBlock for Application.NLP.TEXT_CLASSIFICATION.-
Field Summary
FieldsFields inherited from class ai.djl.fasttext.FtAbstractBlock
fta, modelFileFields inherited from class ai.djl.nn.AbstractBaseBlock
inputNames, inputShapes, outputDataTypes, version -
Constructor Summary
ConstructorsConstructorDescriptionFtTextClassification(FtWrapper fta, String labelPrefix) Constructs aFtTextClassification. -
Method Summary
Modifier and TypeMethodDescriptionai.djl.modality.ClassificationsReturns the classifications of the input text.ai.djl.modality.ClassificationsReturns top K classifications of the input text.static FtTextClassificationfit(FtTrainingConfig config, ai.djl.training.dataset.RawDataset<Path> dataset) Trains the fastText model.protected ai.djl.ndarray.NDListforwardInternal(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList inputs, boolean training, ai.djl.util.PairList<String, Object> params) Returns the fasttext label prefix.ai.djl.training.TrainingResultReturns the results of training, or null if not trained.Converts the block into the equivalentFtWordEmbeddingBlock.Methods inherited from class ai.djl.fasttext.FtAbstractBlock
close, embedWord, getDirectParameters, getModelFileMethods inherited from class ai.djl.nn.AbstractSymbolBlock
getChildren, getOutputShapesMethods inherited from class ai.djl.nn.AbstractBaseBlock
beforeInitialize, cast, clear, describeInput, forward, forward, forwardInternal, getInputShapes, getOutputDataTypes, getParameters, initialize, initializeChildBlocks, isInitialized, loadMetadata, loadParameters, prepare, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, setInitializer, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.djl.nn.Block
cast, clear, describeInput, forward, forward, forward, freezeParameters, freezeParameters, getInputShapes, getOutputDataTypes, getOutputShapes, getParameters, initialize, isInitialized, loadParameters, saveParameters, setInitializer, setInitializer, setInitializerMethods inherited from interface ai.djl.nn.SymbolBlock
describeOutput, removeLastBlock
-
Field Details
-
DEFAULT_LABEL_PREFIX
- See Also:
-
-
Constructor Details
-
FtTextClassification
Constructs aFtTextClassification.- Parameters:
fta- theFtWrappercontaining the "fasttext model"labelPrefix- the prefix to use for labels
-
-
Method Details
-
fit
public static FtTextClassification fit(FtTrainingConfig config, ai.djl.training.dataset.RawDataset<Path> dataset) throws IOException Trains the fastText model.- Parameters:
config- the training configuration to usedataset- the training dataset- Returns:
- the result of the training
- Throws:
IOException- when IO operation fails in loading a resource
-
getLabelPrefix
Returns the fasttext label prefix.- Returns:
- the fasttext label prefix
-
getTrainingResult
public ai.djl.training.TrainingResult getTrainingResult()Returns the results of training, or null if not trained.- Returns:
- the results of training, or null if not trained
-
forwardInternal
protected ai.djl.ndarray.NDList forwardInternal(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList inputs, boolean training, ai.djl.util.PairList<String, Object> params) - Specified by:
forwardInternalin classai.djl.nn.AbstractBaseBlock
-
toWordEmbedding
Converts the block into the equivalentFtWordEmbeddingBlock.- Returns:
- the equivalent
FtWordEmbeddingBlock
-
classify
Returns the classifications of the input text.- Parameters:
text- the input text to be classified- Returns:
- classifications of the input text
-
classify
Returns top K classifications of the input text.- Parameters:
text- the input text to be classifiedtopK- the value of K- Returns:
- classifications of the input text
-