neurons2 = new double[NEURONS]; randomizeFValues(neurons2);
neurons3 = new double[NEURONS]; randomizeFValues(neurons3);
neurons4 = new double[NEURONS]; randomizeFValues(neurons4);
neurons5 = new double[NEURONS]; randomizeFValues(neurons5);
neurons6 = new double[NEURONS]; randomizeFValues(neurons6); weight1 = new double[WEIGHT]; weight2 = new double[WEIGHT]; weight3 = new double[WEIGHT]; weight4 = new double[WEIGHT]; weight5 = new double[WEIGHT]; weight6 = new double[WEIGHT];
randomizeWeight();
deltaWeight1= new double[times*248] ; deltaWeight2= new double[times*248] ; deltaWeight3= new double[times*248] ; deltaWeight4= new double[times*248] ; deltaWeight5= new double[times*248] ; deltaWeight6= new double[times*248] ;用的时候就是通过计算,算出新的值,然后改变数组元素的值。如 for(int j=0; j<735; j++) { weight1[0]+=deltaW1; }
private int NEURONS = 101;
private int WEIGHT = 735;
static int times =50; static double deltaWeight1[];
static double deltaWeight2[];
static double deltaWeight3[];
static double deltaWeight4[];
static double deltaWeight5[];
static double deltaWeight6[];
static double neurons1[];
static double neurons2[];
static double neurons3[];
static double neurons4[];
static double neurons5[];
static double neurons6[];
static double weight1[];
static double weight2[];
static double weight3[];
static double weight4[];
static double weight5[];
static double weight6[];初始化 neurons1 = new double[NEURONS];
randomizeFValues(neurons1);
neurons2 = new double[NEURONS];
randomizeFValues(neurons2);
neurons3 = new double[NEURONS];
randomizeFValues(neurons3);
neurons4 = new double[NEURONS];
randomizeFValues(neurons4);
neurons5 = new double[NEURONS];
randomizeFValues(neurons5);
neurons6 = new double[NEURONS];
randomizeFValues(neurons6); weight1 = new double[WEIGHT];
weight2 = new double[WEIGHT];
weight3 = new double[WEIGHT];
weight4 = new double[WEIGHT];
weight5 = new double[WEIGHT];
weight6 = new double[WEIGHT];
randomizeWeight();
deltaWeight1= new double[times*248] ;
deltaWeight2= new double[times*248] ;
deltaWeight3= new double[times*248] ;
deltaWeight4= new double[times*248] ;
deltaWeight5= new double[times*248] ;
deltaWeight6= new double[times*248] ;用的时候就是通过计算,算出新的值,然后改变数组元素的值。如
for(int j=0; j<735; j++)
{
weight1[0]+=deltaW1;
}
for(int j=0; j<735; j++)
{
weight2[0]+=deltaW2;
}
......neuron1[i]+=deltaF1;......对象怎样回收阿,我的确没写回收语句,恳请指教啦,急。
static double deltaWeight1[];
static double deltaWeight2[];
static double deltaWeight3[];
static double deltaWeight4[];
static double deltaWeight5[];
static double deltaWeight6[];
static double neurons1[];
static double neurons2[];
static double neurons3[];
static double neurons4[];
static double neurons5[];
static double neurons6[];
static double weight1[];
static double weight2[];
static double weight3[];
static double weight4[];
static double weight5[];
static double weight6[];
presentPattern
这个化,用static成员也不错。但是要注意这些static成员一旦生成后除非你显示的置空,要不然只要有任何引用在你的包含有presentPattern(int)方法的类上面,它是一直不回释放的;而且用static成员会相互影响的哦。像这种问题,我个人觉得主要应该在算法上进行优化。当然调大内存也是一个简洁的解决之道。
运行期调整jvm参数应该是能在一定的范围内有效过的。
-XX:MaxPermSize=64m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:SurvivorRatio=8 -Xms512m -Xmx512m