All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.expleague.ml.func.generic.ReLU Maven / Gradle / Ivy

package com.expleague.ml.func.generic;

import com.expleague.commons.math.vectors.SingleValueVec;
import com.expleague.commons.math.vectors.Vec;
import com.expleague.commons.math.FuncC1;

/**
* User: solar
* Date: 27.05.15
* Time: 17:59
*/
public class ReLU extends FuncC1.Stub {
  @Override
  public Vec gradient(Vec x) {
    final double v = x.get(0);
    return new SingleValueVec(v > 0 ? 1 : 0);
  }

  @Override
  public double value(Vec x) {
    final double v = x.get(0);
    return v > 0 ? v : 0;
  }

  @Override
  public int dim() {
    return 0;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy