当前位置: 首页>>代码示例>>Java>>正文


Java MLData类代码示例

本文整理汇总了Java中org.encog.ml.data.MLData的典型用法代码示例。如果您正苦于以下问题:Java MLData类的具体用法?Java MLData怎么用?Java MLData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MLData类属于org.encog.ml.data包,在下文中一共展示了MLData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processData

import org.encog.ml.data.MLData; //导入依赖的package包/类
@Override
    public boolean processData(double[] input) {
//        Log.d(Constants.LOG_TAG, "Processing data");
        String[] inputString = new String[input.length];
        for(int i=0;i<input.length;i++){
            inputString[i] = Double.toString(input[i]);
        }
        MLData inputData = helper.allocateInputVector();

        helper.normalizeInputVector(inputString,inputData.getData(),false);
//        Log.d(Constants.TAG, "About to compute");
        MLData outputData = method.compute(inputData);
//        Log.d(Constants.LOG_TAG, "Computing finished");
        final String output = helper.denormalizeOutputVectorToString(outputData)[0];
//        Log.d(Constants.TAG, "Input: " + Arrays.toString(inputString));
//        Log.d(Constants.TAG, "Output: " + output);
        return output.equals("1");
    }
 
开发者ID:google,项目名称:watchpresenter,代码行数:19,代码来源:EncogDataProcessor.java

示例2: add

import org.encog.ml.data.MLData; //导入依赖的package包/类
@Override
public void add(MLData data) {
    long currentSize = SizeEstimator.estimate(data);
    if(this.byteSize + currentSize < this.maxByteSize) {
        this.byteSize += currentSize;
        this.memoryCount += 1l;
        this.memoryDataSet.add(data);
    } else {
        if(this.diskDataSet == null) {
            this.diskDataSet = new BufferedMLDataSet(new File(this.fileName));
            ((BufferedMLDataSet) this.diskDataSet).beginLoad(this.inputCount, this.outputCount);
        }
        this.byteSize += currentSize;
        this.diskCount += 1l;
        this.diskDataSet.add(data);
    }
}
 
开发者ID:ShifuML,项目名称:guagua,代码行数:18,代码来源:MemoryDiskMLDataSet.java

示例3: getError

import org.encog.ml.data.MLData; //导入依赖的package包/类
private double[] getError(NeuralDataSet trainingSet, BasicNetwork network){
	double total = 0.0;
	double size = 0;
	double RSS = 0.0;
	double Ry = 0.0;
	for (MLDataPair pair : trainingSet) {

		final MLData output = network.compute(pair.getInput());
		if (Double.isNaN(output.getData(0))) {
			throw new RuntimeException("There is a NaN! may be something wrong with the data conversion");
		}
		double result = (Double.isNaN(output.getData(0)))? pair.getIdeal().getData(0) : output.getData(0); 
		//System.out.print("Result ********** " +result+"\n");
		total += calculateEachMAPE(pair.getIdeal().getData(0),
				result);

		double difference = pair.getIdeal().getData(0) - result;
		RSS += Math.pow(difference, 2);
		Ry += Math.pow(pair.getIdeal().getData(0) - meanIdeal, 2);
		size++;
	}

	return new double[]{Ry==0?RSS:RSS/Ry, 
			total/size};
}
 
开发者ID:taochen,项目名称:ssascaling,代码行数:26,代码来源:EncogFeedForwardNeuralNetwork.java

示例4: getOutput

import org.encog.ml.data.MLData; //导入依赖的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

示例5: enquireNeuralNetwork

import org.encog.ml.data.MLData; //导入依赖的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

示例6: doPredict

import org.encog.ml.data.MLData; //导入依赖的package包/类
@Override
protected Object doPredict(String[] line) {
    NormalizationHelper helper = model.getDataset().getNormHelper();
    MLData input = helper.allocateInputVector();
    helper.normalizeInputVector(line, input.getData(), false);
    MLData output = method.compute(input);
    DataType outputType = types.get(this.output);
    switch (outputType) {
        case _float : return output.getData(0);
        case _class: return helper.denormalizeOutputVectorToString(output)[0];
        default: throw new IllegalArgumentException("Output type not yet supported "+outputType);
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-ml-procedures,代码行数:14,代码来源:EncogMLModel.java

示例7: main

import org.encog.ml.data.MLData; //导入依赖的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();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-ml-procedures,代码行数:40,代码来源:XORHelloWorld.java

示例8: autonomousMoveDirection

import org.encog.ml.data.MLData; //导入依赖的package包/类
public Directions autonomousMoveDirection() {
    updateVision();
    MLData result = this.brain.compute(this.vision);

    double winningOutput = Double.NEGATIVE_INFINITY;
    Directions winningDirection = Directions.UP;

    for (int i = 0; i < result.size(); i++) {
        // determine direction
        Directions direction = directionFromIndex(i);

        if(getMap().get(Position.getInDirection(this.getPosition(), direction)).isPresent()) {
            if(getMap().get(Position.getInDirection(this.getPosition(), direction)).get().getType().equals(TypeObject.Obstacle)) {
                continue;
            }
        }

        // evaluate if this is a "winning" direction
        double thisOutput = result.getData(i);
        if (thisOutput > winningOutput) {
            winningOutput = thisOutput;
            winningDirection = direction;
        }
    }

    return winningDirection;
}
 
开发者ID:AdrianBZG,项目名称:IEMLS,代码行数:28,代码来源:NeuralAgent.java

示例9: updatePredictions

import org.encog.ml.data.MLData; //导入依赖的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

示例10: solve

import org.encog.ml.data.MLData; //导入依赖的package包/类
@Override /** {@inheritDoc} */
public double[] solve(final double[][] inputs) {
  double[] results = new double[inputs.length];
  trainingSet = new BasicMLDataSet(inputs, null);
  int i = 0;
  for (MLDataPair pair : trainingSet) {
    final MLData output = network.compute(pair.getInput());
    results[i++] = output.getData(0);
  }
  Encog.getInstance().shutdown();
  return results;
}
 
开发者ID:Saka7,项目名称:Layer-Classifier,代码行数:13,代码来源:BackPropagationNeuralNet.java

示例11: solve

import org.encog.ml.data.MLData; //导入依赖的package包/类
/** {@inheritDoc} */
public double[] solve(final double[][] inputs) {
  double[] results = new double[inputs.length];
  trainingSet = new BasicMLDataSet(inputs, null);
  int i = 0;
  for (MLDataPair pair : trainingSet) {
    final MLData output = network.compute(pair.getInput());
    results[i++] = output.getData(0);
  }
  Encog.getInstance().shutdown();
  return results;
}
 
开发者ID:Saka7,项目名称:Layer-Classifier,代码行数:13,代码来源:ResilientPropagationNeuralNet.java

示例12: main

import org.encog.ml.data.MLData; //导入依赖的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();
}
 
开发者ID:encog,项目名称:encog-sample-java,代码行数:40,代码来源:HelloWorld.java

示例13: calculateError

import org.encog.ml.data.MLData; //导入依赖的package包/类
private boolean calculateError (NeuralDataSet trainingSet){
	logger.debug("Neural Network Results:");
	double RSS = 0.0;
	double Ry = 0.0;
	double SMAPE = 0.0;
	double MAPE = 0.0;
	int no = 0;
	double all = 0.0;
	double sum = 0;
	sample = ((BasicNeuralDataSet)trainingSet).getRecordCount();
	
	for(MLDataPair pair: trainingSet ) {
	   final MLData output = bestEverNetwork.compute(pair.getInput());
	   double result = (Double.NaN == output.getData(0))? pair.getIdeal().getData(0) : output.getData(0); 
	   sum += result;
	   double difference = pair.getIdeal().getData(0) - result;
	   RSS += Math.pow(difference, 2);
	   all += Math.abs(difference);
	 
		   
	   SMAPE += calculateEachSMAPE(pair.getIdeal().getData(0), result);

	   MAPE += calculateEachMAPE(pair.getIdeal().getData(0), result);
	   Ry += Math.pow(pair.getIdeal().getData(0) - meanIdeal, 2);
	   logger.debug("Actual=" + output.getData(0) + ", Ideal=" + pair.getIdeal().getData(0));
	   no++;
	}
	this.RSS = RSS;
	//System.out.print("Ry: " + Ry + "\n");
	this.R = 1-(Ry==0? RSS : RSS/Ry);
	this.SMAPE = SMAPE/no;
	this.MAPE = MAPE/no;
	//System.out.print(no+"MSE: " + bestEverNetwork.calculateError(trainingSet) + "\n");
	return sum != 0;
}
 
开发者ID:taochen,项目名称:ssascaling,代码行数:36,代码来源:EncogFeedForwardNeuralNetwork.java

示例14: test

import org.encog.ml.data.MLData; //导入依赖的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));

    }
}
 
开发者ID:santjuan,项目名称:dailyBot,代码行数:28,代码来源:NeuralNetworkAnalysis.java

示例15: getOutput2

import org.encog.ml.data.MLData; //导入依赖的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


注:本文中的org.encog.ml.data.MLData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。