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

com.expleague.ml.methods.seq.nn.NetworkLayer Maven / Gradle / Ivy

package com.expleague.ml.methods.seq.nn;

import com.expleague.commons.math.vectors.Mx;
import com.expleague.commons.math.vectors.Vec;

public interface NetworkLayer {
  /**
   *
   * @param x input to the layer
   * @return array of output values of the nodes
   */
  Mx value(Mx x);

  /**
   *
   * @param x input to the layer
   * @param outputGrad gradient by output of this layer
   * @param isAfterValue set to true to optimize calculations. Can be used only after calling value on the same x
   * @return
   */
  LayerGrad gradient(Mx x, Mx outputGrad, boolean isAfterValue);

  void adjustParams(Vec dW);

  void setParams(Vec newW);

  int paramCount();

  Vec paramsView();

  class LayerGrad {
    public Vec gradByParams;
    public Mx gradByInput;

    LayerGrad(Vec gradByParams, Mx gradByInput) {
      this.gradByParams = gradByParams;
      this.gradByInput = gradByInput;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy