简体   繁体   English

Encog神经网络训练Java太慢

[英]Encog neural network training java too slow

I am training a neural network to classify images and it takes too long to finish one iteration... about five minutes and it is still not done. 我正在训练一个神经网络来对图像进行分类,并且完成一次迭代所需的时间太长了……大约五分钟,但仍然没有完成。 I am using Encog 3.1. 我正在使用Encog 3.1。 Is there something wrong with my code? 我的代码有问题吗?

BasicNetwork network = new BasicNetwork();
        network.addLayer(new BasicLayer(null,true,5625));
        network.addLayer(new BasicLayer(new ActivationSigmoid(),true,(intIdealCount+5625)/2));
        network.addLayer(new BasicLayer(new ActivationSigmoid(),true,intIdealCount));
        network.getStructure().finalizeStructure();

here is my training codes: 这是我的训练代码:

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);

Any response will be appreciated. 任何答复将不胜感激。 Thank you. 谢谢。

Your code seems fine, but training can get arbitrary long depending on your data. 您的代码看起来不错,但是根据您的数据,训练可能会变得任意长。 From the size of your network one can deduce, that you are working with images - now if you have lots of them - even the most efficient implementation will take forever. 从网络的规模可以推断出,您正在使用图像-现在,如果您有很多图像,那么即使最有效的实现也将永远花费。 Encog is quite good piece of code - it by default works on all avaliable cores, but FANN seems to be the fastest library for ANN for now. Encog是一段非常不错的代码-默认情况下,它可以在所有可用内核上运行,但是FANN似乎是目前ANN最快的库。

You have ~5000 input neurons, assuming that you have ~10 output neurons, you have ~2500 hidden ones. 您有〜5000个输入神经元,假设您有〜10个输出神经元,则有〜2500个隐藏神经元。 So your network has (5000+1)*2500 + (2500+1)*10 weights (about 12,500,000). 因此,您的网络具有(5000 + 1)* 2500 +(2500 + 1)* 10的权重(约12,500,000)。 Now, assuming that you have N images in your training set - one epoch requires computation (and update) of 12,500,000 * N values. 现在,假设您的训练集中有N张图像-一个纪元需要计算(和更新)12,500,000 * N个值。 So even if you have just ~200 images it is 2,500,000,000 updates to compute. 因此,即使您只有约200张图像,也要进行2,500,000,000次更新。

There are at least three possible ways: 至少有三种可能的方式:

  • Try the FANN library, which is one of the most efficient ones 尝试使用FANN库,这是效率最高的库之一
  • Reduce dimensionality of your images using for example PCA (and as a result - reduce the size of the network) 使用PCA来减小图像的尺寸(因此-减小网络的大小)
  • Are you sure that you need 2500 hidden nodes? 您确定需要2500个隐藏节点吗? It is quite a lot 很多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM