Package samer.models
Class MatrixTrainer
- java.lang.Object
-
- samer.models.MatrixTrainer
-
- All Implemented Interfaces:
- Model.Trainer
public class MatrixTrainer extends java.lang.Object implements Model.Trainer
Handles batched delta updates to a matrix. The default flush multiplies the accumulated delta by the learing rate and adds it to the matrix.
-
-
Field Summary
Fields Modifier and Type Field and Description protected double[][]
_A
protected double[][]
_T
protected double[]
a
protected Matrix
A
protected double[]
b
protected double
count
protected int
m
protected int
n
protected double
rate
protected VParameter
ratep
protected Matrix
T
-
Constructor Summary
Constructors Constructor and Description MatrixTrainer(double[] a, Matrix A, double[] b)
MatrixTrainer(Vec left, Matrix A, Vec right)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
accumulate()
collect statistics for parameter updatevoid
accumulate(double w)
weighted accumulatevoid
dispose()
void
flush()
use collected stats to update parameters and resetdouble
get()
VParameter
getRate()
void
oneshot()
Must be equivalent to reset(); accumulate(); flush(); but can be optimised for non-batched trainingprotected void
outerProduct(double w, double[] a, double[] b)
void
reset()
reset accumulators without updating parametersvoid
set(double r)
-
-
-
Field Detail
-
_A
protected double[][] _A
-
_T
protected double[][] _T
-
a
protected double[] a
-
A
protected Matrix A
-
b
protected double[] b
-
count
protected double count
-
m
protected int m
-
n
protected int n
-
rate
protected double rate
-
ratep
protected VParameter ratep
-
T
protected Matrix T
-
-
Constructor Detail
-
MatrixTrainer
public MatrixTrainer(double[] a, Matrix A, double[] b)
-
-
Method Detail
-
set
public void set(double r)
-
get
public double get()
-
getRate
public VParameter getRate()
-
outerProduct
protected void outerProduct(double w, double[] a, double[] b)
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceModel.Trainer
-
reset
public void reset()
Description copied from interface:Model.Trainer
reset accumulators without updating parameters- Specified by:
reset
in interfaceModel.Trainer
-
oneshot
public void oneshot()
Description copied from interface:Model.Trainer
Must be equivalent to reset(); accumulate(); flush(); but can be optimised for non-batched training- Specified by:
oneshot
in interfaceModel.Trainer
-
accumulate
public void accumulate()
Description copied from interface:Model.Trainer
collect statistics for parameter update- Specified by:
accumulate
in interfaceModel.Trainer
-
accumulate
public void accumulate(double w)
Description copied from interface:Model.Trainer
weighted accumulate- Specified by:
accumulate
in interfaceModel.Trainer
-
flush
public void flush()
Description copied from interface:Model.Trainer
use collected stats to update parameters and reset- Specified by:
flush
in interfaceModel.Trainer
-
-