本文整理汇总了Java中org.encog.engine.network.activation.ActivationSigmoid类的典型用法代码示例。如果您正苦于以下问题:Java ActivationSigmoid类的具体用法?Java ActivationSigmoid怎么用?Java ActivationSigmoid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActivationSigmoid类属于org.encog.engine.network.activation包,在下文中一共展示了ActivationSigmoid类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNeuralNetwork
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
private BasicNetwork createNeuralNetwork() {
BasicNetwork network = new BasicNetwork();
// input layer
network.addLayer(new BasicLayer(null, true, inputLayerSize));
// hidden layer
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, inputLayerSize / 6));
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, inputLayerSize / 6 / 4));
// output layer
network.addLayer(new BasicLayer(new ActivationSigmoid(), false, outputLayerSize));
network.getStructure().finalizeStructure();
network.reset();
return network;
}
示例2: main
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
/**
* The main method.
* @param args No arguments are used.
*/
public static void main(final String args[]) {
// create a neural network, without using a factory
BasicNetwork network = new BasicNetwork();
network.addLayer(new BasicLayer(null,true,2));
network.addLayer(new BasicLayer(new ActivationSigmoid(),true,3));
network.addLayer(new BasicLayer(new ActivationSigmoid(),false,1));
network.getStructure().finalizeStructure();
network.reset();
// create training data
MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
// train the neural network
final ResilientPropagation train = new ResilientPropagation(network, trainingSet);
int epoch = 1;
do {
train.iteration();
System.out.println("Epoch #" + epoch + " Error:" + train.getError());
epoch++;
} while(train.getError() > 0.01);
train.finishTraining();
// test the neural network
System.out.println("Neural Network Results:");
for(MLDataPair pair: trainingSet ) {
final MLData output = network.compute(pair.getInput());
System.out.println(pair.getInput().getData(0) + "," + pair.getInput().getData(1)
+ ", actual=" + output.getData(0) + ",ideal=" + pair.getIdeal().getData(0));
}
Encog.getInstance().shutdown();
}
示例3: getNetwork
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
private BasicNetwork getNetwork() {
BasicNetwork network = new BasicNetwork();
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, INPUTS.length));
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, 25));
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, OUTPUTS.length));
network.getStructure().finalizeStructure();
network.reset();
return network;
}
示例4: BackPropagationNeuralNet
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
/** Neural Network structure initialization */
public BackPropagationNeuralNet() {
iterations = new ArrayList<>();
errors = new ArrayList<>();
network = new BasicNetwork();
network.addLayer(new BasicLayer(null, true, 4));
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, 10));
network.addLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
network.getStructure().finalizeStructure();
network.reset();
new ConsistentRandomizer(-1, 1, 500).randomize(network);
}
示例5: ResilientPropagationNeuralNet
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
/** Neural Network structure initialization */
public ResilientPropagationNeuralNet() {
iterations = new ArrayList<>();
errors = new ArrayList<>();
network = new BasicNetwork();
network.addLayer(new BasicLayer(null, true, 4));
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, 10));
network.addLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
network.getStructure().finalizeStructure();
network.reset();
new ConsistentRandomizer(-1, 1, 500).randomize(network);
}
示例6: generateNetwork
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
/**
* Generate basic NN network object
*/
public static BasicNetwork generateNetwork(int in, int hidden, int out) {
final BasicNetwork network = new BasicNetwork();
network.addLayer(new BasicLayer(new ActivationLinear(), true, in));
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, hidden));
network.addLayer(new BasicLayer(new ActivationSigmoid(), false, out));
network.getStructure().finalizeStructure();
network.reset();
return network;
}
示例7: initGradient
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
private void initGradient(MLDataSet training, double[] weights) {
BasicNetwork network = NNUtils.generateNetwork(this.inputs, this.hiddens, this.outputs);
// use the weights from master
network.getFlat().setWeights(weights);
FlatNetwork flat = network.getFlat();
// copy Propagation from encog
double[] flatSpot = new double[flat.getActivationFunctions().length];
for(int i = 0; i < flat.getActivationFunctions().length; i++) {
flatSpot[i] = flat.getActivationFunctions()[i] instanceof ActivationSigmoid ? 0.1 : 0.0;
}
this.gradient = new Gradient(flat, training, flatSpot, new LinearErrorFunction());
}
示例8: main
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
/**
* The main method.
* @param args No arguments are used.
*/
public static void main(final String args[]) {
// create a neural network, without using a factory
BasicNetwork network = new BasicNetwork();
network.addLayer(new BasicLayer(null,true,2));
network.addLayer(new BasicLayer(new ActivationSigmoid(),true,3));
network.addLayer(new BasicLayer(new ActivationSigmoid(),false,1));
network.getStructure().finalizeStructure();
network.reset();
// create training data
MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
// train the neural network
final ResilientPropagation train = new ResilientPropagation(network, trainingSet);
int epoch = 1;
do {
train.iteration();
System.out.println("Epoch #" + epoch + " Error:" + train.getError());
epoch++;
} while(train.getError() > 0.01);
train.finishTraining();
// test the neural network
System.out.println("Neural Network Results:");
for(MLDataPair pair: trainingSet ) {
final MLData output = network.compute(pair.getInput());
System.out.println(pair.getInput().getData(0) + "," + pair.getInput().getData(1)
+ ", actual=" + output.getData(0) + ",ideal=" + pair.getIdeal().getData(0));
}
Encog.getInstance().shutdown();
}
示例9: test
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
public static void test(double[][] inputValues, double[][] outputValues)
{
NeuralDataSet trainingSet = new BasicNeuralDataSet(inputValues, outputValues);
BasicNetwork network = new BasicNetwork();
network.addLayer(new BasicLayer(new ActivationSigmoid(), false, 4));
network.addLayer(new BasicLayer(new ActivationSigmoid(), false, 1000));
network.addLayer(new BasicLayer(new ActivationLinear(), false, 1));
network.getStructure().finalizeStructure();
network.reset();
final Train train = new ResilientPropagation(network, trainingSet);
int epoch = 1;
do
{
train.iteration();
System.out.println("Epoch #" + epoch + " Error:" + train.getError());
epoch++;
}
while(epoch < 10000);
System.out.println("Neural Network Results:");
for(MLDataPair pair : trainingSet)
{
final MLData output = network.compute(pair.getInput());
System.out.println(pair.getInput().getData(0) + "," + pair.getInput().getData(1) + ", actual="
+ output.getData(0) + ",ideal=" + pair.getIdeal().getData(0));
}
}
示例10: newNetwork
import org.encog.engine.network.activation.ActivationSigmoid; //导入依赖的package包/类
/**
* Create new artificial neural network.
*
* @param inputSize
* Size of the input layer.
* @param hiddenSize
* Size of the hidden layer.
* @param outputSize
* Size of the output layer.
*
* @return Neural network created object.
*/
public static BasicNetwork newNetwork(int inputSize, int hiddenSize, int outputSize) {
BasicNetwork net = new BasicNetwork();
net.addLayer(new BasicLayer(null, true, inputSize));
net.addLayer(new BasicLayer(new ActivationSigmoid(), true, hiddenSize));
net.addLayer(new BasicLayer(new ActivationSigmoid(), false, outputSize));
net.getStructure().finalizeStructure();
net.reset();
return net;
}