Class FtAbstractBlock

java.lang.Object
ai.djl.nn.AbstractBaseBlock
ai.djl.nn.AbstractSymbolBlock
ai.djl.fasttext.FtAbstractBlock
All Implemented Interfaces:
ai.djl.nn.Block, ai.djl.nn.SymbolBlock, AutoCloseable
Direct Known Subclasses:
FtTextClassification, FtWordEmbeddingBlock

public abstract class FtAbstractBlock extends ai.djl.nn.AbstractSymbolBlock implements AutoCloseable
A parent class containing shared behavior for SymbolBlocks based on fasttext models.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected FtWrapper
     
    protected Path
     

    Fields inherited from class ai.djl.nn.AbstractBaseBlock

    inputNames, inputShapes, outputDataTypes, version
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a FtAbstractBlock.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    float[]
    Embeds a word using fasttext.
    ai.djl.nn.ParameterList
    Returns the fasttext model file for the block.

    Methods inherited from class ai.djl.nn.AbstractSymbolBlock

    getChildren, getOutputShapes

    Methods inherited from class ai.djl.nn.AbstractBaseBlock

    beforeInitialize, cast, clear, describeInput, forward, forward, forwardInternal, forwardInternal, getInputShapes, getOutputDataTypes, getParameters, initialize, initializeChildBlocks, isInitialized, loadMetadata, loadParameters, prepare, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, setInitializer, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods 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, setInitializer

    Methods inherited from interface ai.djl.nn.SymbolBlock

    describeOutput, removeLastBlock
  • Field Details

    • fta

      protected FtWrapper fta
    • modelFile

      protected Path modelFile
  • Constructor Details

  • Method Details

    • getModelFile

      public Path getModelFile()
      Returns the fasttext model file for the block.
      Returns:
      the fasttext model file for the block
    • embedWord

      public float[] embedWord(String word)
      Embeds a word using fasttext.
      Parameters:
      word - the word to embed
      Returns:
      the embedding
      See Also:
      • WordEmbedding
    • getDirectParameters

      public ai.djl.nn.ParameterList getDirectParameters()
      Specified by:
      getDirectParameters in interface ai.djl.nn.Block
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable