public abstract class Layer
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
protected double[] |
bias
The bias.
|
protected double[] |
gradient
The gradient vector.
|
protected int |
n
The number of neurons in this layer
|
protected double[] |
output
The output vector.
|
protected int |
p
The number of input variables.
|
protected smile.math.matrix.Matrix |
update
The weight update of mini batch or momentum.
|
protected double[] |
updateBias
The bias update of mini batch or momentum.
|
protected smile.math.matrix.Matrix |
weight
The affine transformation matrix.
|
| Constructor and Description |
|---|
Layer(int n,
int p)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
backpropagate(double[] error)
Propagates the errors back to a lower layer.
|
void |
computeUpdate(double eta,
double alpha,
double[] x)
Computes the updates of weight.
|
abstract void |
f(double[] x)
The activation or output function.
|
int |
getInputSize()
Returns the dimension of input vector (not including bias value).
|
int |
getOutputSize()
Returns the dimension of output vector.
|
double[] |
gradient()
Returns the error/gradient vector.
|
static smile.base.mlp.HiddenLayerBuilder |
linear(int n)
Returns a hidden layer with linear activation function.
|
static smile.base.mlp.OutputLayerBuilder |
mle(int n,
OutputFunction f)
Returns an output layer with (log-)likelihood cost function.
|
static smile.base.mlp.OutputLayerBuilder |
mse(int n,
OutputFunction f)
Returns an output layer with mean squared error cost function.
|
double[] |
output()
Returns the output vector.
|
void |
propagate(double[] x)
Propagates signals from a lower layer to this layer.
|
static smile.base.mlp.HiddenLayerBuilder |
rectifier(int n)
Returns a hidden layer with rectified linear activation function.
|
static smile.base.mlp.HiddenLayerBuilder |
sigmoid(int n)
Returns a hidden layer with sigmoid activation function.
|
static smile.base.mlp.HiddenLayerBuilder |
tanh(int n)
Returns a hidden layer with hyperbolic tangent activation function.
|
void |
update(double alpha,
double lambda)
Adjust network weights by back-propagation algorithm.
|
protected int n
protected int p
protected double[] output
protected double[] gradient
protected smile.math.matrix.Matrix weight
protected smile.math.matrix.Matrix update
protected double[] bias
protected double[] updateBias
public Layer(int n,
int p)
n - the number of neurons.p - the number of input variables (not including bias value).public int getOutputSize()
public int getInputSize()
public double[] output()
public double[] gradient()
public void propagate(double[] x)
x - the lower layer signals.public abstract void f(double[] x)
x - the input and output values.public abstract void backpropagate(double[] error)
error - the gradient vector of lower layer.public void computeUpdate(double eta,
double alpha,
double[] x)
eta - the learning rate.alpha - the momentum factorx - the input vector.public void update(double alpha,
double lambda)
alpha - the momentum factorlambda - weight decay factorpublic static smile.base.mlp.HiddenLayerBuilder linear(int n)
n - the number of neurons.public static smile.base.mlp.HiddenLayerBuilder rectifier(int n)
n - the number of neurons.public static smile.base.mlp.HiddenLayerBuilder sigmoid(int n)
n - the number of neurons.public static smile.base.mlp.HiddenLayerBuilder tanh(int n)
n - the number of neurons.public static smile.base.mlp.OutputLayerBuilder mse(int n,
OutputFunction f)
n - the number of neurons.f - the output function.public static smile.base.mlp.OutputLayerBuilder mle(int n,
OutputFunction f)
n - the number of neurons.f - the output function.