📄 functioncache.java
字号:
/* * FunctionCache.java 1.0 09 Jun 2004 * * 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;import java.io.Serializable;import java.util.Vector;/** * Class that implements some technics for activation functions * instances management. The intention is that various activation * functions can be used in different points of the neural network, * without unnecessary instances. * * @version 1.0 09 Jun 2004 * * @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 FunctionCache implements IFunctionCache, Serializable { /** Store the activation functions. */ private Vector activationFunctions; /** An activation function to be stored. */ private IActivationFunction newFunction; /** * Creates a new activation functions cache. */ public FunctionCache() { activationFunctions = new Vector(); } //FunctionCache() /* (non-Javadoc) * @see neuralnetworktoolkit.IFunctionCache#addActivationFunction(java.lang.String) */ public void addActivationFunction(String function) { // TODO Remake this implementation. if ((activationFunctions.size() > 0) && (isIn(function) == true)) { // TODO Throw a exception. } else { if (function.compareTo("Logistic") == 0) { newFunction = new Logistic(); } else if (function.compareTo("Tanh") == 0) { newFunction = new Tanh(); } else if (function.compareTo("Xcube") == 0) { newFunction = new Xcube(); } else if (function.compareTo("Xsquare") == 0) { newFunction = new Xsquare(); } else if (function.compareTo("X") == 0) { newFunction = new X(); } else if (function.compareTo("Exp") == 0) { newFunction = new Exp(); } else if (function.compareTo("Step") == 0) { newFunction = new Step(); } else if (function.compareTo("Sin") == 0) { newFunction = new Sin(); } activationFunctions.addElement(newFunction); } } //addActivationFunction() /* (non-Javadoc) * @see neuralnetworktoolkit.IFunctionCache#removeActivationFunction(java.lang.String) */ public void removeActivationFunction(String function) { IActivationFunction in; for (int i = 0; i < activationFunctions.size(); i++) { in = (IActivationFunction) activationFunctions.elementAt(i); if (function.compareTo(in.getFunctionName()) == 0) { activationFunctions.remove(i); } } } //removeActivationFunction() /* (non-Javadoc) * @see neuralnetworktoolkit.IFunctionCache#getActivationFunction(java.lang.String) */ public IActivationFunction getActivationFunction(String function) { // TODO Remake this implementation. int i = 0; IActivationFunction in = null; do { in = (IActivationFunction) activationFunctions.elementAt(i); i++; } while (function.compareTo(in.getFunctionName()) != 0); return in; } //getActivationFunction() private boolean isIn(String function) { boolean result = false; int i = 0; IActivationFunction in; while ((result == false)&&(i<activationFunctions.size())) { in = (IActivationFunction) activationFunctions.elementAt(i); if (function.compareTo(in.getFunctionName()) == 0) { result = true; } i++; } return result; } //isIn()} //FunctionCache
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -