當前位置: 首頁>>代碼示例>>Java>>正文


Java MLTrain類代碼示例

本文整理匯總了Java中org.encog.ml.train.MLTrain的典型用法代碼示例。如果您正苦於以下問題:Java MLTrain類的具體用法?Java MLTrain怎麽用?Java MLTrain使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MLTrain類屬於org.encog.ml.train包,在下文中一共展示了MLTrain類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: withNEAT

import org.encog.ml.train.MLTrain; //導入依賴的package包/類
private MLRegression withNEAT() {
	final NEATPopulation pop = new NEATPopulation(400, 10, 1000);
	final CalculateScore score = new TrainingSetScore(this.training);
	// train the neural network
	final ActivationStep step = new ActivationStep();
	step.setCenter(0.5);
	pop.setOutputActivationFunction(step);
	final MLTrain train = new NEATTraining(score, pop);
	EncogUtility.trainToError(train, 0.01515);
	return (MLRegression) train.getMethod();
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:12,代碼來源:HandWritingNeuralNetENCOG.java

示例2: withCPN

import org.encog.ml.train.MLTrain; //導入依賴的package包/類
private MLRegression withCPN() {
	final CPN result = new CPN(400, 1000, 10, 1);
	final MLTrain trainInstar = new TrainInstar(result, training, 0.1, false);
	EncogUtility.trainToError(trainInstar, 0.01515);
	final MLTrain trainOutstar = new TrainOutstar(result, training, 0.1);
	EncogUtility.trainToError(trainOutstar, 0.01515);
	return result;
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:9,代碼來源:HandWritingNeuralNetENCOG.java

示例3: withResilieant

import org.encog.ml.train.MLTrain; //導入依賴的package包/類
private MLRegression withResilieant() {
	final MLTrain train = new ResilientPropagation(EncogUtility.simpleFeedForward(400, 100, 0, 10, false),
			this.training);
	EncogUtility.trainToError(train, 0.01515);
	return (MLRegression) train.getMethod();
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:7,代碼來源:HandWritingNeuralNetENCOG.java

示例4: withSVM

import org.encog.ml.train.MLTrain; //導入依賴的package包/類
private MLRegression withSVM() {
	final MLTrain train = new SVMTrain(new SVM(400, true), this.training);
	EncogUtility.trainToError(train, 0.01515);
	return (MLRegression) train.getMethod();
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:6,代碼來源:HandWritingNeuralNetENCOG.java

示例5: train

import org.encog.ml.train.MLTrain; //導入依賴的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


注:本文中的org.encog.ml.train.MLTrain類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。