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


Java MomentumBackpropagation.addListener方法代码示例

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


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

示例1: doRun

import org.neuroph.nnet.learning.MomentumBackpropagation; //导入方法依赖的package包/类
@Override
public void doRun() {
    try {
        System.out.println("Starting training thread....." + sampleDimension.toString() + " and " + imageLabels.toString());

        HashMap<String, BufferedImage> imagesMap = new HashMap<String, BufferedImage>();
        for (File file : srcDirectory.listFiles()) {
            imageLabels.add(FilenameUtils.removeExtension(file.getName()));
            if (sampleDimension.getWidth() > 0 && sampleDimension.getHeight() > 0) {
                Double w = sampleDimension.getWidth();
                Double h = sampleDimension.getHeight();
                imagesMap.put(file.getName(), ImageUtilities.resizeImage(ImageUtilities.loadImage(file), w.intValue(), h.intValue()));
            }
        }
        Map<String, FractionRgbData> imageRgbData = ImageUtilities.getFractionRgbDataForImages(imagesMap);
        DataSet learningData = ImageRecognitionHelper.createRGBTrainingSet(imageLabels, imageRgbData);

        nnet = NeuralNetwork.load(new FileInputStream(nnFile)); //Load NNetwork
        MomentumBackpropagation mBackpropagation = (MomentumBackpropagation) nnet.getLearningRule();
        mBackpropagation.setLearningRate(learningRate);
        mBackpropagation.setMaxError(maxError);
        mBackpropagation.setMomentum(momentum);

        System.out.println("Network Information\nLabel = " + nnet.getLabel()
                + "\n Input Neurons = " + nnet.getInputsCount()
                + "\n Number of layers = " + nnet.getLayersCount()
        );

        mBackpropagation.addListener(this);
        System.out.println("Starting training......");
        nnet.learn(learningData, mBackpropagation);
        //Training Completed
        listener.batchImageTrainingCompleted();
    } catch (FileNotFoundException ex) {
        System.out.println(ex.getMessage() + "\n" + ex.getLocalizedMessage());
    }

}
 
开发者ID:afsalashyana,项目名称:FakeImageDetection,代码行数:39,代码来源:BatchImageTrainer.java

示例2: startLearning

import org.neuroph.nnet.learning.MomentumBackpropagation; //导入方法依赖的package包/类
public void startLearning() {
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            console.addLog("Loading test set");
            testSet = loader.loadDataSet(testSetPath);
            console.addLog("Test set loaded");

            console.addLog("Loading training set");
            trainingSet = loader.loadDataSet(trainingSetPath);
            console.addLog("Training set loaded. Input size: " + trainingSet.getInputSize() +
                    " Output size: " + trainingSet.getOutputSize());

            nnet = new MultiLayerPerceptron(TransferFunctionType.SIGMOID,
                    trainingSet.getInputSize(), 86, 86, trainingSet.getOutputSize());

            MomentumBackpropagation backPropagation = new MomentumBackpropagation();
            backPropagation.setLearningRate(learningRate);
            backPropagation.setMomentum(momentum);

            LearningTestSetEvaluator evaluator =
                    new LearningTestSetEvaluator(nnetName, testSet, trainingSet, console);
            backPropagation.addListener(evaluator);
            backPropagation.addListener(new LearningEventListener() {
                @Override
                public void handleLearningEvent(LearningEvent event) {
                    if (event.getEventType() == LearningEvent.Type.LEARNING_STOPPED) {
                        listeners.forEach((listener) -> listener.learningStopped(LearningNetTask.this));
                    }
                }
            });
            nnet.setLearningRule(backPropagation);
            console.addLog("Started neural net learning with momentum: "
                    + momentum + ", learning rate: " + learningRate);
            nnet.learnInNewThread(trainingSet);
        }
    });
    t1.start();
}
 
开发者ID:fgulan,项目名称:final-thesis,代码行数:39,代码来源:LearningNetTask.java

示例3: learnNeuralNet

import org.neuroph.nnet.learning.MomentumBackpropagation; //导入方法依赖的package包/类
private static void learnNeuralNet(DataSet trainingSet, DataSet testSet) {
    TestSetEvaluator testEvaluator = new TestSetEvaluator(NNET_NAME, testSet, trainingSet);
    MultiLayerPerceptron nnet = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, INPUT_LAYER, 86, 86, OUTPUT_LAYER);

    MomentumBackpropagation bp = new MomentumBackpropagation();
    bp.setLearningRate(LEARINING_RATE);
    bp.setMomentum(MOMENTUM);
    bp.addListener(testEvaluator);

    nnet.setLearningRule(bp);
    nnet.learn(trainingSet);
    nnet.save(NNET_NAME + "last");
}
 
开发者ID:fgulan,项目名称:final-thesis,代码行数:14,代码来源:OneToOneHVTest.java

示例4: learnNeuralNet

import org.neuroph.nnet.learning.MomentumBackpropagation; //导入方法依赖的package包/类
private static void learnNeuralNet(DataSet trainingSet, DataSet testSet) {
    TestSetEvaluator testEvaluator = new TestSetEvaluator(NNET_NAME, testSet, trainingSet);
    MultiLayerPerceptron nnet = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, INPUT_LAYER, 140, OUTPUT_LAYER);

    MomentumBackpropagation bp = new MomentumBackpropagation();
    bp.setLearningRate(LEARINING_RATE);
    bp.setMomentum(MOMENTUM);
    bp.addListener(testEvaluator);

    nnet.setLearningRule(bp);
    nnet.learn(trainingSet);
    nnet.save(NNET_NAME + "last");
}
 
开发者ID:fgulan,项目名称:final-thesis,代码行数:14,代码来源:OneToOneNonUniqueDiagonalTest.java

示例5: learnNeuralNet

import org.neuroph.nnet.learning.MomentumBackpropagation; //导入方法依赖的package包/类
private static void learnNeuralNet(DataSet trainingSet, DataSet testSet) {
    TestSetEvaluator testEvaluator = new TestSetEvaluator(NNET_NAME, testSet, trainingSet);
    MultiLayerPerceptron nnet = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, INPUT_LAYER, 76, 76, OUTPUT_LAYER);

    MomentumBackpropagation bp = new MomentumBackpropagation();
    bp.setLearningRate(LEARINING_RATE);
    bp.setMomentum(MOMENTUM);
    bp.addListener(testEvaluator);

    nnet.setLearningRule(bp);
    nnet.learn(trainingSet);
    nnet.save(NNET_NAME + "last");
}
 
开发者ID:fgulan,项目名称:final-thesis,代码行数:14,代码来源:OneToOneDiagonalTest.java

示例6: doRun

import org.neuroph.nnet.learning.MomentumBackpropagation; //导入方法依赖的package包/类
@Override
public void doRun() {
    HashMap<String, BufferedImage> imagesMap = new HashMap<String, BufferedImage>();
    String fileName = "";
    if (!isReal) {
        fileName = "real";
    } else {
        fileName = "faked";
    }

    System.out.println("Teaching as " + fileName);
    imagesMap.put(fileName, image);
    Map<String, FractionRgbData> imageRgbData = ImageUtilities.getFractionRgbDataForImages(imagesMap);
    DataSet learningData = ImageRecognitionHelper.createRGBTrainingSet(labels, imageRgbData);
    MomentumBackpropagation mBackpropagation = (MomentumBackpropagation) nnet.getLearningRule();
    mBackpropagation.setLearningRate(learningRate);
    mBackpropagation.setMaxError(maxError);
    mBackpropagation.setMomentum(momentum);

    System.out.println("Network Information\nLabel = " + nnet.getLabel()
            + "\n Input Neurons = " + nnet.getInputsCount()
            + "\n Number of layers = " + nnet.getLayersCount()
    );

    mBackpropagation.addListener(this);
    System.out.println("Starting training......");
    nnet.learn(learningData, mBackpropagation);

    //Mark nnet as dirty. Write on close
    isDirty = true;
}
 
开发者ID:afsalashyana,项目名称:FakeImageDetection,代码行数:32,代码来源:SingleImageTrainer.java


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