org.nd4j.linalg.schedule.ISchedule Java Examples

The following examples show how to use org.nd4j.linalg.schedule.ISchedule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdaMaxSpace.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public IUpdater getValue(double[] parameterValues) {
    double lr = learningRate == null ? AdaMax.DEFAULT_ADAMAX_LEARNING_RATE : learningRate.getValue(parameterValues);
    ISchedule lrS = learningRateSchedule == null ? null : learningRateSchedule.getValue(parameterValues);
    double b1 = beta1 == null ? AdaMax.DEFAULT_ADAMAX_LEARNING_RATE : beta1.getValue(parameterValues);
    double b2 = beta2 == null ? AdaMax.DEFAULT_ADAMAX_LEARNING_RATE : beta2.getValue(parameterValues);
    double eps = epsilon == null ? AdaMax.DEFAULT_ADAMAX_LEARNING_RATE : epsilon.getValue(parameterValues);
    if(lrS == null){
        return new AdaMax(lr, b1, b2, eps);
    } else {
        AdaMax a = new AdaMax(lrS);
        a.setBeta1(b1);
        a.setBeta2(b2);
        a.setEpsilon(eps);
        return a;
    }
}
 
Example #2
Source File: NadamSpace.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public IUpdater getValue(double[] parameterValues) {
    double lr = learningRate == null ? Nadam.DEFAULT_NADAM_LEARNING_RATE : learningRate.getValue(parameterValues);
    ISchedule lrS = learningRateSchedule == null ? null : learningRateSchedule.getValue(parameterValues);
    double b1 = beta1 == null ? Nadam.DEFAULT_NADAM_LEARNING_RATE : beta1.getValue(parameterValues);
    double b2 = beta2 == null ? Nadam.DEFAULT_NADAM_LEARNING_RATE : beta2.getValue(parameterValues);
    double eps = epsilon == null ? Nadam.DEFAULT_NADAM_LEARNING_RATE : epsilon.getValue(parameterValues);
    if(lrS == null){
        return new Nadam(lr, b1, b2, eps);
    } else {
        Nadam a = new Nadam(lrS);
        a.setBeta1(b1);
        a.setBeta2(b2);
        a.setEpsilon(eps);
        return a;
    }
}
 
Example #3
Source File: NetworkUtils.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
private static void setLearningRate(MultiLayerNetwork net, int layerNumber, double newLr, ISchedule newLrSchedule, boolean refreshUpdater) {

        Layer l = net.getLayer(layerNumber).conf().getLayer();
        if (l instanceof BaseLayer) {
            BaseLayer bl = (BaseLayer) l;
            IUpdater u = bl.getIUpdater();
            if (u != null && u.hasLearningRate()) {
                if (newLrSchedule != null) {
                    u.setLrAndSchedule(Double.NaN, newLrSchedule);
                } else {
                    u.setLrAndSchedule(newLr, null);
                }
            }

            //Need to refresh the updater - if we change the LR (or schedule) we may rebuild the updater blocks, which are
            // built by creating blocks of params with the same configuration
            if (refreshUpdater) {
                refreshUpdater(net);
            }
        }
    }
 
Example #4
Source File: AdamSpace.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public IUpdater getValue(double[] parameterValues) {
    double lr = learningRate == null ? Adam.DEFAULT_ADAM_LEARNING_RATE : learningRate.getValue(parameterValues);
    ISchedule lrS = learningRateSchedule == null ? null : learningRateSchedule.getValue(parameterValues);
    double b1 = beta1 == null ? Adam.DEFAULT_ADAM_LEARNING_RATE : beta1.getValue(parameterValues);
    double b2 = beta2 == null ? Adam.DEFAULT_ADAM_LEARNING_RATE : beta2.getValue(parameterValues);
    double eps = epsilon == null ? Adam.DEFAULT_ADAM_LEARNING_RATE : epsilon.getValue(parameterValues);
    if(lrS == null){
        return new Adam(lr, b1, b2, eps);
    } else {
        Adam a = new Adam(lrS);
        a.setBeta1(b1);
        a.setBeta2(b2);
        a.setEpsilon(eps);
        return a;
    }
}
 
Example #5
Source File: Dropout.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
@OptionMetadata(
    displayName = "pSchedule",
    description = "The dropout probability schedule  (default = ConstantScheduleImpl).",
    commandLineParamName = "pSchedule",
    commandLineParamSynopsis = "-pSchedule <Schedule>",
    displayOrder = 2
)
public Schedule<? extends ISchedule> getpSchedule() {
  return Schedule.create(backend.getPSchedule());
}
 
Example #6
Source File: Dropout.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
@OptionMetadata(
    displayName = "pSchedule",
    description = "The dropout probability schedule  (default = ConstantScheduleImpl).",
    commandLineParamName = "pSchedule",
    commandLineParamSynopsis = "-pSchedule <Schedule>",
    displayOrder = 2
)
public Schedule<? extends ISchedule> getpSchedule() {
  return Schedule.create(backend.getPSchedule());
}
 
Example #7
Source File: AlphaDropout.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
@OptionMetadata(
    displayName = "schedule",
    description = "The dropout probability schedule (default = ConstantScheduleImpl).",
    commandLineParamName = "schedule",
    commandLineParamSynopsis = "-schedule <Schedule>",
    displayOrder = 1
)
public Schedule<? extends ISchedule> getpSchedule() {
  return pSchedule;
}
 
Example #8
Source File: AdaMaxSpace.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
public AdaMaxSpace(@JsonProperty("learningRate") ParameterSpace<Double> learningRate,
                   @JsonProperty("learningRateSchedule") ParameterSpace<ISchedule> learningRateSchedule,
                   @JsonProperty("beta1") ParameterSpace<Double> beta1,
                   @JsonProperty("beta2") ParameterSpace<Double> beta2,
                   @JsonProperty("epsilon") ParameterSpace<Double> epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #9
Source File: GaussianDropout.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
@OptionMetadata(
    displayName = "schedule",
    description = "The rate schedule (default = ConstantScheduleImpl).",
    commandLineParamName = "schedule",
    commandLineParamSynopsis = "-schedule <Schedule>",
    displayOrder = 2
)
public Schedule<? extends ISchedule> getRateSchedule() {
  return rateSchedule;
}
 
Example #10
Source File: NadamSpace.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
public NadamSpace(@JsonProperty("learningRate") ParameterSpace<Double> learningRate,
                  @JsonProperty("learningRateSchedule") ParameterSpace<ISchedule> learningRateSchedule,
                  @JsonProperty("beta1") ParameterSpace<Double> beta1,
                  @JsonProperty("beta2") ParameterSpace<Double> beta2,
                  @JsonProperty("epsilon") ParameterSpace<Double> epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #11
Source File: AdaGrad.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private AdaGrad(@JsonProperty("learningRate") double learningRate,
                @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
                @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.epsilon = epsilon;
}
 
Example #12
Source File: Nesterovs.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private Nesterovs(@JsonProperty("learningRate") double learningRate,
                  @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
                  @JsonProperty("momentum") double momentum,
                  @JsonProperty("momentumSchedule") ISchedule momentumISchedule){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.momentum = momentum;
    this.momentumISchedule = momentumISchedule;
}
 
Example #13
Source File: AlphaDropout.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
@OptionMetadata(
    displayName = "schedule",
    description = "The dropout probability schedule (default = ConstantScheduleImpl).",
    commandLineParamName = "schedule",
    commandLineParamSynopsis = "-schedule <Schedule>",
    displayOrder = 1
)
public Schedule<? extends ISchedule> getpSchedule() {
  return pSchedule;
}
 
Example #14
Source File: GaussianNoise.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
@OptionMetadata(
    displayName = "schedule",
    description = "The standard deviation schedule (default = ConstantScheduleImpl).",
    commandLineParamName = "schedule",
    commandLineParamSynopsis = "-schedule <Schedule>",
    displayOrder = 2
)
public Schedule<? extends ISchedule> getRateSchedule() {
  return rateSchedule;
}
 
Example #15
Source File: AdaMax.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private AdaMax(@JsonProperty("learningRate") double learningRate,
               @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
               @JsonProperty("beta1") double beta1,
               @JsonProperty("beta2") double beta2,
               @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #16
Source File: AMSGrad.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private AMSGrad(@JsonProperty("learningRate") double learningRate,
                @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
                @JsonProperty("beta1") double beta1,
                @JsonProperty("beta2") double beta2,
                @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #17
Source File: Updater.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the learning rate schedule
 *
 * @param learningRateSchedule Learning rate schedule
 */
public void setLearningRateSchedule(Schedule<? extends ISchedule> learningRateSchedule) {
  this.learningRateSchedule = learningRateSchedule;
  if (hasLearningRate()) {
    learningRateSchedule.setInitialValue(learningRate);
    this.backend.setLrAndSchedule(this.learningRate, this.learningRateSchedule.getBackend());
  }
}
 
Example #18
Source File: Adam.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private Adam(@JsonProperty("learningRate") double learningRate,
             @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
             @JsonProperty("beta1") double beta1,
             @JsonProperty("beta2") double beta2,
             @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #19
Source File: NetworkUtils.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private static void setLearningRate(MultiLayerNetwork net, double newLr, ISchedule lrSchedule) {
    int nLayers = net.getnLayers();
    for (int i = 0; i < nLayers; i++) {
        setLearningRate(net, i, newLr, lrSchedule, false);
    }
    refreshUpdater(net);
}
 
Example #20
Source File: Adam.java    From nd4j with Apache License 2.0 5 votes vote down vote up
private Adam(@JsonProperty("learningRate") double learningRate,
             @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
             @JsonProperty("beta1") double beta1,
             @JsonProperty("beta2") double beta2,
             @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #21
Source File: AdaMax.java    From nd4j with Apache License 2.0 5 votes vote down vote up
private AdaMax(@JsonProperty("learningRate") double learningRate,
               @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
               @JsonProperty("beta1") double beta1,
               @JsonProperty("beta2") double beta2,
               @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #22
Source File: DropConnect.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private DropConnect(@JsonProperty("weightRetainProbability") double weightRetainProbability,
                    @JsonProperty("weightRetainProbSchedule") ISchedule weightRetainProbSchedule,
                    @JsonProperty("applyToBiases") boolean applyToBiases) {
    this.weightRetainProb = weightRetainProbability;
    this.weightRetainProbSchedule = weightRetainProbSchedule;
    this.applyToBiases = applyToBiases;
}
 
Example #23
Source File: AMSGrad.java    From nd4j with Apache License 2.0 5 votes vote down vote up
private AMSGrad(@JsonProperty("learningRate") double learningRate,
                @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
                @JsonProperty("beta1") double beta1,
                @JsonProperty("beta2") double beta2,
                @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #24
Source File: Nadam.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private Nadam(@JsonProperty("learningRate") double learningRate,
              @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
              @JsonProperty("beta1") double beta1,
              @JsonProperty("beta2") double beta2,
              @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #25
Source File: SgdSpace.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public IUpdater getValue(double[] parameterValues) {
    double lr = learningRate == null ? Sgd.DEFAULT_SGD_LR : learningRate.getValue(parameterValues);
    ISchedule lrS = learningRateSchedule == null ? null : learningRateSchedule.getValue(parameterValues);
    if(lrS == null){
        return new Sgd(lr);
    } else {
        return new Sgd(lrS);
    }
}
 
Example #26
Source File: Nadam.java    From nd4j with Apache License 2.0 5 votes vote down vote up
private Nadam(@JsonProperty("learningRate") double learningRate,
              @JsonProperty("learningRateSchedule") ISchedule learningRateSchedule,
              @JsonProperty("beta1") double beta1,
              @JsonProperty("beta2") double beta2,
              @JsonProperty("epsilon") double epsilon){
    this.learningRate = learningRate;
    this.learningRateSchedule = learningRateSchedule;
    this.beta1 = beta1;
    this.beta2 = beta2;
    this.epsilon = epsilon;
}
 
Example #27
Source File: Nadam.java    From nd4j with Apache License 2.0 4 votes vote down vote up
@Override
public void setLrAndSchedule(double lr, ISchedule lrSchedule) {
    this.learningRate = lr;
    this.learningRateSchedule = lrSchedule;
}
 
Example #28
Source File: AMSGrad.java    From nd4j with Apache License 2.0 4 votes vote down vote up
@Override
public void setLrAndSchedule(double lr, ISchedule lrSchedule) {
    this.learningRate = lr;
    this.learningRateSchedule = lrSchedule;
}
 
Example #29
Source File: ExponentialScheduleSpace.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public ISchedule getValue(double[] parameterValues) {
    return new ExponentialSchedule(scheduleType, initialValue.getValue(parameterValues), gamma.getValue(parameterValues));
}
 
Example #30
Source File: NadamSpace.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public static NadamSpace withLRSchedule(ParameterSpace<ISchedule> lrSchedule){
    return new NadamSpace(null, lrSchedule, null, null, null);
}