libeblearngui
/home/rex/ebltrunk/tools/libeblearngui/include/ebl_trainer_gui.h
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 EBL_TRAINER_GUI_H_
00033 #define EBL_TRAINER_GUI_H_
00034 
00035 #include "libidxgui.h"
00036 #include "ebl_trainer.h"
00037 #include "datasource_gui.h"
00038 #include "ebl_arch_gui.h"
00039 
00040 namespace ebl {
00041 
00044 
00045   template <class Tnet, class Tdata, class Tlabel>
00046     class supervised_trainer_gui : public scroll_box {    
00047   public:
00049     supervised_trainer_gui(const char *title = NULL, bool scroll = false);
00050     virtual ~supervised_trainer_gui();
00051     
00056     void display_datasource(supervised_trainer<Tnet, Tdata, Tlabel> &st,
00057                             labeled_datasource<Tnet, Tdata, Tlabel> &ds,
00058                             infer_param &infp,
00059                             unsigned int nh, unsigned int nw, 
00060                             unsigned int h0 = 0, unsigned int w0 = 0, 
00061                             double zoom = 1.0, int wid = -1,
00062                             const char *title = NULL, bool scrolling = false);
00063     
00065     void display_internals(supervised_trainer<Tnet, Tdata, Tlabel> &st,
00066                            labeled_datasource<Tnet, Tdata, Tlabel> &ds, 
00067                            infer_param &infp, gd_param &args,
00068                            unsigned int ninternals, 
00069                            unsigned int h0 = 0, unsigned int w0 = 0, 
00070                            double zoom = 1.0, int wid = -1,
00071                            const char *title = NULL);
00072 
00080     void display_correctness(bool incorrect, bool up,
00081                              supervised_trainer<Tnet, Tdata, Tlabel> &st,
00082                              labeled_datasource<Tnet, Tdata, Tlabel> &ds,
00083                              infer_param &infp,
00084                              unsigned int nh, unsigned int nw,
00085                              bool print_raw_outputs = false,
00086                              bool draw_all_jitter = false,
00087                              unsigned int h0 = 0, unsigned int w0 = 0, 
00088                              double zoom = 1.0, int wid = -1,
00089                              const char *title = NULL, bool scrolling = false);
00090     
00092     // inherited methods to implement for scrolling capabilities
00093     
00095     virtual void display_next ();
00097     virtual void display_previous ();
00099     virtual unsigned int max_pages ();
00100     //    virtual scroll_box0* copy();
00102     virtual supervised_trainer_gui<Tnet, Tdata, Tlabel>* copy();
00103 
00104     // members /////////////////////////////////////////////////////////////////
00105   protected:
00106     supervised_trainer<Tnet, Tdata, Tlabel>     *_st;
00107     labeled_datasource<Tnet, Tdata, Tlabel>     *_ds;
00108     labeled_datasource<Tnet, Tdata, Tlabel>     *_last_ds;
00109     infer_param                                 *_infp;
00110     unsigned int                                 _nh;
00111     unsigned int                                 _nw;
00112     double                                       _zoom;
00113     int                                          datasource_wid;
00114     int                                          datasource_wid2;
00115     int                                          datasource_wid3;
00116     int                                          datasource_wid4;
00117     int                                          internals_wid;
00118     int                                          internals_wid2;
00119     int                                          internals_wid3;
00120     bool                                         scroll;
00121     bool                                         scroll_added;
00122     unsigned int                                 pos;
00123     labeled_datasource_gui<Tnet, Tdata, Tlabel> *dsgui;
00124     string                                       title0; 
00125     string                                       title1;
00126     string                                       title2;
00127     string                                       title3;
00128     string                                       title4;    
00129   };
00130 
00131 } // namespace ebl {
00132 
00133 #include "ebl_trainer_gui.hpp"
00134 
00135 #endif /* EBL_TRAINER_GUI_H_ */