Class PLNetInputOptimizer


  • public class PLNetInputOptimizer
    extends java.lang.Object
    Optimizes a given loss function (InputOptimizerLoss) with respect to the input of a PLNet using gradient descent. Assumes the PLNet was trained on normalized training data (i.e. scaled to intervals of 0 to 1 using DyadMinMaxScaler) and ensures that the optimized inputs will be within this range.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet, org.nd4j.linalg.api.ndarray.INDArray input, InputOptimizerLoss loss, double initialLearningRate, double finalLearningRate, int numSteps, org.nd4j.linalg.api.ndarray.INDArray inputMask)
      Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent.
      org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet, org.nd4j.linalg.api.ndarray.INDArray input, InputOptimizerLoss loss, double initialLearningRate, double finalLearningRate, int numSteps, org.nd4j.linalg.primitives.Pair<java.lang.Integer,​java.lang.Integer> indexRange)
      Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent.
      org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet, org.nd4j.linalg.api.ndarray.INDArray input, InputOptimizerLoss loss, double learningRate, int numSteps, org.nd4j.linalg.api.ndarray.INDArray inputMask)
      Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent.
      org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet, org.nd4j.linalg.api.ndarray.INDArray input, InputOptimizerLoss loss, double learningRate, int numSteps, org.nd4j.linalg.primitives.Pair<java.lang.Integer,​java.lang.Integer> indexRange)
      Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent.
      void setListener​(InputOptListener listener)
      Set an InputOptListener to record the intermediate steps of the optimization procedure.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PLNetInputOptimizer

        public PLNetInputOptimizer()
    • Method Detail

      • optimizeInput

        public org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet,
                                                                  org.nd4j.linalg.api.ndarray.INDArray input,
                                                                  InputOptimizerLoss loss,
                                                                  double learningRate,
                                                                  int numSteps,
                                                                  org.nd4j.linalg.primitives.Pair<java.lang.Integer,​java.lang.Integer> indexRange)
        Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent. Ensures the outcome will be within the range of 0 and 1. Performs gradient descent for a given number of steps starting at a given input, using a static learning rate. The inputs that should be optimized can be specified using an index range in the form of a Pair} of integers.
        Parameters:
        plNet - PLNet whose inputs to optimize.
        input - Initial inputs to start the gradient descent procedure from.
        loss - The loss to be minimized.
        learningRate - The initial learning rate.
        numSteps - The number of steps to perform gradient descent for.
        indexRange - Pair of indices (inclusive) specifying the parts of the input that should be optimized.
        Returns:
        The input optimized with respect to the given loss.
      • optimizeInput

        public org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet,
                                                                  org.nd4j.linalg.api.ndarray.INDArray input,
                                                                  InputOptimizerLoss loss,
                                                                  double initialLearningRate,
                                                                  double finalLearningRate,
                                                                  int numSteps,
                                                                  org.nd4j.linalg.primitives.Pair<java.lang.Integer,​java.lang.Integer> indexRange)
        Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent. Ensures the outcome will be within the range of 0 and 1. Performs gradient descent for a given number of steps starting at a given input, using a linearly decaying learning rate. The inputs that should be optimized can be specified using an index range in the form of a Pair} of integers.
        Parameters:
        plNet - PLNet whose inputs to optimize.
        input - Initial inputs to start the gradient descent procedure from.
        loss - The loss to be minimized.
        initialLearningRate - The initial learning rate.
        finalLearningRate - The value the learning rate should decay to.
        numSteps - The number of steps to perform gradient descent for.
        indexRange - Pair of indices (inclusive) specifying the parts of the input that should be optimized.
        Returns:
        The input optimized with respect to the given loss.
      • optimizeInput

        public org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet,
                                                                  org.nd4j.linalg.api.ndarray.INDArray input,
                                                                  InputOptimizerLoss loss,
                                                                  double learningRate,
                                                                  int numSteps,
                                                                  org.nd4j.linalg.api.ndarray.INDArray inputMask)
        Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent. Ensures the outcome will be within the range of 0 and 1. Performs gradient descent for a given number of steps starting at a given input, using a static learning rate. The inputs that should be optimized can be specified using a 0,1-vector
        Parameters:
        plNet - PLNet whose inputs to optimize.
        input - Initial inputs to start the gradient descent procedure from.
        loss - The loss to be minimized.
        learningRate - The initial learning rate.
        numSteps - The number of steps to perform gradient descent for.
        inputMask - 0,1 vector specifying the inputs to optimize, i.e. should have a 1 at the index of any input that should be optimized and a 0 elsewhere.
        Returns:
        The input optimized with respect to the given loss.
      • optimizeInput

        public org.nd4j.linalg.api.ndarray.INDArray optimizeInput​(PLNetDyadRanker plNet,
                                                                  org.nd4j.linalg.api.ndarray.INDArray input,
                                                                  InputOptimizerLoss loss,
                                                                  double initialLearningRate,
                                                                  double finalLearningRate,
                                                                  int numSteps,
                                                                  org.nd4j.linalg.api.ndarray.INDArray inputMask)
        Optimizes the given loss function with respect to a given PLNet's inputs using gradient descent. Ensures the outcome will be within the range of 0 and 1. Performs gradient descent for a given number of steps starting at a given input, using a linearly decaying learning rate. The inputs that should be optimized can be specified using a 0,1-vector
        Parameters:
        plNet - PLNet whose inputs to optimize.
        input - Initial inputs to start the gradient descent procedure from.
        loss - The loss to be minimized.
        initialLearningRate - The initial learning rate.
        finalLearningRate - The value the learning rate should decay to.
        numSteps - The number of steps to perform gradient descent for.
        inputMask - 0,1 vector specifying the inputs to optimize, i.e. should have a 1 at the index of any input that should be optimized and a 0 elsewhere.
        Returns:
        The input optimized with respect to the given loss.
      • setListener

        public void setListener​(InputOptListener listener)
        Set an InputOptListener to record the intermediate steps of the optimization procedure.
        Parameters:
        listener -