📄 backpropagationpanel.java
字号:
/* * $RCSfile: BackPropagationPanel.java,v $ * $Revision: 1.6 $ * $Date: 2005/05/10 01:37:52 $ * * NeuralNetworkToolkit * Copyright (C) 2004 Universidade de Brasília * * This file is part of NeuralNetworkToolkit. * * NeuralNetworkToolkit is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * NeuralNetworkToolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NeuralNetworkToolkit; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 - USA. */package neuralnetworktoolkit.gui.options.method;import java.awt.BorderLayout;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ResourceBundle;import javax.swing.ButtonGroup;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JSpinner;import javax.swing.SpinnerNumberModel;import javax.swing.border.TitledBorder;import neuralnetworktoolkit.methods.TrainingParameters;import neuralnetworktoolkit.methods.gradientbased.backpropagation.BackPropagationModel;import neuralnetworktoolkit.methods.gradientbased.backpropagation.BackPropagationParameters;/** * * * @version $Revision: 1.6 $ - $Date: 2005/05/10 01:37:52 $ * * @author <a href="mailto:rodbra@pop.com.br">Rodrigo C. M. Coimbra</a> * @author <a href="mailto:hugoiver@yahoo.com.br">Hugo Iver V. Gonçalves</a> */public class BackPropagationPanel extends TrainingMethodPanel { private static final int LEARNING_RATE_ENABLED = 0; private static final int ALL_ENABLED = 1; private static final int MULTIPLIER_DISABLED = 2; private JLabel maxEpochsLabel; private JLabel errorLabel; private JLabel lrMultiplierLabel; private JLabel learningRateLabel; private JLabel alphaLabel; private JRadioButton batchRadio; private JRadioButton batchAdaptiveLearningRateRadio; private JRadioButton batchMomentumRadio; private JRadioButton onLineRadio; private JRadioButton onLineAdaptiveLearningRadio; private JRadioButton onLineMomentumRadio; private ButtonGroup backPropagationVariationGroup; private JSpinner maxEpochsSpinner; private JSpinner errorSpinner; private JSpinner lrMultiplierSpinner; private JSpinner learningRateSpinner; private JSpinner alphaSpinner; private SpinnerNumberModel maxEpochsSpinnerModel; private SpinnerNumberModel errorSpinnerModel; private SpinnerNumberModel lrMultiplierSpinnerModel; private SpinnerNumberModel learningRateSpinnerModel; private SpinnerNumberModel alphaSpinnerModel; private JPanel maxEpochsPanel; private JPanel errorPanel; private JPanel lrMultiplierPanel; private JPanel learningRatePanel; private JPanel alphaPanel; private JPanel backPropagationVariationPanel; private JPanel stopConditionPanel; private JPanel backPropagationParametersPanel; private Insets borderInsets; private Insets borderInsets2; private String[] methods = {"gradientbased.backpropagation.BatchBackPropagation", "gradientbased.backpropagation.BatchAdaptiveLearningRateMomentumBackPropagation", "gradientbased.backpropagation.BatchMomentumBackPropagation", "gradientbased.backpropagation.OnLineBackPropagation", "gradientbased.backpropagation.OnLineAdaptiveLearningRateMomentumBackPropagation", "gradientbased.backpropagation.OnLineMomentumBackPropagation"}; private ResourceBundle resource; /** * * */ public BackPropagationPanel() { resource = ResourceBundle .getBundle("neuralnetworktoolkit.gui.options.method.resources.BackPropagationPanelResource"); borderInsets = new Insets(5, 5, 5, 5); borderInsets2 = new Insets(2, 2, 2, 2); batchRadio = new JRadioButton(resource.getString("batch")); batchRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setBackpropagationParametersEnabled(LEARNING_RATE_ENABLED); } }); batchAdaptiveLearningRateRadio = new JRadioButton(resource .getString("batchAdaptiveLearningRate")); batchAdaptiveLearningRateRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setBackpropagationParametersEnabled(ALL_ENABLED); } }); batchMomentumRadio = new JRadioButton(resource .getString("batchMomentum")); batchMomentumRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setBackpropagationParametersEnabled(MULTIPLIER_DISABLED); } }); onLineRadio = new JRadioButton(resource.getString("onLine")); onLineRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setBackpropagationParametersEnabled(LEARNING_RATE_ENABLED); } }); onLineAdaptiveLearningRadio = new JRadioButton(resource .getString("onLineAdaptiveLearningRate")); onLineAdaptiveLearningRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setBackpropagationParametersEnabled(ALL_ENABLED); } }); onLineMomentumRadio = new JRadioButton(resource .getString("onLineMomentum")); onLineMomentumRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setBackpropagationParametersEnabled(MULTIPLIER_DISABLED); } }); backPropagationVariationGroup = new ButtonGroup(); backPropagationVariationGroup.add(batchRadio); backPropagationVariationGroup.add(batchAdaptiveLearningRateRadio); backPropagationVariationGroup.add(batchMomentumRadio); backPropagationVariationGroup.add(onLineRadio); backPropagationVariationGroup.add(onLineAdaptiveLearningRadio); backPropagationVariationGroup.add(onLineMomentumRadio); backPropagationVariationGroup.setSelected(batchRadio.getModel(), true); backPropagationVariationPanel = new JPanel(); backPropagationVariationPanel.setLayout(new GridBagLayout()); backPropagationVariationPanel.add(batchRadio, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, borderInsets2, 0, 0)); backPropagationVariationPanel.add(batchAdaptiveLearningRateRadio, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, borderInsets2, 0, 0)); backPropagationVariationPanel.add(batchMomentumRadio, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, borderInsets2, 0, 0)); backPropagationVariationPanel.add(onLineRadio, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, borderInsets2, 0, 0)); backPropagationVariationPanel.add(onLineAdaptiveLearningRadio, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, borderInsets2, 0, 0)); backPropagationVariationPanel.add(onLineMomentumRadio, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, borderInsets2, 0, 0)); backPropagationVariationPanel.setBorder(new TitledBorder(resource.getString("backPropagationVariation"))); maxEpochsLabel = new JLabel(resource.getString("maxEpochs")); maxEpochsSpinnerModel = new SpinnerNumberModel(400, 1, BackPropagationModel.MAX_EPOCHS, 1); maxEpochsSpinner = new JSpinner(maxEpochsSpinnerModel); maxEpochsPanel = new JPanel(); maxEpochsPanel.setLayout(new BorderLayout()); maxEpochsPanel.add(maxEpochsLabel, BorderLayout.NORTH); maxEpochsPanel.add(maxEpochsSpinner, BorderLayout.CENTER); errorLabel = new JLabel(resource.getString("error")); errorSpinnerModel = new SpinnerNumberModel(0.001, 0, 1, 0.001); errorSpinner = new JSpinner(errorSpinnerModel);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -