java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_ml.python.nlptransformers.TransformersHpSearchSpace

public class TransformersHpSearchSpace extends Object
This class represents the search space for hyper parameters. Each method represents the type of sampling and it need a parameter which appears as a training argument.
 
 NLPTransformersHpSearchSpace psace = new NLPTransformersHpSearchSpace()
      .
 System.out.println(s);
 
 
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • JSON_MAPPER

      private static final com.fasterxml.jackson.databind.ObjectMapper JSON_MAPPER
    • config

      private final Map<String,Object> config
  • Constructor Details

    • TransformersHpSearchSpace

      public TransformersHpSearchSpace()
  • Method Details

    • uniform

      public TransformersHpSearchSpace uniform(String parameter, float lower, float upper)
      Sample a float value uniformly between lower and upper.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - the lower value of the distribution
      upper - the upper value of the distribution
      Returns:
      the search space (this) itself for next call
    • quniform

      public TransformersHpSearchSpace quniform(String parameter, float lower, float upper, float q)
      Sample a quantized float value uniformly between lower and upper. The value will be quantized, i.e. rounded to an integer increment of q. Quantization makes the upper bound inclusive.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - the lower value of the distribution
      upper - the upper value of the distribution
      q - quantization number. The result will be rounded to an integer increment of this value.
      Returns:
      the search space (this) itself for next call
    • loguniform

      public TransformersHpSearchSpace loguniform(String parameter, float lower, float upper)
      Sugar for sampling in different orders of magnitude. Base is 10.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 1e-4)
      upper - upper boundary of the output interval (e.g. 1e-2)
      Returns:
      the search space (this) itself for next call
    • loguniform

      public TransformersHpSearchSpace loguniform(String parameter, float lower, float upper, float base)
      Sugar for sampling in different orders of magnitude.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 1e-4)
      upper - upper boundary of the output interval (e.g. 1e-2)
      base - Base of the log
      Returns:
      the search space (this) itself for next call
    • qloguniform

      public TransformersHpSearchSpace qloguniform(String parameter, float lower, float upper, float q)
      Sugar for sampling in different orders of magnitude. Quantization makes the upper bound inclusive. The base will default to 10.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 1e-4)
      upper - upper boundary of the output interval (e.g. 1e-2)
      q - quantization number. The result will be rounded to an integer increment of this value.
      Returns:
      the search space (this) itself for next call
    • qloguniform

      public TransformersHpSearchSpace qloguniform(String parameter, float lower, float upper, float q, float base)
      Sugar for sampling in different orders of magnitude.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 1e-4)
      upper - upper boundary of the output interval (e.g. 1e-2)
      q - quantization number. The result will be rounded to an integer increment of this value.
      base - base of the log
      Returns:
      the search space (this) itself for next call
    • randn

      public TransformersHpSearchSpace randn(String parameter)
      Sample a float value normally with mean 0 and sd 1. Quantization makes the upper bound inclusive. The base will default to 10.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      Returns:
      the search space (this) itself for next call
    • randn

      public TransformersHpSearchSpace randn(String parameter, float mean, float sd)
      Sample a float value normally with mean and sd.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      mean - mean of the normal distribution
      sd - standard deviation of the normal distribution
      Returns:
      the search space (this) itself for next call
    • qrandn

      public TransformersHpSearchSpace qrandn(String parameter, float mean, float sd, float q)
      Sample a float value normally with mean and sd.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      mean - mean of the normal distribution
      sd - standard deviation of the normal distribution
      q - quantization number. The result will be rounded to an integer increment of this value.
      Returns:
      the search space (this) itself for next call
    • randint

      public TransformersHpSearchSpace randint(String parameter, int lower, int upper)
      Sample an integer value uniformly between lower and upper. lower is inclusive, upper is exclusive.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 5)
      upper - upper boundary of the output interval (e.g. 10)
      Returns:
      the search space (this) itself for next call
    • qrandint

      public TransformersHpSearchSpace qrandint(String parameter, int lower, int upper)
      Sample an integer value uniformly between lower and upper. lower is inclusive, upper is exclusive. Q set to 1.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 5)
      upper - upper boundary of the output interval (e.g. 10)
      Returns:
      the search space (this) itself for next call
    • qrandint

      public TransformersHpSearchSpace qrandint(String parameter, int lower, int upper, int q)
      Sample an integer value uniformly between lower and upper. lower is inclusive, upper is exclusive.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 5)
      upper - upper boundary of the output interval (e.g. 10)
      q - quantization number. The result will be rounded to an integer increment of this value.
      Returns:
      the search space (this) itself for next call
    • lograndint

      public TransformersHpSearchSpace lograndint(String parameter, int lower, int upper)
      Sample an integer value log-uniformly between lower and upper, with base 10.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 5)
      upper - upper boundary of the output interval (e.g. 10)
      Returns:
      the search space (this) itself for next call
    • lograndint

      public TransformersHpSearchSpace lograndint(String parameter, int lower, int upper, float base)
      Sample an integer value log-uniformly between lower and upper, with base being the base of logarithm.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 5)
      upper - upper boundary of the output interval (e.g. 10)
      base - base of the log
      Returns:
      the search space (this) itself for next call
    • qlograndint

      public TransformersHpSearchSpace qlograndint(String parameter, int lower, int upper, int q)
      Sample an integer value log-uniformly between lower and upper, with base 10. lower is inclusive, upper is also inclusive (!). The value will be quantized, i.e. rounded to an integer increment of q. Quantization makes the upper bound inclusive.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 5)
      upper - upper boundary of the output interval (e.g. 10)
      q - quantization number. The result will be rounded to an integer increment of this value.
      Returns:
      the search space (this) itself for next call
    • qlograndint

      public TransformersHpSearchSpace qlograndint(String parameter, int lower, int upper, int q, float base)
      Sample an integer value log-uniformly between lower and upper, with base being the base of logarithm. lower is inclusive, upper is also inclusive (!). The value will be quantized, i.e. rounded to an integer increment of q. Quantization makes the upper bound inclusive.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      lower - lower boundary of the output interval (e.g. 5)
      upper - upper boundary of the output interval (e.g. 10)
      q - quantization number. The result will be rounded to an integer increment of this value.
      base - base of the log
      Returns:
      the search space (this) itself for next call
    • choice

      public TransformersHpSearchSpace choice(String parameter, List<Object> categories)
      Sample a categorical value.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      categories - sample a categorical value.
      Returns:
      the search space (this) itself for next call
    • gridSearch

      public TransformersHpSearchSpace gridSearch(String parameter, List<Object> values)
      Grid search over a value. The final number of trials is: the number of values per gridsearch multiplied with number of trials.
      Parameters:
      parameter - parameter name (which should appear in the training arguments like learning_rate.
      values - a list whose parameters will be gridded
      Returns:
      the search space (this) itself for next call
    • toJsonString

      public String toJsonString()
    • getDefaultHpSpace

      public static TransformersHpSearchSpace getDefaultHpSpace()
      Initializes a default search space for hyper parameter search.
      Returns:
      a default search space for hyper parameter search
    • getDefaultHpSpaceMutations

      public static TransformersHpSearchSpace getDefaultHpSpaceMutations()