📄 rmsecondition.java
字号:
/* * RmseCondition.java * * Created on August 27, 2004, 1:50 PM */package org.joone.dte.control;import java.util.ArrayList;import org.joone.dte.StopCondition;import org.joone.dte.TaskDescriptor;import org.joone.dte.TaskListFactory;/** * This condition verifies if the actual population has reached the * maxRmse specified as parameter. * if validation = true, the validation rmse is checked, otherwise the * control is done on the training rmse (the default). * if mean = true, the condition is verified only if the average rmse * of the population is below maxRmse, otherwise the control is done * on the fittest neural network. * As this class extends the MaxCyclesCondition, also a max number of * iterations can be specified, in order to stop the DTE if the maxRmse * is not reached after that number of cycles. * * @author P.Marrone */public class RmseCondition extends MaxCyclesCondition { private double maxRmse; private boolean mean; private boolean validation; /** Creates a new instance of RmseCondition */ public RmseCondition() { } public boolean done(TaskListFactory tasks, int currentCycle) { double minRmse, avgRmse, rmse; // Checks if the max # of iterations has been reached if (getMaxCycles() > 0) { if (super.done(tasks, currentCycle)) return true; } if (tasks == null) return true; tasks.initialize(); if (tasks.getTaskList() == null) return true; ArrayList tsk = tasks.getTaskList().getTasks(); if ((tsk == null) || (tsk.size() == 0)) return true; minRmse = 999; avgRmse = 0; for (int i=0; i < tsk.size(); ++i) { TaskDescriptor td = (TaskDescriptor)tsk.get(i); if (!validation) rmse = td.getTrainingRmse(); else rmse = td.getValidationRmse(); avgRmse += rmse; if (rmse < minRmse) minRmse = rmse; } avgRmse = avgRmse / tsk.size(); if (mean) return (avgRmse <= maxRmse); else return (minRmse <= maxRmse); } /** * Getter for property maxRmse. * @return Value of property maxRmse. */ public double getMaxRmse() { return maxRmse; } /** * Setter for property maxRmse. * @param maxRmse New value of property maxRmse. */ public void setMaxRmse(double maxRmse) { this.maxRmse = maxRmse; } /** * Getter for property mean. * @return Value of property mean. */ public boolean isMean() { return mean; } /** * Setter for property mean. * @param mean New value of property mean. */ public void setMean(boolean mean) { this.mean = mean; } /** * Getter for property validation. * @return Value of property validation. */ public boolean isValidation() { return validation; } /** * Setter for property validation. * @param validation New value of property validation. */ public void setValidation(boolean validation) { this.validation = validation; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -