public class Matrix
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Besides the weights or biases, it holds the last modification (update value or delta) and 2 boolean values indicating whether the weight is on or off and trainable or fixed.
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_INITIAL
This constant defines the boundaries of the default domain used for
weight initialization.
|
double[][] |
delta
The value of the last modification, i.e.
|
boolean[][] |
enabled
Flag indicating whether the weight is on or off.
|
boolean[][] |
fixed
Flag indicating whether the weight is fixed or trainable / adjustable.
|
protected int |
m_cols
The number of columns.
|
protected int |
m_rows
The number of rows.
|
double[][] |
value
The values of the weights / biases.
|
protected WeightInitializer |
weightInitializer
The weight initializer that is used by this class.
|
Constructor and Description |
---|
Matrix()
Default constructor
Needed for Save as XML
|
Matrix(int aRows,
int aColumns)
This constructur creates a weights or biases according to the values
aRows and aColumns . |
Matrix(int aRows,
int aColumns,
double anInitial)
This constructur creates a weights or biases according to the values
aRows and aColumns . |
Modifier and Type | Method and Description |
---|---|
void |
addNoise(double amplitude)
Adds noise to the weights.
|
void |
clear()
Clears (resets) the matrix object.
|
void |
clearDelta()
Clears (sets to zero) the delta values.
|
java.lang.Object |
clone()
Clones this matrix object.
|
void |
disableAll()
Disables all the weights (or biases) of this matrix.
|
void |
enableAll()
Enables all the weights (or biases) of this matrix.
|
void |
fixAll()
Fixes all the weights (or biases) of this matrix.
|
double[][] |
getDelta()
Gets
delta[][] . |
boolean[][] |
getEnabled()
Gets
enabled . |
boolean[][] |
getFixed()
Gets
fixed[][] . |
int |
getM_cols()
Gets
m_cols . |
int |
getM_rows()
Gets
m_rows . |
double[][] |
getValue()
Gets
value[][] . |
WeightInitializer |
getWeightInitializer()
Gets the weight initializer.
|
void |
initialize()
Initializes the weights or biases by making a call to the weight initializer.
|
void |
randomizeConditionally(double amplitude)
Initializes the weights or biases by making a call to the weight initializer.
|
void |
removeColumn(int aColumn)
Removes a column.
|
void |
removeRow(int aRow)
Removes a row.
|
void |
setDelta(double[][] newdelta)
Sets
delta[][] . |
void |
setEnabled(boolean[][] newenabled)
Sets
enabled[][] . |
void |
setFixed(boolean[][] newfixed)
Sets
fixed . |
void |
setM_cols(int newm_cols)
Sets
m_cols . |
void |
setM_rows(int newm_rows)
Sets
m_rows . |
void |
setValue(double[][] newvalue)
Sets
value[][] . |
void |
setWeightInitializer(WeightInitializer aWeightInitializer)
Sets the weight initializer and initializes the weights.
|
void |
setWeightInitializer(WeightInitializer aWeightInitializer,
boolean anInitialize)
Sets the weight initializer.
|
void |
unfixAll()
Unfixes all the weights (or biases) of this matrix.
|
public static final double DEFAULT_INITIAL
[-DEFAULT_INITIAL, DEFAULT_INITIAL]
. Although different
boundaries or even different weight intialization can be used by calling
differnt constructors that that a WeightInitializer
class
as parameter or by calling the method initialize()
.public double[][] value
public double[][] delta
public boolean[][] enabled
public boolean[][] fixed
protected int m_rows
protected int m_cols
protected WeightInitializer weightInitializer
public Matrix()
public Matrix(int aRows, int aColumns)
aRows
and aColumns
. The weights or biases
are initialised with a random value in the domain of
[-DEFAULT_INITIAL, DEFAULT_INITIAL]
.aRows
- the number of rows (the number of neurons on the input side
of a synapse or the number of biases).aColumns
- the number of colums (the number of neurons on the output
side of a synapse or zero in case of biases).public Matrix(int aRows, int aColumns, double anInitial)
aRows
and aColumns
. And the weights or biases
are initialized with a random value in the domain of
[-anInitial, anInitial]
.aRows
- the number of rows (the number of neurons on the input side
of a synapse or the number of biases).aColumns
- the number of colums (the number of neurons on the output
side of a synapse or zero in case of biases).anInitial
- the boundary of the domain within these weights or biases
shoud be randomly initialized.public void initialize()
setWeightInitializer(WeightInitializer)
public void randomizeConditionally(double amplitude)
amplitude
- public void setWeightInitializer(WeightInitializer aWeightInitializer)
aWeightInitializer
- the weight initializer to set.public void setWeightInitializer(WeightInitializer aWeightInitializer, boolean anInitialize)
aWeightInitializer
- the weight initializer to set.anInitialize
- if true the weights will be initialized by the new
weight initializer, if false the weights will not be initialized.public WeightInitializer getWeightInitializer()
public java.lang.Object clone()
clone
in class java.lang.Object
public void addNoise(double amplitude)
[-amplitude, amplitude]
.amplitude
- defines the domain of noise.public void removeRow(int aRow)
aRow
- the row to remove.public void removeColumn(int aColumn)
aColumn
- the column to remove.public void clear()
public void clearDelta()
public void enableAll()
public void disableAll()
public void fixAll()
public void unfixAll()
public int getM_rows()
m_rows
. Needed for Save as XMLm_rows
public void setM_rows(int newm_rows)
m_rows
. Needed for Save as XMLnewm_rows
- the new number of rows to set.public int getM_cols()
m_cols
. Needed for Save as XMLm_cols
public void setM_cols(int newm_cols)
m_cols
. Needed for Save as XMLnewm_cols
- the new number of columns to set.public double[][] getDelta()
delta[][]
. Needed for Save as XMLdelta[][]
public void setDelta(double[][] newdelta)
delta[][]
. Needed for Save as XMLnewdelta
- the new delta to set.public double[][] getValue()
value[][]
. Needed for Save as XMLvalue[][]
public void setValue(double[][] newvalue)
value[][]
. Needed for Save as XMLnewvalue
- the new values to setpublic boolean[][] getFixed()
fixed[][]
. Needed for Save as XMLfixed[][]
public void setFixed(boolean[][] newfixed)
fixed
. Needed for Save as XMLnewfixed
- the new fixed values to setpublic boolean[][] getEnabled()
enabled
. Needed for Save as XMLenabled[][]
public void setEnabled(boolean[][] newenabled)
enabled[][]
. Needed for Save as XMLnewenabled
- the new enabled values to set.Submit Feedback to pmarrone@users.sourceforge.net