Example usage for org.apache.mahout.math MatrixWritable writeMatrix

List of usage examples for org.apache.mahout.math MatrixWritable writeMatrix

Introduction

In this page you can find the example usage for org.apache.mahout.math MatrixWritable writeMatrix.

Prototype

public static void writeMatrix(final DataOutput out, Matrix matrix) throws IOException 

Source Link

Document

Writes a typed Matrix instance to the output stream

Usage

From source file:com.cloudera.knittingboar.messages.GlobalParameterVectorUpdateMessage.java

License:Apache License

public void Serialize(DataOutput d) throws IOException {

    d.writeInt(GlobalPassCount);/*  www.j  av a2 s .  c  om*/
    // buf.write
    MatrixWritable.writeMatrix(d, this.parameter_vector);
    // MatrixWritable.

}

From source file:com.cloudera.knittingboar.messages.GradientUpdateMessage.java

License:Apache License

public void Serialize(DataOutput d) throws IOException {

    d.writeUTF(src_host);/*from  w w w .  jav  a  2s .c o m*/
    d.writeInt(this.SrcWorkerPassCount);
    // buf.write
    MatrixWritable.writeMatrix(d, this.gradient.getMatrix());
    // MatrixWritable.

}

From source file:com.cloudera.knittingboar.messages.iterativereduce.ParameterVector.java

License:Apache License

public byte[] Serialize() throws IOException {

    // DataOutput d

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    DataOutput d = new DataOutputStream(out);

    // d.writeUTF(src_host);
    d.writeInt(this.SrcWorkerPassCount);
    d.writeInt(this.GlobalPassCount);

    d.writeInt(this.IterationComplete);
    d.writeInt(this.CurrentIteration);

    d.writeInt(this.TrainedRecords);
    d.writeFloat(this.AvgLogLikelihood);
    d.writeFloat(this.PercentCorrect);
    // buf.write/* w  w  w  . ja  va  2  s.  co m*/
    // MatrixWritable.writeMatrix(d, this.worker_gradient.getMatrix());
    MatrixWritable.writeMatrix(d, this.parameter_vector);
    // MatrixWritable.

    return out.toByteArray();
}

From source file:com.cloudera.knittingboar.sgd.ParallelOnlineLogisticRegression.java

License:Apache License

/**
 * TODO - add something in to write the gamma to the output stream -- do we
 * need to save gamma?/* w w w  .j av  a 2s.co  m*/
 */
@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(WRITABLE_VERSION);
    out.writeDouble(learningRate);
    out.writeDouble(decayFactor);
    out.writeInt(stepOffset);
    out.writeInt(step);
    out.writeDouble(forgettingExponent);
    out.writeInt(perTermAnnealingOffset);
    out.writeInt(numCategories);
    MatrixWritable.writeMatrix(out, beta);
    PolymorphicWritable.write(out, prior);
    VectorWritable.writeVector(out, updateCounts);
    VectorWritable.writeVector(out, updateSteps);

}