Class FtModel

java.lang.Object
ai.djl.fasttext.FtModel
All Implemented Interfaces:
ai.djl.Model, AutoCloseable

public class FtModel extends Object implements ai.djl.Model
FtModel is the fastText implementation of Model.

FtModel contains all the methods in Model to load and process a model. However, it only supports training by using TrainFastText.

  • Constructor Details

    • FtModel

      public FtModel(String name)
      Constructs a new Model.
      Parameters:
      name - the model name
  • Method Details

    • load

      public void load(Path modelPath, String prefix, Map<String,?> options) throws IOException, ai.djl.MalformedModelException
      Specified by:
      load in interface ai.djl.Model
      Throws:
      IOException
      ai.djl.MalformedModelException
    • load

      public void load(InputStream modelStream, Map<String,?> options)
      Specified by:
      load in interface ai.djl.Model
    • save

      public void save(Path modelDir, String newModelName)
      Specified by:
      save in interface ai.djl.Model
    • getModelPath

      public Path getModelPath()
      Specified by:
      getModelPath in interface ai.djl.Model
    • getBlock

      public FtAbstractBlock getBlock()
      Specified by:
      getBlock in interface ai.djl.Model
    • setBlock

      public void setBlock(ai.djl.nn.Block block)
      Specified by:
      setBlock in interface ai.djl.Model
    • getName

      public String getName()
      Specified by:
      getName in interface ai.djl.Model
    • newTrainer

      public ai.djl.training.Trainer newTrainer(ai.djl.training.TrainingConfig trainingConfig)
      Specified by:
      newTrainer in interface ai.djl.Model
    • newPredictor

      public <I, O> ai.djl.inference.Predictor<I,O> newPredictor(ai.djl.translate.Translator<I,O> translator, ai.djl.Device device)
      Specified by:
      newPredictor in interface ai.djl.Model
    • setDataType

      public void setDataType(ai.djl.ndarray.types.DataType dataType)
      Specified by:
      setDataType in interface ai.djl.Model
    • getDataType

      public ai.djl.ndarray.types.DataType getDataType()
      Specified by:
      getDataType in interface ai.djl.Model
    • describeInput

      public ai.djl.util.PairList<String,ai.djl.ndarray.types.Shape> describeInput()
      Specified by:
      describeInput in interface ai.djl.Model
    • describeOutput

      public ai.djl.util.PairList<String,ai.djl.ndarray.types.Shape> describeOutput()
      Specified by:
      describeOutput in interface ai.djl.Model
    • getArtifactNames

      public String[] getArtifactNames()
      Specified by:
      getArtifactNames in interface ai.djl.Model
    • getArtifact

      public <T> T getArtifact(String name, Function<InputStream,T> function)
      Specified by:
      getArtifact in interface ai.djl.Model
    • getArtifact

      public URL getArtifact(String artifactName)
      Specified by:
      getArtifact in interface ai.djl.Model
    • getArtifactAsStream

      public InputStream getArtifactAsStream(String name)
      Specified by:
      getArtifactAsStream in interface ai.djl.Model
    • getNDManager

      public ai.djl.ndarray.NDManager getNDManager()
      Specified by:
      getNDManager in interface ai.djl.Model
    • setProperty

      public void setProperty(String key, String value)
      Specified by:
      setProperty in interface ai.djl.Model
    • getProperty

      public String getProperty(String key)
      Specified by:
      getProperty in interface ai.djl.Model
    • getProperties

      public Map<String,String> getProperties()
      Specified by:
      getProperties in interface ai.djl.Model
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ai.djl.Model
    • toString

      public String toString()
      Overrides:
      toString in class Object