本文整理汇总了Java中org.encog.ml.data.basic.BasicMLData类的典型用法代码示例。如果您正苦于以下问题:Java BasicMLData类的具体用法?Java BasicMLData怎么用?Java BasicMLData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicMLData类属于org.encog.ml.data.basic包,在下文中一共展示了BasicMLData类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOutput
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
@Override
public MLData getOutput() {
//waitTillStabilized();
final MLData output = new BasicMLData(nodes.length);
NormalizedField norm = new NormalizedField(NormalizationAction.Normalize,
null,IFSpikingNeuron.THRESHOLD,0,1,0);
//now stabilized
for (int i=0; i<nodes.length; i++){
//output.setData(i,norm.normalize(nodes[i].getMembranePotential()));
output.setData(i,nodes[i].getMembranePotential());
}
return output;
}
开发者ID:wil3,项目名称:lacus,代码行数:19,代码来源:SpikingOutput.java
示例2: enquireNeuralNetwork
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
public int enquireNeuralNetwork(final BasicNetwork neuralNetwork, DataPoint dataPoint) {
MLData input = new BasicMLData(2);
input.setData(0, dataPoint.getX());
input.setData(1, dataPoint.getY());
MLData output = neuralNetwork.compute(input);
// Check to see which button has the highest output
double buttons[] = output.getData();
int buttonIndex = -1;
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] > 0 && (buttonIndex == -1 || buttons[i] > buttons[buttonIndex])) {
buttonIndex = i;
}
}
return buttonIndex;
}
开发者ID:bsmulders,项目名称:StepManiaSolver,代码行数:18,代码来源:NeuralNetworkBasher.java
示例3: updatePredictions
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
@Override
public void updatePredictions(SensorModel model) {
RealVector vec = sensorsToVector(model, mNorm);
MLData prediction = mNN.compute(new BasicMLData(vec.toArray()));
mPredictions = new ArrayRealVector(prediction.getData());
mNorm.denormalizeOutput(mPredictions, 0, 1);
}
开发者ID:Ignotus,项目名称:torcsnet,代码行数:9,代码来源:EvolvedController.java
示例4: getOutput2
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
/**
*
* @return An array containing all of the times in which spikes occured in discrete time
*/
public MLData getOutput2() {
final MLData output = new BasicMLData(nodes.length);
logger.debug("Output Spike Trains:");
for (int i=0; i<nodes.length; i++){
double [] spikes = nodes[i].getFiringTimes();
logger.info(nodes[i].toString() + " = " + Arrays.toString(spikes));
}
return output;
}
开发者ID:wil3,项目名称:lacus,代码行数:14,代码来源:SpikingOutput.java
示例5: setData
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
public void setData(double[][] p) {
for(int i = 0 ; i < p.length; i ++){
double[] input = p[i];
MLDataPair pair = new BasicMLDataPair(new BasicMLData(input), new BasicMLData(input));
dataset.add(pair);
}
}
开发者ID:m4rkl1u,项目名称:AutoEncoder,代码行数:10,代码来源:AutoEncoder.java
示例6: move
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int move(Board board, int player) throws NoValidMoveException {
super.move(board, player);
int[][] state = board.getState();
/*
* State matrix should be with valid dimensions.
*/
int size = 0;
for (int i = 0; i < state.length; i++) {
size += state[i].length;
}
/*
* Encode in the input the player who is playing.
*/
size += NUMBER_OF_PLAYERS;
/*
* Check ANN input layer size.
*/
if (size != net.getInputCount()) {
throw new NoValidMoveException();
}
/*
* Scale input in the range of [0.0-1.0].
*/
double input[] = new double[size];
for (int i = 0, k = 0; i < state.length; i++) {
for (int j = 0; j < state[i].length; j++, k++) {
input[k] = (state[i][j] - min) / (max - min);
}
}
/*
* Mark the player who is playing.
*/
for (int i = input.length - NUMBER_OF_PLAYERS, p = 1; i < input.length; i++, p++) {
if (player == p) {
input[i] = 1;
} else {
input[i] = 0;
}
}
/*
* Feed the ANN input. ANN calculation.
*/
MLData data = new BasicMLData(input);
data = net.compute(data);
/*
* Obtain the ANN output.
*/
double output[] = data.getData();
/*
* Suggest move.
*/
int index = 0;
for (int i = 0; i < output.length; i++) {
if (output[i] > output[index]) {
index = i;
}
}
return index;
}
开发者ID:VelbazhdSoftwareLLC,项目名称:Complica4,代码行数:73,代码来源:NeuralNetworkArtificialIntelligence.java
示例7: load
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
@Override
public void load(GuaguaWritableAdapter<LongWritable> currentKey, GuaguaWritableAdapter<Text> currentValue,
WorkerContext<NNParams, NNParams> workerContext) {
++this.count;
if((this.count) % 100000 == 0) {
LOG.info("Read {} records.", this.count);
}
// use guava to iterate only once
double[] ideal = new double[1];
int inputNodes = NumberFormatUtils.getInt(
workerContext.getProps().getProperty(NNConstants.GUAGUA_NN_INPUT_NODES),
NNConstants.GUAGUA_NN_DEFAULT_INPUT_NODES);
double[] inputs = new double[inputNodes];
int i = 0;
for(String input: Splitter.on(NNConstants.NN_DEFAULT_COLUMN_SEPARATOR).split(
currentValue.getWritable().toString())) {
if(i == 0) {
ideal[i++] = NumberFormatUtils.getDouble(input, 0.0d);
} else {
int inputsIndex = (i++) - 1;
if(inputsIndex >= inputNodes) {
break;
}
inputs[inputsIndex] = NumberFormatUtils.getDouble(input, 0.0d);
}
}
if(i < (inputNodes + 1)) {
throw new GuaguaRuntimeException(String.format(
"Not enough data columns, input nodes setting:%s, data column:%s", inputNodes, i));
}
int scale = NumberFormatUtils.getInt(workerContext.getProps().getProperty(NNConstants.NN_RECORD_SCALE), 1);
for(int j = 0; j < scale; j++) {
double[] tmpInputs = j == 0 ? inputs : new double[inputs.length];
double[] tmpIdeal = j == 0 ? ideal : new double[ideal.length];
System.arraycopy(inputs, 0, tmpInputs, 0, inputs.length);
MLDataPair pair = new BasicMLDataPair(new BasicMLData(tmpInputs), new BasicMLData(tmpIdeal));
double r = Math.random();
if(r >= 0.5d) {
this.trainingData.add(pair);
} else {
this.testingData.add(pair);
}
}
}
开发者ID:ShifuML,项目名称:guagua,代码行数:49,代码来源:NNWorker.java
示例8: train
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
public void train(final ArrayList<DataPoint> dataHistory) {
if (isTraining()) {
throw new IllegalStateException();
}
setTrainerThread(new Thread() {
public void run() {
// Clean and normalize the data history
ArrayList<DataPoint> cleanedDataHistory = cleanDataHistory(dataHistory);
ArrayList<DataPoint> normalizedDataHistory = normalizeDataHistory(cleanedDataHistory);
// Create a new neural network and data set
BasicNetwork neuralNetwork = EncogUtility.simpleFeedForward(2, getHiddenLayerNeurons(0),
getHiddenLayerNeurons(1), 5, true);
MLDataSet dataSet = new BasicMLDataSet();
// Add all points of the data history to the data set
for (DataPoint dataPoint : normalizedDataHistory) {
MLData input = new BasicMLData(2);
input.setData(0, dataPoint.getX());
input.setData(1, dataPoint.getY());
// If getButton() is 0, the output will be 0, 0, 0, 0
// If getButton() is 2, the output will be 0, 1, 0, 0
// If getButton() is 4, the output will be 0, 0, 0, 1
MLData ideal = new BasicMLData(5);
for (int i = 0; i <= 4; i++) {
ideal.setData(i, (dataPoint.getButton() == i) ? 1 : 0);
}
MLDataPair pair = new BasicMLDataPair(input, ideal);
dataSet.add(pair);
}
// Create a training method
MLTrain trainingMethod = new ResilientPropagation((ContainsFlat) neuralNetwork, dataSet);
long startTime = System.currentTimeMillis();
int timeLeft = getMaxTrainingTime();
int iteration = 0;
// Train the network using multiple iterations on the training method
do {
trainingMethod.iteration();
timeLeft = (int) ((startTime + getMaxTrainingTime()) - System.currentTimeMillis());
iteration++;
sendNeuralNetworkIteration(iteration, trainingMethod.getError(), timeLeft);
} while (trainingMethod.getError() > getMaxTrainingError() && timeLeft > 0
&& !trainingMethod.isTrainingDone());
trainingMethod.finishTraining();
// Return the neural network to all listeners
sendNeuralNetworkTrainerResult(neuralNetwork);
}
});
getTrainerThread().start();
}
开发者ID:bsmulders,项目名称:StepManiaSolver,代码行数:58,代码来源:NeuralNetworkTrainer.java
示例9: addData
import org.encog.ml.data.basic.BasicMLData; //导入依赖的package包/类
public void addData(double[] p ){
MLDataPair pair = new BasicMLDataPair(new BasicMLData(p), new BasicMLData(p));
dataset.add(pair);
}
开发者ID:m4rkl1u,项目名称:AutoEncoder,代码行数:5,代码来源:AutoEncoder.java
注:本文中的org.encog.ml.data.basic.BasicMLData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论