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


Java MLData.getData方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: move

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


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