/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : ICLMath/demos/llm-2D/llm-2D.cpp ** ** Module : ICLMath ** ** Authors: Christof Elbrechter ** ** ** ** ** ** GNU LESSER GENERAL PUBLIC LICENSE ** ** This file may be used under the terms of the GNU Lesser General ** ** Public License version 3.0 as published by the ** ** ** ** Free Software Foundation and appearing in the file LICENSE.LGPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the license requirements will ** ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** ********************************************************************/ #include #include #include static LLM llm(2,3); HBox gui; static const int W = 100; static const int H = 100; static const float MINX = 0; static const float MAXX = iclMax(W,H); float I[W][H][3]; static int *nTrainingSteps = new int(100); static ImgQ image = scale(create("parrot"),W,H); //static ImgQ image = scale(load("sprirals1.ppm"),W,H); DispHandle *mseDisp = 0; static int *nKernels = new int(50); static float *initialSigma = new float(10); static bool *softMaxEnabled = new bool(true); void initI(){ for(int i=0;i >(2,Range(MINX,MAXX)),std::vector(2,*initialSigma)); llm.setSoftMaxEnabled(*softMaxEnabled); } static void trainLLM(){ int N = *nTrainingSteps; float x[2]; for(int i=0;i("net-image"); static ButtonHandle &trainButton = gui.get("train"); static ButtonHandle &showKernelsButton = gui.get("show-k"); static ButtonHandle &resetButton = gui.get("reset"); nKernels = &gui.get("kc"); mseDisp = &gui.get("mse"); nTrainingSteps = &gui.get("steps"); initialSigma = &gui.get("init-sigma"); softMaxEnabled = &gui.get("use-soft-max"); // ImgQ netImage(image.getSize(),formatRGB); ImgQ netImage = copy(image); w.setImage(&netImage); w.render(); while(1){ llm.setEpsilonIn(gui.get("e-in")); llm.setEpsilonOut(gui.get("e-out")); llm.setEpsilonA(gui.get("e-a")); llm.setEpsilonSigma(gui.get("e-sigma")); llm.setSoftMaxEnabled(*softMaxEnabled); if(trainButton.wasTriggered() || gui.get("train-loop")){ trainLLM(); float xx[2]={0,0}; float mse[3]={0,0,0}; for(int x=0;x