org.joone.engine
Class Matrix
- java.lang.Object
-
- org.joone.engine.Matrix
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class Matrix extends java.lang.Object implements java.io.Serializable, java.lang.CloneableThe Matrix object represents the connection matrix of the weights of a synapse or the biases of a layer. In case of a synapse, it contains the weight of each connection. In case of a layer, it contains the bias of each neuron.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.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleDEFAULT_INITIALThis constant defines the boundaries of the default domain used for weight initialization.double[][]deltaThe value of the last modification, i.e.boolean[][]enabledFlag indicating whether the weight is on or off.boolean[][]fixedFlag indicating whether the weight is fixed or trainable / adjustable.double[][]valueThe values of the weights / biases.
-
Constructor Summary
Constructors Constructor and Description Matrix()Default constructor Needed for Save as XMLMatrix(int aRows, int aColumns)This constructur creates a weights or biases according to the valuesaRowsandaColumns.Matrix(int aRows, int aColumns, double anInitial)This constructur creates a weights or biases according to the valuesaRowsandaColumns.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddNoise(double amplitude)Adds noise to the weights.voidclear()Clears (resets) the matrix object.java.lang.Objectclone()Clones this matrix object.voiddisableAll()Disables all the weights (or biases) of this matrix.voidenableAll()Enables all the weights (or biases) of this matrix.voidfixAll()Fixes all the weights (or biases) of this matrix.double[][]getDelta()Getsdelta[][].boolean[][]getEnabled()Getsenabled.boolean[][]getFixed()Getsfixed[][].intgetM_cols()Getsm_cols.intgetM_rows()Getsm_rows.double[][]getValue()Getsvalue[][].WeightInitializergetWeightInitializer()Gets the weight initializer.voidinitialize()Initializes the weights or biases by making a call to the weight initializer.voidremoveColumn(int aColumn)Removes a column.voidremoveRow(int aRow)Removes a row.voidsetDelta(double[][] newdelta)Setsdelta[][].voidsetEnabled(boolean[][] newenabled)Setsenabled[][].voidsetFixed(boolean[][] newfixed)Setsfixed.voidsetM_cols(int newm_cols)Setsm_cols.voidsetM_rows(int newm_rows)Setsm_rows.voidsetValue(double[][] newvalue)Setsvalue[][].voidsetWeightInitializer(WeightInitializer aWeightInitializer)Sets the weight initializer and initializes the weights.voidsetWeightInitializer(WeightInitializer aWeightInitializer, boolean anInitialize)Sets the weight initializer.voidunfixAll()Unfixes all the weights (or biases) of this matrix.
-
-
-
Field Detail
-
DEFAULT_INITIAL
public static final double DEFAULT_INITIAL
This constant defines the boundaries of the default domain used for weight initialization. Weights or biases are initialised by default with a random value in the domain[-DEFAULT_INITIAL, DEFAULT_INITIAL]. Although different boundaries or even different weight intialization can be used by calling differnt constructors that that aWeightInitializerclass as parameter or by calling the methodinitialize().- See Also:
- Constant Field Values
-
value
public double[][] value
The values of the weights / biases.
-
delta
public double[][] delta
The value of the last modification, i.e. the last update.
-
enabled
public boolean[][] enabled
Flag indicating whether the weight is on or off.
-
fixed
public boolean[][] fixed
Flag indicating whether the weight is fixed or trainable / adjustable.
-
-
Constructor Detail
-
Matrix
public Matrix()
Default constructor Needed for Save as XML
-
Matrix
public Matrix(int aRows, int aColumns)This constructur creates a weights or biases according to the valuesaRowsandaColumns. The weights or biases are initialised with a random value in the domain of[-DEFAULT_INITIAL, DEFAULT_INITIAL].- Parameters:
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).
-
Matrix
public Matrix(int aRows, int aColumns, double anInitial)This constructur creates a weights or biases according to the valuesaRowsandaColumns. And the weights or biases are initialized with a random value in the domain of[-anInitial, anInitial].- Parameters:
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.
-
-
Method Detail
-
initialize
public void initialize()
Initializes the weights or biases by making a call to the weight initializer. The weight initializer can be set throughsetWeightInitializer(WeightInitializer)
-
setWeightInitializer
public void setWeightInitializer(WeightInitializer aWeightInitializer)
Sets the weight initializer and initializes the weights. This function calls setWeightInitializer(aWeightInitializer, true).- Parameters:
aWeightInitializer- the weight initializer to set.
-
setWeightInitializer
public void setWeightInitializer(WeightInitializer aWeightInitializer, boolean anInitialize)
Sets the weight initializer.- Parameters:
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.
-
getWeightInitializer
public WeightInitializer getWeightInitializer()
Gets the weight initializer.- Returns:
- the weight initializer that is set for this matrix.
-
clone
public java.lang.Object clone()
Clones this matrix object. It returns a copy of this matrix object.- Overrides:
clonein classjava.lang.Object- Returns:
- a copy of the current matrix object.
-
addNoise
public void addNoise(double amplitude)
Adds noise to the weights. The noise that is added to the weights is within the domain[-amplitude, amplitude].- Parameters:
amplitude- defines the domain of noise.
-
removeRow
public void removeRow(int aRow)
Removes a row.- Parameters:
aRow- the row to remove.
-
removeColumn
public void removeColumn(int aColumn)
Removes a column.- Parameters:
aColumn- the column to remove.
-
clear
public void clear()
Clears (resets) the matrix object. The weights/ biases (values) and its delta values are reset to zero.
-
enableAll
public void enableAll()
Enables all the weights (or biases) of this matrix.
-
disableAll
public void disableAll()
Disables all the weights (or biases) of this matrix.
-
fixAll
public void fixAll()
Fixes all the weights (or biases) of this matrix.
-
unfixAll
public void unfixAll()
Unfixes all the weights (or biases) of this matrix.
-
getM_rows
public int getM_rows()
Getsm_rows. Needed for Save as XML- Returns:
m_rows
-
setM_rows
public void setM_rows(int newm_rows)
Setsm_rows. Needed for Save as XML- Parameters:
newm_rows- the new number of rows to set.
-
getM_cols
public int getM_cols()
Getsm_cols. Needed for Save as XML- Returns:
m_cols
-
setM_cols
public void setM_cols(int newm_cols)
Setsm_cols. Needed for Save as XML- Parameters:
newm_cols- the new number of columns to set.
-
getDelta
public double[][] getDelta()
Getsdelta[][]. Needed for Save as XML- Returns:
delta[][]
-
setDelta
public void setDelta(double[][] newdelta)
Setsdelta[][]. Needed for Save as XML- Parameters:
newdelta- the new delta to set.
-
getValue
public double[][] getValue()
Getsvalue[][]. Needed for Save as XML- Returns:
value[][]
-
setValue
public void setValue(double[][] newvalue)
Setsvalue[][]. Needed for Save as XML- Parameters:
newvalue- the new values to set
-
getFixed
public boolean[][] getFixed()
Getsfixed[][]. Needed for Save as XML- Returns:
fixed[][]
-
setFixed
public void setFixed(boolean[][] newfixed)
Setsfixed. Needed for Save as XML- Parameters:
newfixed- the new fixed values to set
-
getEnabled
public boolean[][] getEnabled()
Getsenabled. Needed for Save as XML- Returns:
enabled[][]
-
setEnabled
public void setEnabled(boolean[][] newenabled)
Setsenabled[][]. Needed for Save as XML- Parameters:
newenabled- the new enabled values to set.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG