📄 synapse.java
字号:
package org.scut.DataMining.Algorithm.NeuralNetwork.Core;
public class Synapse
{
/** Neuron connects backward to the synapse */
private Neuron backwardNeuron;
/** Neuron connects forward to the synapse */
private Neuron forwardNeuron;
/** Weight of the Neuron */
private double weight;
/** Delta weight to be changed of the neuron */
private double deltaWeight;
/** Learning rate of the synapse */
private double learningRate = 0.1;
/** Random initialized random range for the synapse */
private double initRandomRange = 0.05;
public Synapse(Neuron backward,Neuron forward)
{
super();
// TODO Auto-generated constructor stub
this.backwardNeuron = backward;
this.forwardNeuron = forward;
this.weight = (Math.random()-0.5)*2*this.initRandomRange;
this.deltaWeight = 0;
}
/**
* Gets the weight of the synapse
* @return weight value of the synapse
*/
public double getWeight()
{
return this.weight;
}
/**
* Sets the weight
* @param weight
*/
public void setWeight(double weight)
{
this.weight = weight;
}
/** Adds the weight by delta weight and, sets the delta weight zero*/
public void updateWeight()
{
this.weight += this.deltaWeight;
this.deltaWeight = 0.0;
}
/**
* Gets the delta weight
* @return delta weight value
*/
public double getDeltaWeight()
{
return this.deltaWeight;
}
/**
* Adds the delta weight at the accelerate speed(learning rate)
* @param value delta value
*/
public void updateDeltaWeight(double value)
{
this.deltaWeight += this.learningRate*value;
}
/**
* Gets the backward neuron of the synapse
* @return backward neuron
*/
public Neuron getBackwardNeuron()
{
return this.backwardNeuron;
}
/**
* Gets the forward neuron of the synapse
* @return forward neuron
*/
public Neuron getForwardNeuron()
{
return this.forwardNeuron;
}
/**
* Gets the learning rate
* @return learning rate
* */
public double getLearningRate()
{
return this.learningRate;
}
/**
* Sets the learning rate
* @param value learning rate to be set
*/
public void setLearningRate(double value)
{
this.learningRate = value;
}
/**
* Gets the initial weight random range
* @return random range value
*/
public double getInitRandomRange()
{
return this.initRandomRange;
}
/**
* Sets the initial weight random range
* @param value random range to be set
*/
public void setInitRandomRange(double value)
{
this.initRandomRange = value;
this.weight = (Math.random()-0.5)*2*this.initRandomRange;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -