📄 ebm_gui.h
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * state_idx gui related function * * * * * * * * * * * * * * * * * * * * * * * * * * */class state_Idx_Gui : public ebbox{ Q_OBJECTprivate: state_idx_data data; state_idx* state; /* * * @param fromproperties is used to know if we refresh the display from * the properties dialog (so we have to update the plotting datas) or from * the keyboard shortcuts (the plotting datas are already changed) * anyway as a user you don't have to use it * */ bool fromproperties; //! opens the properties dialog void openProperties();public slots: /* * * checks various display settings, triggers a warning if it seems weird, * and calls the displayAll() function of the display widget * */ void refreshdisplay(); //! prints accordingly to the print settings void print(); /* * * handles the keyboard event. So far: * = (equals) -> zoom in * - (minus) -> zoom out * p -> print * q -> close * */ void keyPressEvent( QKeyEvent* event);public: state_Idx_Gui(state_idx* stateIdx, const char* title = "state_idx", QWidget *parent = 0, QMutex* mutex = NULL); ~state_Idx_Gui(){}; //! sets the min value for custom normalisation void setvmin(double xmin, double dxmin, double ddxmin); //! sets the max value for custoom normalisation void setvmax(double xmax, double dxmax, double ddxmax); //! enable (or not) the visualization void setvisible(bool xvisible, bool dxvisible, bool ddxvisible); //! set visualization as array if idx1 void setidx1_as_array(bool xarray, bool dxarray, bool ddxarray); //! set visualization as RGB if idx3 void setidx3_as_RGB(bool xrgb, bool dxrgb, bool ddxrgb);};/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //////////////////////////////////////////////////////////////////////////////////////////// * From this point, the next classes are specialized gui * designed for the corresponding ebm modules * //////////////////////////////////////////////////////////////////////////////////////////// * * All the constructors are doubled * The first version creates automatically state_idx_GUIs for * the state_idxs provided, and then creates the other GUIs * that are special to the module * The second only creates the later* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//* * * General module_1_1 GUI: use it for every module_1_1 that doesn't have any particular feature to display * Keep in my mind that this GUI library only displays things, you won't be able to launch any operation (for now at least) * this module is to be used for : * the stdsigmoid_module * the tanh_module * for the rest of the specialized module_1_1, use the specialized GUIs * */class module_1_1_GUI : public ebbox{ Q_OBJECTprivate: state_idx* in; state_idx* out;public: module_1_1_GUI(state_idx* in, state_idx* out, const char* title = "module_1_1", QWidget *parent = 0, QMutex* mutex = NULL); module_1_1_GUI(const char* title = "module_1_1", QWidget *parent = 0, QMutex* mutex = NULL); ~module_1_1_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for module_2_1 (2 ins and 1 out) * * * * * * * * * * * * * * * * * * * * * * */class module_2_1_GUI : public ebbox{ Q_OBJECTprivate: state_idx* in1; state_idx* in2; state_idx* out;public: module_2_1_GUI(state_idx* in1, state_idx* in2, state_idx* out, const char* title = "module_2_1", QWidget *parent = 0, QMutex* mutex = NULL); module_2_1_GUI(const char* title = "module_2_1", QWidget *parent = 0, QMutex* mutex = NULL); ~module_2_1_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for layers_2 (general architecture with one hidden layer) * The GUI automatically provides : * a state_idx_GUI for the hidden layer * 2 module_1_1_GUI for the 2 modules * * * * * * * * * * * * * * * * * * * * * * */class layers_2_GUI : public ebbox{ Q_OBJECTprivate: layers_2<state_idx, state_idx, state_idx>* layer2; state_idx* in; state_idx* out;public: layers_2_GUI(layers_2<state_idx, state_idx, state_idx>* layer2, state_idx* in, state_idx* out, const char* title = "layers_2 <state_idx, state_idx, state_idx>", QWidget *parent = 0, QMutex* mutex = NULL); layers_2_GUI(layers_2<state_idx, state_idx, state_idx>* layer2, const char* title = "layers_2 <state_idx, state_idx, state_idx>", QWidget *parent = 0, QMutex* mutex = NULL); ~layers_2_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for fc_ebm1 (1 in EBM) * The GUI automatically provides : * a state_idx_GUI for the out calculated by the function * 2 module_1_1_GUI for the 2 modules * * * * * * * * * * * * * * * * * * * * * * */class fc_ebm1_GUI : public ebbox{ Q_OBJECTprivate: fc_ebm1<state_idx, state_idx>* ebm1; state_idx* in; state_idx* energy;public: fc_ebm1_GUI(fc_ebm1<state_idx, state_idx>* ebm1, state_idx* in, state_idx* energy, const char* title = "fc_ebm1<state_idx, state_idx>", QWidget *parent = 0, QMutex* mutex = NULL); fc_ebm1_GUI(fc_ebm1<state_idx, state_idx>* ebm1, const char* title = "fc_ebm1<state_idx, state_idx>", QWidget *parent = 0, QMutex* mutex = NULL); ~fc_ebm1_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for fc_ebm2 (2 ins EBM) * The GUI automatically provides : * a state_idx_GUI for the out calculated by the function * 2 module_1_1_GUI for the 2 modules * * * * * * * * * * * * * * * * * * * * * * */class fc_ebm2_GUI : public ebbox{ Q_OBJECTprivate: fc_ebm2<state_idx, state_idx, state_idx>* ebm2; state_idx* in1; state_idx* in2; state_idx* energy;public: fc_ebm2_GUI(fc_ebm2<state_idx, state_idx, state_idx>* ebm2, state_idx* in1, state_idx* in2, state_idx* energy, const char* title = "fc_ebm2<state_idx, state_idx, state_idx>", QWidget *parent = 0, QMutex* mutex = NULL); fc_ebm2_GUI(fc_ebm2<state_idx, state_idx, state_idx>* ebm2, const char* title = "fc_ebm2<state_idx, state_idx, state_idx>", QWidget *parent = 0, QMutex* mutex = NULL); ~fc_ebm2_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for linear modules * The GUI automatically provides a state_idx_GUI for the weights * * * * * * * * * * * * * * * * * * * * * * */class linear_module_GUI : public module_1_1_GUI{ Q_OBJECTprivate: linear_module* module;public: linear_module_GUI(linear_module* module, state_idx *in, state_idx *out, const char* title = "linear module", QWidget *parent = 0, QMutex* mutex = NULL); linear_module_GUI(linear_module* module, const char* title = "linear module", QWidget *parent = 0, QMutex* mutex = NULL); ~linear_module_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for nn_layer_full (fully-connected neural net layer: linear + tanh non-linearity) * The GUI automatically provides: * a linear_module_GUI * Two state_idx_GUI for the bias and the sum state_idxs * a module_1_1_GUI for the tan_h module * * * * * * * * * * * * * * * * * * * * * * */class nn_layer_full_GUI : public module_1_1_GUI{ Q_OBJECTprivate: nn_layer_full* layer;public: nn_layer_full_GUI(nn_layer_full* layer, state_idx *in, state_idx *out, const char* title = "nn_layer_full", QWidget *parent = 0, QMutex* mutex = NULL); nn_layer_full_GUI(nn_layer_full* layer, const char* title = "nn_layer_full", QWidget *parent = 0, QMutex* mutex = NULL); ~nn_layer_full_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for f_layerl (full connection between replicable 3D layers) * The GUI automatically provides: * Three state_idx_GUI for the weights, bias and sum state_idxs * a module_1_1_GUI for the squash function * * * * * * * * * * * * * * * * * * * * * * */class f_layer_GUI : public module_1_1_GUI{ Q_OBJECTprivate: f_layer* layer;public: f_layer_GUI(f_layer* layer, state_idx *in, state_idx *out, const char* title = "f_layer", const char* squash_title = "squash", QWidget *parent = 0, QMutex* mutex = NULL); f_layer_GUI(f_layer* layer, const char* title = "f_layer", const char* squash_title = "squash", QWidget *parent = 0, QMutex* mutex = NULL); ~f_layer_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for c_layer (convolutional layer module) * The GUI automatically provides: * an Idx_GUI for the table * Three state_idx_GUI for the kernel, bias and sum state_idxs * a module_1_1_GUI for the squash function * * * * * * * * * * * * * * * * * * * * * * */class c_layer_GUI : public module_1_1_GUI{ Q_OBJECTprivate: c_layer* layer;public: c_layer_GUI(c_layer* layer, state_idx *in, state_idx *out, const char* title = "c_layer", const char* squash_title = "squash function", QWidget *parent = 0, QMutex* mutex = NULL); c_layer_GUI(c_layer* layer, const char* title = "c_layer", const char* squash_title = "squash", QWidget *parent = 0, QMutex* mutex = NULL); ~c_layer_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for s_layer (subsampling layer class) * The GUI automatically provides: * 4 state_idx_GUI for the coeff, bias sub and sum state_idxs * a module_1_1_GUI for the squash function * * * * * * * * * * * * * * * * * * * * * * */class s_layer_GUI : public module_1_1_GUI{ Q_OBJECTprivate: s_layer* layer;public: s_layer_GUI(s_layer* layer, state_idx *in, state_idx *out, const char* title = "s_layer", const char* squash_title = "squash function", QWidget *parent = 0, QMutex* mutex = NULL); s_layer_GUI(s_layer* layer, const char* title = "s_layer", const char* squash_title = "squash", QWidget *parent = 0, QMutex* mutex = NULL); ~s_layer_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for logadd_layer (log-add over spatial dimensions of an idx3-state * The GUI automatically provides 2 Idx_GUIs for the expdist and sumexp Idxs * * * * * * * * * * * * * * * * * * * * * * */class logadd_layer_GUI : public module_1_1_GUI{ Q_OBJECTprivate: logadd_layer* layer;public: logadd_layer_GUI(logadd_layer* layer, state_idx *in, state_idx *out, const char* title = "logadd_layer", QWidget *parent = 0, QMutex* mutex = NULL); logadd_layer_GUI(logadd_layer* layer, const char* title = "logadd_layer", QWidget *parent = 0, QMutex* mutex = NULL); ~logadd_layer_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * GUI for edist_cost (replicable Euclidean distance cost function.) * The GUI automatically provides : * a logadd_layer_GUI * two state_idx_GUI for the distance and loggaded distance * 1 Idx_GUI for the proto * * * * * * * * * * * * * * * * * * * * * * */class edist_cost_GUI : public module_1_1_GUI{ Q_OBJECTprivate: edist_cost* edist;public: edist_cost_GUI(edist_cost* edist, state_idx *in, state_idx *energy, const char* title = "edist_cost", QWidget *parent = 0, QMutex* mutex = NULL); edist_cost_GUI(edist_cost* edist, const char* title = "edist_cost", QWidget *parent = 0, QMutex* mutex = NULL); ~edist_cost_GUI(){};};/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ebwindow is a simple "whiteboard" on which you can display * idxs with gray_draw_matrix and RGB_draw_matrix * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */class ebwindow : public QWidget{ Q_OBJECTprivate: QPixmap* mydisplay; QLabel* mylabel; QPainter* painter; void resizeEvent (QResizeEvent *event);public: /* * * Be careful to create a whiteboard big enough for your pictures, since you won't be able * to make it bigger after (ie resizing the window will scale the content, you won't have more space to draw on) * */ ebwindow(int height = 500, int width = 500); /* * * gray_draw_matrix displays your idx2 or the first layer of your idx3 in grayscale on the whiteboard. * This function does a copy of your idx and won't change in in any way ! * @param idx and @param type are, like before, used to templatize the function * @param x and @param y are the coordinates of the top-left corner of your picture on the whiteboard * @param minv and @param maxv are the min and max values to set colors. If left to zero, the min of * your idx will be set to 0 and the max will be 255 * @param zoomx and @param zoomy are the zoom factors in width and height * @param mutex is used if you want to protect your idx (multi-thread) * */ void gray_draw_matrix(void* idx, idx_type type, int x = 0, int y = 0, int minv = 0, int maxv = 0, int zoomx = 1, int zoomy = 1, QMutex* mutex = NULL); /* * * RGB_draw_matrix displays the 3 firsts layers of your idx3 as a RGB picture on the whiteboard. * Attention : it won't change the values in your idx, so if you want a good display, you have to make it * an idx3 with values between 0 and 255 !! * This function does a copy of your idx and won't change in in any way ! * @param idx and @param type are, like before, used to templatize the function * @param x and @param y are the coordinates of the top-left corner of your picture on the whiteboard * @param zoomx and @param zoomy are the zoom factors in width and height * @param mutex is used if you want to protect your idx (multi-thread) * */ void RGB_draw_matrix(void* idx, idx_type type, int x = 0, int y = 0, int zoomx = 1, int zoomy = 1, QMutex* mutex = NULL);};#endif // EBM_GUI_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -