Class Predictor<I,​O>

    • Constructor Detail

      • Predictor

        public Predictor​(Model model,
                         Translator<I,​O> translator,
                         Device device,
                         boolean copy)
        Creates a new instance of BasePredictor with the given Model and Translator.
        Parameters:
        model - the model on which the predictions are based
        translator - the translator to be used
        device - the device for prediction
        copy - whether to copy the parameters to the parameter store. If the device changes, it will copy regardless
    • Method Detail

      • predict

        public O predict​(I input)
                  throws TranslateException
        Predicts an item for inference.
        Parameters:
        input - the input
        Returns:
        the output object defined by the user
        Throws:
        TranslateException - if an error occurs during prediction
      • batchPredict

        public java.util.List<O> batchPredict​(java.util.List<I> inputs)
                                       throws TranslateException
        Predicts a batch for inference.
        Parameters:
        inputs - a list of inputs
        Returns:
        a list of output objects defined by the user
        Throws:
        TranslateException - if an error occurs during prediction
      • setMetrics

        public void setMetrics​(Metrics metrics)
        Attaches a Metrics param to use for benchmark.
        Parameters:
        metrics - the Metrics class
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable