logistic.java

来自「利用Java实现的神经网络工具箱」· Java 代码 · 共 108 行

JAVA
108
字号
/* * $RCSfile: Logistic.java,v $ * $Revision: 1.1 $ * $Date: 2004/10/17 01:35:30 $ * * 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.activationfunctions;/** * Logistic activation function. *  * @version $Revision: 1.1 $ - $Date: 2004/10/17 01:35:30 $ *  * @author <a href="mailto:hugoiver@yahoo.com.br">Hugo Iver V. Gonçalves</a> * @author <a href="mailto:rodbra@pop.com.br">Rodrigo C. M. Coimbra</a> */public class Logistic extends ActivationFunction {	/** Dafault steep value. */	public static final double DEFAULT_STEEP = 1;	/** Steep parameter value. */	private double steep;	/** Auto-reference to provide the unique class instance. */	private static Logistic function;	/**	 * Creates a new Logistic activation function.	 */	public Logistic() {		functionName = "Logistic";		functionExpression = "1 / (1 + exp(-s * x))";		functionDerivativeExpression = 			"(s * exp(-s * s)) / ((1 + exp(-s * x)) * (1 + exp(-s * x)))";		steep = DEFAULT_STEEP;			} //Logistic()		/**	 * Returns the unique instance of <code>Logistic</code>.	 * 	 * @return Unique instance of <code>Logistic</code>.	 */	public static Logistic instantiate() {		if(function == null) {			function = new Logistic();					}				return function;			} //instantiate()		/* 	 * @see neuralnetworktoolkit.activationfunctions.ActivationFunction#functionValue()	 */	public double functionValue(double input) {		return 1 / (1 + Math.exp(-steep * input));			} //functionValue	/* 	 * @see neuralnetworktoolkit.activationfunctions.ActivationFunction#functionDerivative()	 */	public double functionDerivative(double input) {		return (steep * Math.exp(-steep * input))			/ ((1 + Math.exp(-steep * input)) * (1 + Math.exp(-steep * input)));				} //functionDerivative()		/**	 * Returns the steep parameter value.	 * 	 * @return Returns the steep.	 */	public double getSteep() {		return steep;			} //getSteep()		/**	 * Sets the steep parameter value.	 * 	 * @param steep The steep to set.	 */	public void setSteep(double steep) {		this.steep = steep;			} //setSteep()	} //Logistic	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?