Examples of DenseDoubleVector


Examples of org.apache.hama.commons.math.DenseDoubleVector

      // normalize instances
      zeroOneNormalization(instanceList, instanceList.get(0).length);
     
      SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, path, LongWritable.class, VectorWritable.class);
      for (int i = 0; i < instanceList.size(); ++i) {
        DoubleVector vector = new DenseDoubleVector(instanceList.get(i));
        writer.append(new LongWritable(i), new VectorWritable(vector));
      }
     
      writer.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
   
    AutoEncoder encoder = new AutoEncoder(3, 2);
    String modelPath = "/tmp/autoencoder-modelpath";
    encoder.setModelPath(modelPath);
    Map<String, String> trainingParams = new HashMap<String, String>();
    encoder.setLearningRate(0.5);
    trainingParams.put("tasks", "5");
    trainingParams.put("training.max.iterations", "3000");
    trainingParams.put("training.batch.size", "200");
    encoder.train(path, trainingParams);
   
    double errorInstance = 0;
    for (double[] instance : instanceList) {
      DoubleVector vector = new DenseDoubleVector(instance);
      DoubleVector decoded = encoder.getOutput(vector);
      DoubleVector diff = vector.subtract(decoded);
      double error = diff.dot(diff);
      if (error > 0.1) {
        ++errorInstance;
      }
    }
View Full Code Here

Examples of org.apache.hama.commons.math.DenseDoubleVector

      if (usePipesVectorWritable) {
        writer = new SequenceFile.Writer(fs, conf, path, IntWritable.class,
            PipesVectorWritable.class);

        for (int i = 0; i < matrix.length; i++) {
          DenseDoubleVector rowVector = new DenseDoubleVector(matrix[i]);
          writer.append(new IntWritable(i), new PipesVectorWritable(rowVector));
          LOG.debug("IntWritable: " + i + " PipesVectorWritable: "
              + rowVector.toString());
        }

      } else {
        writer = new SequenceFile.Writer(fs, conf, path, IntWritable.class,
            VectorWritable.class);

        for (int i = 0; i < matrix.length; i++) {
          DenseDoubleVector rowVector = new DenseDoubleVector(matrix[i]);
          writer.append(new IntWritable(i), new VectorWritable(rowVector));
          LOG.debug("IntWritable: " + i + " VectorWritable: "
              + rowVector.toString());
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.apache.hama.ml.math.DenseDoubleVector

   * The model meta-data is stored in memory.
   */
  public DoubleVector output(DoubleVector featureVector) {
    List<double[]> outputCache = this.outputInternal(featureVector);
    // the output of the last layer is the output of the MLP
    return new DenseDoubleVector(outputCache.get(outputCache.size() - 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.