libeblearntools
|
00001 /*************************************************************************** 00002 * Copyright (C) 2010 by Pierre Sermanet * 00003 * pierre.sermanet@gmail.com * 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Redistribution under a license not approved by the Open Source 00014 * Initiative (http://www.opensource.org) must display the 00015 * following acknowledgement in all advertising material: 00016 * This product includes software developed at the Courant 00017 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00018 * * The names of the authors may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00025 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef NETCONF_H_ 00034 #define NETCONF_H_ 00035 00036 #include "libeblearn.h" 00037 #include "configuration.h" 00038 #include "tools_utils.h" 00039 00040 namespace ebl { 00041 00053 // TODO: default is not allowed for function template, 00054 // solution is to use -std=c++0x or -std=gnu++0x but not available everywhere 00055 // -> find test for these capabilities in cmake 00057 template <typename T, class Tstate> 00058 module_1_1<T,Tstate>* 00059 create_network(parameter<T, Tstate> &theparam, configuration &conf, 00060 intg &thick, int noutputs = -1, const char *varname = "arch", 00061 bool isbranch = false, bool narrow = 0, 00062 intg narrow_dim = 0, intg narrow_size = 0, 00063 intg narrow_offset = 0, 00064 vector<layers<T,Tstate>*>* branches = NULL, 00065 vector<intg> *branches_thick = NULL, 00066 map<string,module_1_1<T,Tstate>*> *shared = NULL); 00067 00068 00073 template <typename T, class Tstate> 00074 module_1_1<T,Tstate>* 00075 create_module(const string &name, parameter<T, Tstate> &theparam, 00076 configuration &conf, int &nout, intg &thick, 00077 map<string,module_1_1<T,Tstate>*> &shared, 00078 vector<layers<T,Tstate>*> *branches, 00079 vector<intg> *branches_thick); 00080 00083 template <typename T, class Tstate> 00084 ebm_1<T,Tstate>* create_ebm1(const string &name, configuration &conf); 00085 00088 template <typename T, typename Tds1, typename Tds2, class Tstate> 00089 answer_module<T,Tds1,Tds2,Tstate>* 00090 create_answer(configuration &conf, uint nclasses, 00091 const char *varname = "answer"); 00092 00095 template <typename T, typename Tds1, typename Tds2, class Tstate> 00096 trainable_module<T,Tds1,Tds2,Tstate>* 00097 create_trainer(configuration &conf, labeled_datasource<T,Tds1,Tds2> &ds, 00098 module_1_1<T,Tstate> &net, 00099 answer_module<T,Tds1,Tds2,Tstate> &answer, 00100 const char *varname = "trainer"); 00101 00102 // preprocessing ///////////////////////////////////////////////////////////// 00103 00117 template <typename T, class Tstate> 00118 resizepp_module<T,Tstate>* 00119 create_preprocessing(uint height, uint width, const char *ppchan, 00120 idxdim &kersz, const char *resize_method = "bilinear", 00121 bool keep_aspect_ratio = true, int lpyramid = 0, 00122 vector<double> *fovea = NULL, 00123 midxdim *fovea_scale_size = NULL, 00124 bool globnorm = true, 00125 bool locnorm = false, bool locnorm2 = false, 00126 bool color_lnorm = false, bool cnorm_across = true, 00127 double hscale = 1.0, double wscale = 1.0, 00128 vector<float> *scalings = NULL); 00129 00144 template <typename T, class Tstate> 00145 resizepp_module<T,Tstate>* 00146 create_preprocessing(midxdim &dims, const char *ppchan, 00147 midxdim &kersz, midxdim &zpads, 00148 const char *resize_method = "bilinear", 00149 bool keep_aspect_ratio = true, int lpyramid = 0, 00150 vector<double> *fovea = NULL, 00151 midxdim *fovea_scale_size = NULL, 00152 bool globnorm = true, 00153 bool locnorm = false, bool locnorm2 = false, 00154 bool color_lnorm = false, bool cnorm_across = true, 00155 double hscale = 1.0, double wscale = 1.0, 00156 vector<float> *scalings = NULL); 00157 00173 template <typename T, class Tstate> 00174 resizepp_module<T,Tstate>* 00175 create_preprocessing(const char *ppchan, midxdim &kersz, midxdim &zpads, 00176 const char *resize_method = "bilinear", 00177 bool keep_aspect_ratio = true, int lpyramid = 0, 00178 vector<double> *fovea = NULL, 00179 midxdim *fovea_scale_size = NULL, 00180 bool globnorm = true, 00181 bool locnorm = false, bool locnorm2 = false, 00182 bool color_lnorm = false, bool cnorm_across = true, 00183 double hscale = 1.0, double wscale = 1.0, 00184 vector<float> *scalings = NULL); 00185 00187 00202 // TODO: default is not allowed for function template, 00203 // solution is to use -std=c++0x or -std=gnu++0x but not available everywhere 00204 // -> find test for these capabilities in cmake 00205 template <typename T, class Tstate> // = bbstate_idx<T> > 00206 module_1_1<T,Tstate>* create_network_old(parameter<T, Tstate> &theparam, 00207 configuration &conf, 00208 int noutputs = -1); 00209 00213 template <class Tmodule, typename T, class Tstate> 00214 bool load_module(configuration &conf, module_1_1<T,Tstate> &m, 00215 const string &module_name, const string &type); 00216 00219 template <typename T, class Tstate> 00220 uint manually_load_network(layers<T,Tstate> &l, configuration &conf, 00221 const char *varname = "arch"); 00222 00229 bool EXPORT load_table(configuration &conf, const string &module_name, 00230 idx<intg> &table, intg thickness, intg noutputs); 00231 00234 void EXPORT load_gd_param(configuration &conf, gd_param &gdp); 00235 00236 } // end namespace ebl 00237 00238 #include "netconf.hpp" 00239 00240 #endif /* NETCONF_H_ */