00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Yann LeCun and Pierre Sermanet * 00003 * yann@cs.nyu.edu, pierre.sermanet@gmail.com * 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * * Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Redistribution under a license not approved by the Open Source 00013 * Initiative (http://www.opensource.org) must display the 00014 * following acknowledgement in all advertising material: 00015 * This product includes software developed at the Courant 00016 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00017 * * The names of the authors may not be used to endorse or promote products 00018 * derived from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00021 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00023 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00024 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00025 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00026 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00027 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 ***************************************************************************/ 00031 00032 #ifndef EBLNONLINEARITY_H_ 00033 #define EBLNONLINEARITY_H_ 00034 00035 #include "Defines.h" 00036 #include "Idx.h" 00037 #include "Blas.h" 00038 #include "EblStates.h" 00039 #include "EblBasic.h" 00040 #include "EblArch.h" 00041 00042 namespace ebl { 00043 00045 00047 class stdsigmoid_module: public module_1_1<state_idx, state_idx> { 00048 public: 00050 stdsigmoid_module(); 00051 virtual ~stdsigmoid_module(); 00053 virtual void fprop(state_idx &in, state_idx &out); 00055 virtual void bprop(state_idx &in, state_idx &out); 00057 virtual void bbprop(state_idx &in, state_idx &out); 00058 }; 00059 00061 00063 class tanh_module: public module_1_1<state_idx, state_idx> { 00064 public: 00066 void fprop(state_idx &in, state_idx &out); 00068 void bprop(state_idx &in, state_idx &out); 00070 void bbprop(state_idx &in, state_idx &out); 00071 void forget(forget_param_linear &fp); 00072 void normalize(); 00073 }; 00074 00076 00085 00086 class softmax: public module_1_1<state_idx, state_idx> { 00087 00088 public: 00089 double beta; 00090 00091 // <b> is the parameter beta in the softmax 00092 // large <b> turns the softmax into a max 00093 // <b> equal to 0 turns the softmax into 1/N 00094 00095 private: 00096 void resize_nsame(state_idx &in, state_idx &out, int n); 00097 00098 public: 00099 softmax(double b); 00100 ~softmax() { 00101 } 00102 ; 00103 void fprop(state_idx &in, state_idx &out); 00104 void bprop(state_idx &in, state_idx &out); 00105 void bbprop(state_idx &in, state_idx &out); 00106 00107 }; 00108 00109 } // namespace ebl { 00110 00111 #endif /* EBLNONLINEARITY_H_ */
1.5.6