Package org.jblas

Examples of org.jblas.DoubleMatrix.sub()


 
  @Override
  protected double loss(List<SampleVector> samples) {
    DoubleMatrix x_samples = MathUtil.convertX2Matrix(samples);
        DoubleMatrix reconstruct_x = reconstruct(x_samples);
    return MatrixFunctions.powi(reconstruct_x.sub(x_samples), 2).sum();
  }
 
  @Override
  protected void gradientUpdateMiniBatch(SGDTrainConfig config, DoubleMatrix x_samples, DoubleMatrix y_samples, SGDParam curr_param) {
    int nbr_sample = x_samples.rows;
View Full Code Here


    /**
     * backward
     */
    // 1 last layer
    DoubleMatrix ai = activation[curr_pbparam.nl - 1];
    l_bias[curr_pbparam.nl - 1] = ai.sub(x_samples).muli(ai).muli(ai.neg().addi(1));
   
    //2 back
    for(int i = curr_pbparam.nl - 2; i >= 1; i--) {
      l_bias[i] = l_bias[i + 1].mmul(curr_pbparam.w[i]);
      if(config.isForceSparsity()) {
View Full Code Here

      /**
       * backward
       */
      // 1 last layer
      DoubleMatrix ai = activation[my_bpparam.nl - 1];
      l_bias[my_bpparam.nl - 1] = ai.sub(activation[0]).muli(ai).muli(ai.neg().addi(1));
     
      //2 back(no layer0 error need)
      for(int i = my_bpparam.nl - 2; i >= 1; i--) {
        l_bias[i] = l_bias[i + 1].mmul(my_bpparam.w[i]);
        if(my_config.isForceSparsity()) {
View Full Code Here

   
    @Override
    protected final double loss(List<SampleVector> samples) {
      DoubleMatrix x = MathUtil.convertX2Matrix(samples);
        DoubleMatrix reconstruct_x = reconstruct(x);
        return MatrixFunctions.powi(reconstruct_x.sub(x), 2).sum();
    }
   
    @Override
    protected final boolean isSupervise() {
    return false;
View Full Code Here

  @Override
  protected double loss(List<SampleVector> samples) {
    DoubleMatrix x_samples = MathUtil.convertX2Matrix(samples);
        DoubleMatrix y_samples = MathUtil.convertY2Matrix(samples);
        DoubleMatrix predict_y = predict(x_samples);
        return MatrixFunctions.powi(predict_y.sub(y_samples), 2).sum();
  }

  @Override
  protected boolean isSupervise() {
    return true;
View Full Code Here

    /**
     * backward
     */
    // 1 last layer
    DoubleMatrix ai = activation[curr_pbparam.nl - 1];
    l_bias[curr_pbparam.nl - 1] = ai.sub(y_samples).muli(ai).muli(ai.neg().addi(1));
   
    //2 back
    for(int i = curr_pbparam.nl - 2; i >= 1; i--) {
      ai = activation[i];
      l_bias[i] = l_bias[i + 1].mmul(curr_pbparam.w[i]).muli(ai).muli(ai.neg().addi(1));
View Full Code Here

  @Override
  protected double loss(List<SampleVector> samples) {
    DoubleMatrix x_samples = MathUtil.convertX2Matrix(samples);
        DoubleMatrix y_samples = MathUtil.convertY2Matrix(samples);
        DoubleMatrix sigmod_output = sigmod_output(x_samples);
    return MatrixFunctions.powi(sigmod_output.sub(y_samples), 2).sum();
  }

  @Override
  protected boolean isSupervise() {
    return true;
View Full Code Here

      /**
       * backward
       */
      // 1 last layer
      DoubleMatrix ai = activation[my_bpparam.nl - 1];
      l_bias[my_bpparam.nl - 1] = ai.sub(my_y_samples).muli(ai).muli(ai.neg().addi(1));
     
      //2 back(no layer0 error need)
      for(int i = my_bpparam.nl - 2; i >= 1; i--) {
        ai = activation[i];
        l_bias[i] = l_bias[i + 1].mmul(my_bpparam.w[i]).muli(ai).muli(ai.neg().addi(1));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.