/*
  ==============================================================================

  This is an automatically generated GUI class created by the Introjucer!

  Be careful when adding custom code to these files, as only the code within
  the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  and re-saved.

  Created with Introjucer version: 3.1.0

  ------------------------------------------------------------------------------

  The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
  Copyright 2004-13 by Raw Material Software Ltd.

  ==============================================================================
*/

//[Headers] You can add your own extra header files here...
#ifdef WIN32
#include <Windows.h>
#endif
#include <iostream>
#include <Eigen/Dense>
//[/Headers]

#include "MainComponent.h"


//[MiscUserDefs] You can add your own user definitions and misc code here...
#ifdef WIN32
void mylog(const char* format, ...)
{
	char log_buf[257];
    va_list argptr;
    va_start(argptr, format);
    vsprintf(log_buf, format, argptr);
    va_end(argptr);
	OutputDebugStringA (log_buf);
}
#else
void mylog(const char* format, ...)
{
	char log_buf[257];
    va_list argptr;
    va_start(argptr, format);
    vprintf(format, argptr);
    va_end(argptr);
}
#endif

//[/MiscUserDefs]

//==============================================================================
MainComponent::MainComponent ()
    : Thread("RBM"),
      m_layers(this),
      m_pRbm(nullptr),
      DrawTraining(nullptr),
      DrawReconstruction(nullptr),
      DrawWeights(nullptr),
      DrawHidden(nullptr)
{
    addAndMakeVisible (trainButton = new TextButton ("Train button"));
    trainButton->setButtonText (TRANS("Train"));
    trainButton->addListener (this);

    addAndMakeVisible (addButton = new TextButton ("Add button"));
    addButton->setButtonText (TRANS("Add"));
    addButton->addListener (this);

    addAndMakeVisible (patterSlider = new Slider ("Pattern slider"));
    patterSlider->setRange (0, 0, 1);
    patterSlider->setSliderStyle (Slider::LinearBar);
    patterSlider->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
    patterSlider->addListener (this);

    addAndMakeVisible (reconstructButton = new TextButton ("Reconstruct button"));
    reconstructButton->setButtonText (TRANS("Reconstruct"));
    reconstructButton->addListener (this);

    addAndMakeVisible (ShakeButton = new TextButton ("Shake button"));
    ShakeButton->setButtonText (TRANS("Shake"));
    ShakeButton->addListener (this);

    addAndMakeVisible (WeightsSlider = new Slider ("Weights slider"));
    WeightsSlider->setRange (0, 0, 1);
    WeightsSlider->setSliderStyle (Slider::LinearBar);
    WeightsSlider->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
    WeightsSlider->addListener (this);

    addAndMakeVisible (numEpochslabel = new Label ("Num Epochs label",
                                                   TRANS("100")));
    numEpochslabel->setFont (Font (15.00f, Font::plain));
    numEpochslabel->setJustificationType (Justification::centred);
    numEpochslabel->setEditable (true, true, false);
    numEpochslabel->setColour (TextEditor::textColourId, Colours::black);
    numEpochslabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    numEpochslabel->addListener (this);

    addAndMakeVisible (learningRateLabel = new Label ("Learning Rate label",
                                                      TRANS("0.01")));
    learningRateLabel->setFont (Font (15.00f, Font::plain));
    learningRateLabel->setJustificationType (Justification::centred);
    learningRateLabel->setEditable (true, true, false);
    learningRateLabel->setColour (TextEditor::textColourId, Colours::black);
    learningRateLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    learningRateLabel->addListener (this);

    addAndMakeVisible (testButton = new TextButton ("Test button"));
    testButton->setButtonText (TRANS("Test"));
    testButton->addListener (this);

    addAndMakeVisible (numVisibleLabel = new Label ("Num Visible label",
                                                    TRANS("99999")));
    numVisibleLabel->setFont (Font (15.00f, Font::plain));
    numVisibleLabel->setJustificationType (Justification::centred);
    numVisibleLabel->setEditable (true, true, false);
    numVisibleLabel->setColour (TextEditor::textColourId, Colours::black);
    numVisibleLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    numVisibleLabel->addListener (this);

    addAndMakeVisible (numHiddenLabel = new Label ("Num Hidden label",
                                                   TRANS("99999")));
    numHiddenLabel->setFont (Font (15.00f, Font::plain));
    numHiddenLabel->setJustificationType (Justification::centred);
    numHiddenLabel->setEditable (true, true, false);
    numHiddenLabel->setColour (TextEditor::textColourId, Colours::black);
    numHiddenLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    numHiddenLabel->addListener (this);

    addAndMakeVisible (createButton = new TextButton ("Create button"));
    createButton->setButtonText (TRANS("Create"));
    createButton->addListener (this);

    addAndMakeVisible (projectNameLabel = new Label ("Project Name label",
                                                     TRANS("TestPrj")));
    projectNameLabel->setFont (Font (15.00f, Font::plain));
    projectNameLabel->setJustificationType (Justification::centred);
    projectNameLabel->setEditable (true, true, false);
    projectNameLabel->setColour (TextEditor::textColourId, Colours::black);
    projectNameLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    projectNameLabel->addListener (this);

    addAndMakeVisible (loadButton = new TextButton ("Load button"));
    loadButton->setButtonText (TRANS("Load"));
    loadButton->addListener (this);

    addAndMakeVisible (saveButton = new TextButton ("Save button"));
    saveButton->setButtonText (TRANS("Save"));
    saveButton->addListener (this);

    addAndMakeVisible (numVisibleYLabel = new Label ("Num Visible Y label",
                                                     TRANS("99999")));
    numVisibleYLabel->setFont (Font (15.00f, Font::plain));
    numVisibleYLabel->setJustificationType (Justification::centred);
    numVisibleYLabel->setEditable (true, true, false);
    numVisibleYLabel->setColour (TextEditor::textColourId, Colours::black);
    numVisibleYLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    numVisibleYLabel->addListener (this);

    addAndMakeVisible (loadTrainingButton = new TextButton ("Load Training button"));
    loadTrainingButton->setButtonText (TRANS("Load T"));
    loadTrainingButton->addListener (this);

    addAndMakeVisible (saveTrainingButton = new TextButton ("Save Training button"));
    saveTrainingButton->setButtonText (TRANS("Save T"));
    saveTrainingButton->addListener (this);

    addAndMakeVisible (clearTrainingButton = new TextButton ("Clear Training button"));
    clearTrainingButton->setButtonText (TRANS("Clear T"));
    clearTrainingButton->addListener (this);

    addAndMakeVisible (removeTrainingButton = new TextButton ("Remove Training button"));
    removeTrainingButton->setButtonText (TRANS("Remove T"));
    removeTrainingButton->addListener (this);

    addAndMakeVisible (numGibbsSlider = new Slider ("Num. Gibbs slider"));
    numGibbsSlider->setRange (1, 101, 1);
    numGibbsSlider->setSliderStyle (Slider::LinearBar);
    numGibbsSlider->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
    numGibbsSlider->addListener (this);

    addAndMakeVisible (reconstructEquButton = new TextButton ("Reconstruct Equilibrium button"));
    reconstructEquButton->setButtonText (TRANS("Reconst Equ."));
    reconstructEquButton->addListener (this);

    addAndMakeVisible (rbmDoRaoBlackwellToggleButton = new ToggleButton ("rbmDoRaoBlackwell toggle button"));
    rbmDoRaoBlackwellToggleButton->setButtonText (TRANS("Rao-Blackwell"));
    rbmDoRaoBlackwellToggleButton->addListener (this);

    addAndMakeVisible (rbmReduceVarianceToggleButton = new ToggleButton ("rbmReduceVariance toggle button"));
    rbmReduceVarianceToggleButton->setButtonText (TRANS("Reduce Variance"));
    rbmReduceVarianceToggleButton->addListener (this);

    addAndMakeVisible (lambdaLabel = new Label ("Lambda label",
                                                TRANS("1.0")));
    lambdaLabel->setFont (Font (15.00f, Font::plain));
    lambdaLabel->setJustificationType (Justification::centred);
    lambdaLabel->setEditable (true, true, false);
    lambdaLabel->setColour (TextEditor::textColourId, Colours::black);
    lambdaLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    lambdaLabel->addListener (this);

    addAndMakeVisible (sigmaLabel = new Label ("Sigma label",
                                               TRANS("1.0")));
    sigmaLabel->setFont (Font (15.00f, Font::plain));
    sigmaLabel->setJustificationType (Justification::centred);
    sigmaLabel->setEditable (true, true, false);
    sigmaLabel->setColour (TextEditor::textColourId, Colours::black);
    sigmaLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    sigmaLabel->addListener (this);

    addAndMakeVisible (rbmUseVisibleGaussianToggleButton = new ToggleButton ("rbmUseVisibleGaussian toggle button"));
    rbmUseVisibleGaussianToggleButton->setButtonText (TRANS("Use gaussian visible"));
    rbmUseVisibleGaussianToggleButton->addListener (this);

    addAndMakeVisible (rbmDoSparseToggleButton = new ToggleButton ("rbmDoSparse toggle button"));
    rbmDoSparseToggleButton->setButtonText (TRANS("Do sparse"));
    rbmDoSparseToggleButton->addListener (this);

    addAndMakeVisible (sparsityLabel = new Label ("Sparsity label",
                                                  TRANS("0.05")));
    sparsityLabel->setFont (Font (15.00f, Font::plain));
    sparsityLabel->setJustificationType (Justification::centred);
    sparsityLabel->setEditable (true, true, false);
    sparsityLabel->setColour (TextEditor::textColourId, Colours::black);
    sparsityLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    sparsityLabel->addListener (this);

    addAndMakeVisible (sigmaDecayLabel = new Label ("SigmaDecay label",
                                                    TRANS("1.0")));
    sigmaDecayLabel->setFont (Font (15.00f, Font::plain));
    sigmaDecayLabel->setJustificationType (Justification::centred);
    sigmaDecayLabel->setEditable (true, true, false);
    sigmaDecayLabel->setColour (TextEditor::textColourId, Colours::black);
    sigmaDecayLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    sigmaDecayLabel->addListener (this);

    addAndMakeVisible (weightDecayLabel = new Label ("WeightDecay label",
                                                     TRANS("0.0")));
    weightDecayLabel->setFont (Font (15.00f, Font::plain));
    weightDecayLabel->setJustificationType (Justification::centred);
    weightDecayLabel->setEditable (true, true, false);
    weightDecayLabel->setColour (TextEditor::textColourId, Colours::black);
    weightDecayLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    weightDecayLabel->addListener (this);

    addAndMakeVisible (m_progressBarSlider = new Slider ("progressBar slider"));
    m_progressBarSlider->setRange (0, 100, 1);
    m_progressBarSlider->setSliderStyle (Slider::LinearBar);
    m_progressBarSlider->setTextBoxStyle (Slider::TextBoxLeft, true, 80, 20);
    m_progressBarSlider->addListener (this);

    addAndMakeVisible (momentumLabel = new Label ("Momentum label",
                                                  TRANS("0.5")));
    momentumLabel->setFont (Font (15.00f, Font::plain));
    momentumLabel->setJustificationType (Justification::centred);
    momentumLabel->setEditable (true, true, false);
    momentumLabel->setColour (TextEditor::textColourId, Colours::black);
    momentumLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    momentumLabel->addListener (this);

    addAndMakeVisible (sparsityLearningRateLabel = new Label ("SparsityLearn label",
                                                              TRANS("0.01")));
    sparsityLearningRateLabel->setFont (Font (15.00f, Font::plain));
    sparsityLearningRateLabel->setJustificationType (Justification::centred);
    sparsityLearningRateLabel->setEditable (true, true, false);
    sparsityLearningRateLabel->setColour (TextEditor::textColourId, Colours::black);
    sparsityLearningRateLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    sparsityLearningRateLabel->addListener (this);

    addAndMakeVisible (weightInitLabel = new Label ("WeightInit label",
                                                    TRANS("0.001")));
    weightInitLabel->setFont (Font (15.00f, Font::plain));
    weightInitLabel->setJustificationType (Justification::centred);
    weightInitLabel->setEditable (true, true, false);
    weightInitLabel->setColour (TextEditor::textColourId, Colours::black);
    weightInitLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
    weightInitLabel->addListener (this);

    addAndMakeVisible (rbmTrainV2ToggleButton = new ToggleButton ("rbmTrainV2ToggleButton toggle button"));
    rbmTrainV2ToggleButton->setButtonText (TRANS("Train Ver. 2"));
    rbmTrainV2ToggleButton->addListener (this);


    //[UserPreSize]
	m_vNumX = 16;
	m_vNumY = 16;
	m_hNum = 64;
	m_numGibbs = 1;
	m_weights.setUnits(m_vNumX*m_vNumY, m_hNum);
	m_pRbm = new Rbm(m_weights, this);
	create();

    //[/UserPreSize]

    setSize (800, 600);


    //[Constructor] You can add your own custom stuff here..
    m_progressBarSlider->setValue(100);
    //[/Constructor]
}

MainComponent::~MainComponent()
{
    //[Destructor_pre]. You can add your own custom destruction code here..
    //[/Destructor_pre]

    trainButton = nullptr;
    addButton = nullptr;
    patterSlider = nullptr;
    reconstructButton = nullptr;
    ShakeButton = nullptr;
    WeightsSlider = nullptr;
    numEpochslabel = nullptr;
    learningRateLabel = nullptr;
    testButton = nullptr;
    numVisibleLabel = nullptr;
    numHiddenLabel = nullptr;
    createButton = nullptr;
    projectNameLabel = nullptr;
    loadButton = nullptr;
    saveButton = nullptr;
    numVisibleYLabel = nullptr;
    loadTrainingButton = nullptr;
    saveTrainingButton = nullptr;
    clearTrainingButton = nullptr;
    removeTrainingButton = nullptr;
    numGibbsSlider = nullptr;
    reconstructEquButton = nullptr;
    rbmDoRaoBlackwellToggleButton = nullptr;
    rbmReduceVarianceToggleButton = nullptr;
    lambdaLabel = nullptr;
    sigmaLabel = nullptr;
    rbmUseVisibleGaussianToggleButton = nullptr;
    rbmDoSparseToggleButton = nullptr;
    sparsityLabel = nullptr;
    sigmaDecayLabel = nullptr;
    weightDecayLabel = nullptr;
    m_progressBarSlider = nullptr;
    momentumLabel = nullptr;
    sparsityLearningRateLabel = nullptr;
    weightInitLabel = nullptr;
    rbmTrainV2ToggleButton = nullptr;


    //[Destructor]. You can add your own custom destruction code here..
    DrawTraining = nullptr;
    DrawReconstruction = nullptr;
    DrawWeights = nullptr;
    DrawHidden = nullptr;
    m_pRbm = nullptr;

    //[/Destructor]
}

//==============================================================================
void MainComponent::paint (Graphics& g)
{
    //[UserPrePaint] Add your own custom painting code here..
    //[/UserPrePaint]

    g.fillAll (Colours::white);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Sigma"),
                32, 306, 80, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Lambda"),
                120, 306, 80, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Num. epochs"),
                32, 354, 80, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Alpha"),
                120, 354, 80, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Sparsity"),
                208, 306, 80, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Sigma decay"),
                296, 306, 96, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Weight decay"),
                296, 354, 96, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Momentum"),
                208, 354, 80, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Sparsity Alpha"),
                408, 306, 96, 14,
                Justification::centred, true);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Weight init"),
                408, 354, 96, 14,
                Justification::centred, true);

    //[UserPaint] Add your own custom painting code here..
    //[/UserPaint]
}

void MainComponent::resized()
{
    trainButton->setBounds (120, 408, 72, 24);
    addButton->setBounds (24, 160, 72, 24);
    patterSlider->setBounds (224, 448, 184, 24);
    reconstructButton->setBounds (24, 408, 72, 24);
    ShakeButton->setBounds (120, 448, 72, 24);
    WeightsSlider->setBounds (224, 488, 184, 24);
    numEpochslabel->setBounds (32, 368, 72, 24);
    learningRateLabel->setBounds (120, 368, 72, 24);
    testButton->setBounds (120, 160, 72, 24);
    numVisibleLabel->setBounds (504, 224, 72, 24);
    numHiddenLabel->setBounds (552, 256, 72, 24);
    createButton->setBounds (552, 288, 72, 24);
    projectNameLabel->setBounds (536, 192, 96, 24);
    loadButton->setBounds (504, 160, 72, 24);
    saveButton->setBounds (584, 160, 72, 24);
    numVisibleYLabel->setBounds (576, 224, 72, 24);
    loadTrainingButton->setBounds (504, 48, 72, 24);
    saveTrainingButton->setBounds (584, 48, 72, 24);
    clearTrainingButton->setBounds (584, 88, 72, 24);
    removeTrainingButton->setBounds (504, 88, 72, 24);
    numGibbsSlider->setBounds (224, 408, 184, 24);
    reconstructEquButton->setBounds (24, 448, 72, 24);
    rbmDoRaoBlackwellToggleButton->setBounds (24, 200, 112, 24);
    rbmReduceVarianceToggleButton->setBounds (168, 200, 128, 24);
    lambdaLabel->setBounds (120, 320, 72, 24);
    sigmaLabel->setBounds (32, 320, 72, 24);
    rbmUseVisibleGaussianToggleButton->setBounds (168, 232, 160, 24);
    rbmDoSparseToggleButton->setBounds (24, 232, 128, 24);
    sparsityLabel->setBounds (208, 320, 72, 24);
    sigmaDecayLabel->setBounds (304, 320, 72, 24);
    weightDecayLabel->setBounds (304, 368, 72, 24);
    m_progressBarSlider->setBounds (216, 160, 184, 24);
    momentumLabel->setBounds (208, 368, 72, 24);
    sparsityLearningRateLabel->setBounds (416, 320, 72, 24);
    weightInitLabel->setBounds (416, 368, 72, 24);
    rbmTrainV2ToggleButton->setBounds (336, 200, 128, 24);
    //[UserResized] Add your own custom resize handling here..
    DrawTraining->setBounds (16, 16, 100, 100);
    DrawReconstruction->setBounds (110+16, 16, 100, 100);
    DrawWeights->setBounds (220+16, 16, 100, 100);
    DrawHidden->setBounds (16, 16+110, 320, 20);
    //[/UserResized]
}

void MainComponent::buttonClicked (Button* buttonThatWasClicked)
{
    //[UserbuttonClicked_Pre]
    //[/UserbuttonClicked_Pre]

    if (buttonThatWasClicked == trainButton)
    {
        //[UserButtonCode_trainButton] -- add your button handler code here..
    	startThread();
        //[/UserButtonCode_trainButton]
    }
    else if (buttonThatWasClicked == addButton)
    {
        //[UserButtonCode_addButton] -- add your button handler code here..
		DrawReconstruction->setData(DrawTraining->getData());
		m_layers.add(&DrawTraining->getData(), m_vNumX*m_vNumY);
		patterSlider->setRange (0, m_layers.getSize()-1, 1);
        //[/UserButtonCode_addButton]
    }
    else if (buttonThatWasClicked == reconstructButton)
    {
        //[UserButtonCode_reconstructButton] -- add your button handler code here..
    	redrawReconstruction();
        //[/UserButtonCode_reconstructButton]
    }
    else if (buttonThatWasClicked == ShakeButton)
    {
        //[UserButtonCode_ShakeButton] -- add your button handler code here..
    	m_weights.shuffle(weightInitLabel->getText().getFloatValue());
    	redrawReconstruction();
    	redrawWeights((int)WeightsSlider->getValue());
        //[/UserButtonCode_ShakeButton]
    }
    else if (buttonThatWasClicked == testButton)
    {
        //[UserButtonCode_testButton] -- add your button handler code here..
		DrawTraining->setData(DrawReconstruction->getData());
		redrawReconstruction();
        //[/UserButtonCode_testButton]
    }
    else if (buttonThatWasClicked == createButton)
    {
        //[UserButtonCode_createButton] -- add your button handler code here..
		m_vNumX = numVisibleLabel->getText().getIntValue();
		m_vNumY = numVisibleYLabel->getText().getIntValue();
		m_hNum = numHiddenLabel->getText().getIntValue();

		m_weights.setUnits(m_vNumX*m_vNumY, m_hNum);
		create();
        //[/UserButtonCode_createButton]
    }
    else if (buttonThatWasClicked == loadButton)
    {
        //[UserButtonCode_loadButton] -- add your button handler code here..
		load();
		redrawReconstruction();
    	redrawWeights((int)WeightsSlider->getValue());
        //[/UserButtonCode_loadButton]
    }
    else if (buttonThatWasClicked == saveButton)
    {
        //[UserButtonCode_saveButton] -- add your button handler code here..
		save();
        //[/UserButtonCode_saveButton]
    }
    else if (buttonThatWasClicked == loadTrainingButton)
    {
        //[UserButtonCode_loadTrainingButton] -- add your button handler code here..
		m_layers.clear();
		m_layers.load((String(getBaseDir() + String(".trainingStates.dat"))).toUTF8());
		redrawReconstruction();
        //[/UserButtonCode_loadTrainingButton]
    }
    else if (buttonThatWasClicked == saveTrainingButton)
    {
        //[UserButtonCode_saveTrainingButton] -- add your button handler code here..
		m_layers.save((String(getBaseDir() + String(".trainingStates.dat"))).toUTF8());
        //[/UserButtonCode_saveTrainingButton]
    }
    else if (buttonThatWasClicked == clearTrainingButton)
    {
        //[UserButtonCode_clearTrainingButton] -- add your button handler code here..
		m_layers.clear();
        //[/UserButtonCode_clearTrainingButton]
    }
    else if (buttonThatWasClicked == removeTrainingButton)
    {
        //[UserButtonCode_removeTrainingButton] -- add your button handler code here..
		m_layers.removeAt((int)patterSlider->getValue());
        //[/UserButtonCode_removeTrainingButton]
    }
    else if (buttonThatWasClicked == reconstructEquButton)
    {
        //[UserButtonCode_reconstructEquButton] -- add your button handler code here..
    	uint32_t i;
    	VectorXd V, H;

    	V = DrawTraining->getData();
    	for (i=0; i < 100; i++)
    	{
        	H = m_pRbm->toHidden(V);
        	DrawHidden->setData(H);
        	V = m_pRbm->toVisible(H);
    		DrawReconstruction->setData(V);
    	}
        //[/UserButtonCode_reconstructEquButton]
    }
    else if (buttonThatWasClicked == rbmDoRaoBlackwellToggleButton)
    {
        //[UserButtonCode_rbmDoRaoBlackwellToggleButton] -- add your button handler code here..
    	m_pRbm->setDoRaoBlackwell(buttonThatWasClicked->getToggleState());
        //[/UserButtonCode_rbmDoRaoBlackwellToggleButton]
    }
    else if (buttonThatWasClicked == rbmReduceVarianceToggleButton)
    {
        //[UserButtonCode_rbmReduceVarianceToggleButton] -- add your button handler code here..
    	m_pRbm->setUseProbsForHiddenReconstruction(buttonThatWasClicked->getToggleState());
        //[/UserButtonCode_rbmReduceVarianceToggleButton]
    }
    else if (buttonThatWasClicked == rbmUseVisibleGaussianToggleButton)
    {
        //[UserButtonCode_rbmUseVisibleGaussianToggleButton] -- add your button handler code here..
    	m_pRbm->setUseVisibleGaussian(buttonThatWasClicked->getToggleState());
   		rbmReduceVarianceToggleButton->setEnabled(!buttonThatWasClicked->getToggleState());

   		if (buttonThatWasClicked->getToggleState())
   		{
   	    	rbmReduceVarianceToggleButton_binary = rbmReduceVarianceToggleButton->getToggleState();
   			rbmReduceVarianceToggleButton->setToggleState(false, sendNotification);
   			sigmaLabel->setText(String(sigma_gauss, 2), sendNotification);
			sigmaDecayLabel->setText(String(sigmaDecay_gauss, 2), sendNotification);
   		}
   		else
   		{
   			sigma_gauss = sigmaLabel->getText().getFloatValue();
   			sigmaDecay_gauss = sigmaDecayLabel->getText().getFloatValue();
   			sigmaLabel->setText("1.0", sendNotification);
			sigmaDecayLabel->setText("1.0", sendNotification);
   			rbmReduceVarianceToggleButton->setToggleState(rbmReduceVarianceToggleButton_binary, sendNotification);
   		}
    	redrawReconstruction();
        //[/UserButtonCode_rbmUseVisibleGaussianToggleButton]
    }
    else if (buttonThatWasClicked == rbmDoSparseToggleButton)
    {
        //[UserButtonCode_rbmDoSparseToggleButton] -- add your button handler code here..
    	m_pRbm->setDoSparse(buttonThatWasClicked->getToggleState());
        //[/UserButtonCode_rbmDoSparseToggleButton]
    }
    else if (buttonThatWasClicked == rbmTrainV2ToggleButton)
    {
        //[UserButtonCode_rbmTrainV2ToggleButton] -- add your button handler code here..
        //[/UserButtonCode_rbmTrainV2ToggleButton]
    }

    //[UserbuttonClicked_Post]
    //[/UserbuttonClicked_Post]
}

void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
{
    //[UsersliderValueChanged_Pre]
    //[/UsersliderValueChanged_Pre]

    if (sliderThatWasMoved == patterSlider)
    {
        //[UserSliderCode_patterSlider] -- add your slider handling code here..
		if (m_layers.getSize() > 0)
		{
			VisibleLayer &p = (VisibleLayer&)m_layers.getAt((int)sliderThatWasMoved->getValue());
			DrawTraining->setData(p.states());
			redrawReconstruction();

		}
        //[/UserSliderCode_patterSlider]
    }
    else if (sliderThatWasMoved == WeightsSlider)
    {
        //[UserSliderCode_WeightsSlider] -- add your slider handling code here..
    	redrawWeights((int)sliderThatWasMoved->getValue());
        //[/UserSliderCode_WeightsSlider]
    }
    else if (sliderThatWasMoved == numGibbsSlider)
    {
        //[UserSliderCode_numGibbsSlider] -- add your slider handling code here..
    	m_pRbm->setNumGibbs((uint32_t)sliderThatWasMoved->getValue());
        //[/UserSliderCode_numGibbsSlider]
    }
    else if (sliderThatWasMoved == m_progressBarSlider)
    {
        //[UserSliderCode_m_progressBarSlider] -- add your slider handling code here..
        //[/UserSliderCode_m_progressBarSlider]
    }

    //[UsersliderValueChanged_Post]
    //[/UsersliderValueChanged_Post]
}

void MainComponent::labelTextChanged (Label* labelThatHasChanged)
{
    //[UserlabelTextChanged_Pre]
    //[/UserlabelTextChanged_Pre]

    if (labelThatHasChanged == numEpochslabel)
    {
        //[UserLabelCode_numEpochslabel] -- add your label text handling code here..
        //[/UserLabelCode_numEpochslabel]
    }
    else if (labelThatHasChanged == learningRateLabel)
    {
        //[UserLabelCode_learningRateLabel] -- add your label text handling code here..
    	m_pRbm->setMuWeights(labelThatHasChanged->getText().getFloatValue());
        //[/UserLabelCode_learningRateLabel]
    }
    else if (labelThatHasChanged == numVisibleLabel)
    {
        //[UserLabelCode_numVisibleLabel] -- add your label text handling code here..
        //[/UserLabelCode_numVisibleLabel]
    }
    else if (labelThatHasChanged == numHiddenLabel)
    {
        //[UserLabelCode_numHiddenLabel] -- add your label text handling code here..
        //[/UserLabelCode_numHiddenLabel]
    }
    else if (labelThatHasChanged == projectNameLabel)
    {
        //[UserLabelCode_projectNameLabel] -- add your label text handling code here..
        //[/UserLabelCode_projectNameLabel]
    }
    else if (labelThatHasChanged == numVisibleYLabel)
    {
        //[UserLabelCode_numVisibleYLabel] -- add your label text handling code here..
        //[/UserLabelCode_numVisibleYLabel]
    }
    else if (labelThatHasChanged == lambdaLabel)
    {
        //[UserLabelCode_lambdaLabel] -- add your label text handling code here..
    	m_pRbm->setLambda(labelThatHasChanged->getText().getFloatValue());
    	redrawReconstruction();
        //[/UserLabelCode_lambdaLabel]
    }
    else if (labelThatHasChanged == sigmaLabel)
    {
        //[UserLabelCode_sigmaLabel] -- add your label text handling code here..
    	m_pRbm->setSigma(labelThatHasChanged->getText().getFloatValue());
    	redrawReconstruction();
        //[/UserLabelCode_sigmaLabel]
    }
    else if (labelThatHasChanged == sparsityLabel)
    {
        //[UserLabelCode_sparsityLabel] -- add your label text handling code here..
    	m_pRbm->setSparsity(labelThatHasChanged->getText().getFloatValue());
        //[/UserLabelCode_sparsityLabel]
    }
    else if (labelThatHasChanged == sigmaDecayLabel)
    {
        //[UserLabelCode_sigmaDecayLabel] -- add your label text handling code here..
    	m_pRbm->setSigmaDecay(labelThatHasChanged->getText().getFloatValue());
        //[/UserLabelCode_sigmaDecayLabel]
    }
    else if (labelThatHasChanged == weightDecayLabel)
    {
        //[UserLabelCode_weightDecayLabel] -- add your label text handling code here..
    	m_pRbm->setWeightDecay(labelThatHasChanged->getText().getFloatValue());
        //[/UserLabelCode_weightDecayLabel]
    }
    else if (labelThatHasChanged == momentumLabel)
    {
        //[UserLabelCode_momentumLabel] -- add your label text handling code here..
    	m_pRbm->setMomentum(labelThatHasChanged->getText().getFloatValue());
        //[/UserLabelCode_momentumLabel]
    }
    else if (labelThatHasChanged == sparsityLearningRateLabel)
    {
        //[UserLabelCode_sparsityLearningRateLabel] -- add your label text handling code here..
    	m_pRbm->setMuSparsity(labelThatHasChanged->getText().getFloatValue());
        //[/UserLabelCode_sparsityLearningRateLabel]
    }
    else if (labelThatHasChanged == weightInitLabel)
    {
        //[UserLabelCode_weightInitLabel] -- add your label text handling code here..
        //[/UserLabelCode_weightInitLabel]
    }

    //[UserlabelTextChanged_Post]
    //[/UserlabelTextChanged_Post]
}



//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
void MainComponent::load ()
{
	m_weights.load((String(getBaseDir() + String(".weights.dat"))).toUTF8());

	m_vNumX = m_vNumY = (int)sqrt((float)m_weights.getNumVisible());
	m_hNum = m_weights.getNumHidden();
	create();
}

void MainComponent::save ()
{
	m_weights.save((String(getBaseDir() + String(".weights.dat"))).toUTF8());
}

void MainComponent::create()
{
	DrawTraining = nullptr;
	DrawReconstruction = nullptr;
	DrawWeights = nullptr;
	DrawHidden = nullptr;

	WeightsSlider->setRange(0, m_hNum-1, 1);

	addAndMakeVisible (DrawTraining = new DrawComponent (m_vNumX, m_vNumY));
	DrawTraining->setListener(this);
    addAndMakeVisible (DrawReconstruction = new DrawComponent (m_vNumX, m_vNumY));
    addAndMakeVisible (DrawWeights = new DrawComponent (m_vNumX, m_vNumY));
    addAndMakeVisible (DrawHidden = new DrawComponent (m_hNum, 1));
	DrawHidden->setListener(this);
	numVisibleLabel->setText(String(m_vNumX), dontSendNotification );
	numVisibleYLabel->setText(String(m_vNumY), dontSendNotification );
	numHiddenLabel->setText(String(m_hNum), dontSendNotification );

	sigma_gauss = 0.5;
	sigmaDecay_gauss = 1.0;
	m_pRbm->setDoRaoBlackwell(rbmDoRaoBlackwellToggleButton->getToggleState());
	m_pRbm->setUseProbsForHiddenReconstruction(rbmReduceVarianceToggleButton->getToggleState());
	m_pRbm->setUseVisibleGaussian(rbmUseVisibleGaussianToggleButton->getToggleState());
	m_pRbm->setDoSparse(rbmDoSparseToggleButton->getToggleState());

	m_pRbm->setLambda(lambdaLabel->getText().getFloatValue());
	m_pRbm->setSigma(sigmaLabel->getText().getFloatValue());
	m_pRbm->setSigmaDecay(sigmaDecayLabel->getText().getFloatValue());
	m_pRbm->setWeightDecay(weightDecayLabel->getText().getFloatValue());
	m_pRbm->setSparsity(sparsityLabel->getText().getFloatValue());
	m_pRbm->setNumGibbs((uint32_t)numGibbsSlider->getValue());


	resized();
}

void MainComponent::destroy()
{
}

const juce::String& MainComponent::getBaseDir()
{
	m_baseDir = String("./") + projectNameLabel->getText();

	return m_baseDir;

}

void MainComponent::onChanged(const LayerArray<VisibleLayer> &obj)
{
	patterSlider->setRange(0, std::max(0,(int)m_layers.getSize()-1), 1);
}

void MainComponent::onEpochTrained(const Rbm &obj)
{
//	mylog("Training %f %%\n", obj.getProgress()*100);
	redrawReconstruction();
	redrawWeights((int)WeightsSlider->getValue());
	m_progressBarSlider->setValue((int)(100*obj.getProgress()), dontSendNotification);
}

void MainComponent::onDraw(DrawComponent &obj)
{
	if (&obj == DrawHidden)
	{
		DrawReconstruction->setData(m_pRbm->toVisible(obj.getData()));
	}
	if (&obj == DrawTraining)
	{
		DrawReconstruction->setData(m_pRbm->toVisible(m_pRbm->toHidden(obj.getData())));
    	DrawHidden->setData(m_pRbm->toHidden(obj.getData()));
	}
}

void MainComponent::redrawReconstruction()
{
	DrawHidden->setData(m_pRbm->toHidden(DrawTraining->getData()));
	DrawReconstruction->setData(m_pRbm->toVisible(DrawHidden->getData()));
//	double energy = m_pRbm->getEnergy(DrawTraining->getData(), DrawHidden->getData());
//	cout << "Energy(" << 0 <<") = " << energy << endl;

}

void MainComponent::redrawWeights(int index)
{
	VectorXd w = m_weights.weights().col(index);
	DrawWeights->setData(w);
}

void MainComponent::run()
{
	trainButton->setEnabled(false);
	if (rbmTrainV2ToggleButton->getToggleState())
	{
		m_pRbm->train2(m_layers, numEpochslabel->getText().getIntValue(), 100);
	}
	else
	{
		m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue());
	}
	trainButton->setEnabled(true);
}

//[/MiscUserCode]


//==============================================================================
#if 0
/*  -- Introjucer information section --

    This is where the Introjucer stores the metadata that describe this GUI layout, so
    make changes in here at your peril!

BEGIN_JUCER_METADATA

<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
                 parentClasses="public Component, public LayerArrayListener&lt;VisibleLayer&gt;, public RbmListener, public DrawListener, public Thread"
                 constructorParams="" variableInitialisers="Thread(&quot;RBM&quot;),&#10;m_layers(this),&#10;m_pRbm(nullptr)&#10;DrawTraining(nullptr),&#10;DrawReconstruction(nullptr),&#10;DrawWeights(nullptr),&#10;DrawHidden(nullptr)"
                 snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
                 fixedSize="1" initialWidth="800" initialHeight="600">
  <BACKGROUND backgroundColour="ffffffff">
    <TEXT pos="32 306 80 14" fill="solid: ff000000" hasStroke="0" text="Sigma"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="120 306 80 14" fill="solid: ff000000" hasStroke="0" text="Lambda"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="32 354 80 14" fill="solid: ff000000" hasStroke="0" text="Num. epochs"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="120 354 80 14" fill="solid: ff000000" hasStroke="0" text="Alpha"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="208 306 80 14" fill="solid: ff000000" hasStroke="0" text="Sparsity"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="296 306 96 14" fill="solid: ff000000" hasStroke="0" text="Sigma decay"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="296 354 96 14" fill="solid: ff000000" hasStroke="0" text="Weight decay"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="208 354 80 14" fill="solid: ff000000" hasStroke="0" text="Momentum"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="408 306 96 14" fill="solid: ff000000" hasStroke="0" text="Sparsity Alpha"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
    <TEXT pos="408 354 96 14" fill="solid: ff000000" hasStroke="0" text="Weight init"
          fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
  </BACKGROUND>
  <TEXTBUTTON name="Train button" id="7909d74b5522987c" memberName="trainButton"
              virtualName="" explicitFocusOrder="0" pos="120 408 72 24" buttonText="Train"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <TEXTBUTTON name="Add button" id="4609f7b526ec1aef" memberName="addButton"
              virtualName="" explicitFocusOrder="0" pos="24 160 72 24" buttonText="Add"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <SLIDER name="Pattern slider" id="c3e0a2c816db81d1" memberName="patterSlider"
          virtualName="" explicitFocusOrder="0" pos="224 448 184 24" min="0"
          max="0" int="1" style="LinearBar" textBoxPos="TextBoxLeft" textBoxEditable="1"
          textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
  <TEXTBUTTON name="Reconstruct button" id="c1901d121a5819d6" memberName="reconstructButton"
              virtualName="" explicitFocusOrder="0" pos="24 408 72 24" buttonText="Reconstruct"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <TEXTBUTTON name="Shake button" id="7fa4964a9a9ed199" memberName="ShakeButton"
              virtualName="" explicitFocusOrder="0" pos="120 448 72 24" buttonText="Shake"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <SLIDER name="Weights slider" id="699075a1fc01458a" memberName="WeightsSlider"
          virtualName="" explicitFocusOrder="0" pos="224 488 184 24" min="0"
          max="0" int="1" style="LinearBar" textBoxPos="TextBoxLeft" textBoxEditable="1"
          textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
  <LABEL name="Num Epochs label" id="b23ae372ee931474" memberName="numEpochslabel"
         virtualName="" explicitFocusOrder="0" pos="32 368 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="100" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <LABEL name="Learning Rate label" id="49611a27914e910d" memberName="learningRateLabel"
         virtualName="" explicitFocusOrder="0" pos="120 368 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="0.01" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <TEXTBUTTON name="Test button" id="a1e6fed732ae7ee1" memberName="testButton"
              virtualName="" explicitFocusOrder="0" pos="120 160 72 24" buttonText="Test"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <LABEL name="Num Visible label" id="60acd702770b77dd" memberName="numVisibleLabel"
         virtualName="" explicitFocusOrder="0" pos="504 224 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="99999" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <LABEL name="Num Hidden label" id="8a56c0419bd3ce86" memberName="numHiddenLabel"
         virtualName="" explicitFocusOrder="0" pos="552 256 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="99999" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <TEXTBUTTON name="Create button" id="6c71593a581844eb" memberName="createButton"
              virtualName="" explicitFocusOrder="0" pos="552 288 72 24" buttonText="Create"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <LABEL name="Project Name label" id="b4e855167abdac6b" memberName="projectNameLabel"
         virtualName="" explicitFocusOrder="0" pos="536 192 96 24" edTextCol="ff000000"
         edBkgCol="0" labelText="TestPrj" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <TEXTBUTTON name="Load button" id="4e606c77b12e7d11" memberName="loadButton"
              virtualName="" explicitFocusOrder="0" pos="504 160 72 24" buttonText="Load"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <TEXTBUTTON name="Save button" id="c435e774a51e39bf" memberName="saveButton"
              virtualName="" explicitFocusOrder="0" pos="584 160 72 24" buttonText="Save"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <LABEL name="Num Visible Y label" id="101a4f77ca2445ba" memberName="numVisibleYLabel"
         virtualName="" explicitFocusOrder="0" pos="576 224 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="99999" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <TEXTBUTTON name="Load Training button" id="c603a32c128de05d" memberName="loadTrainingButton"
              virtualName="" explicitFocusOrder="0" pos="504 48 72 24" buttonText="Load T"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <TEXTBUTTON name="Save Training button" id="8e665b97490357c4" memberName="saveTrainingButton"
              virtualName="" explicitFocusOrder="0" pos="584 48 72 24" buttonText="Save T"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <TEXTBUTTON name="Clear Training button" id="b4c148828519c013" memberName="clearTrainingButton"
              virtualName="" explicitFocusOrder="0" pos="584 88 72 24" buttonText="Clear T"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <TEXTBUTTON name="Remove Training button" id="f0e1d068c39986f3" memberName="removeTrainingButton"
              virtualName="" explicitFocusOrder="0" pos="504 88 72 24" buttonText="Remove T"
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <SLIDER name="Num. Gibbs slider" id="fdd9d5ca4e05e18c" memberName="numGibbsSlider"
          virtualName="" explicitFocusOrder="0" pos="224 408 184 24" min="1"
          max="101" int="1" style="LinearBar" textBoxPos="TextBoxLeft"
          textBoxEditable="1" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
  <TEXTBUTTON name="Reconstruct Equilibrium button" id="208a587f5556207" memberName="reconstructEquButton"
              virtualName="" explicitFocusOrder="0" pos="24 448 72 24" buttonText="Reconst Equ."
              connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  <TOGGLEBUTTON name="rbmDoRaoBlackwell toggle button" id="7f585de46e182418"
                memberName="rbmDoRaoBlackwellToggleButton" virtualName="" explicitFocusOrder="0"
                pos="24 200 112 24" buttonText="Rao-Blackwell" connectedEdges="0"
                needsCallback="1" radioGroupId="0" state="0"/>
  <TOGGLEBUTTON name="rbmReduceVariance toggle button" id="1636f6389abe9225"
                memberName="rbmReduceVarianceToggleButton" virtualName="" explicitFocusOrder="0"
                pos="168 200 128 24" buttonText="Reduce Variance" connectedEdges="0"
                needsCallback="1" radioGroupId="0" state="0"/>
  <LABEL name="Lambda label" id="c51a5dfb587390b4" memberName="lambdaLabel"
         virtualName="" explicitFocusOrder="0" pos="120 320 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="1.0" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <LABEL name="Sigma label" id="68d7dad32ed357f8" memberName="sigmaLabel"
         virtualName="" explicitFocusOrder="0" pos="32 320 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="1.0" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <TOGGLEBUTTON name="rbmUseVisibleGaussian toggle button" id="c89b32a4deaa7f19"
                memberName="rbmUseVisibleGaussianToggleButton" virtualName=""
                explicitFocusOrder="0" pos="168 232 160 24" buttonText="Use gaussian visible"
                connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
  <TOGGLEBUTTON name="rbmDoSparse toggle button" id="ed3f2602ab35b5f2" memberName="rbmDoSparseToggleButton"
                virtualName="" explicitFocusOrder="0" pos="24 232 128 24" buttonText="Do sparse"
                connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
  <LABEL name="Sparsity label" id="f4efe44dc0ca4894" memberName="sparsityLabel"
         virtualName="" explicitFocusOrder="0" pos="208 320 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="0.05" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <LABEL name="SigmaDecay label" id="d5f2f5fffdafd926" memberName="sigmaDecayLabel"
         virtualName="" explicitFocusOrder="0" pos="304 320 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="1.0" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <LABEL name="WeightDecay label" id="67bf3a0bec436468" memberName="weightDecayLabel"
         virtualName="" explicitFocusOrder="0" pos="304 368 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="0.0" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <SLIDER name="progressBar slider" id="8c8748f39f6d0ec6" memberName="m_progressBarSlider"
          virtualName="" explicitFocusOrder="0" pos="216 160 184 24" min="0"
          max="100" int="1" style="LinearBar" textBoxPos="TextBoxLeft"
          textBoxEditable="0" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
  <LABEL name="Momentum label" id="570ca1355ccd4cdd" memberName="momentumLabel"
         virtualName="" explicitFocusOrder="0" pos="208 368 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="0.5" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <LABEL name="SparsityLearn label" id="8e452129810c0ed3" memberName="sparsityLearningRateLabel"
         virtualName="" explicitFocusOrder="0" pos="416 320 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="0.01" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <LABEL name="WeightInit label" id="c827025f2cc51ddf" memberName="weightInitLabel"
         virtualName="" explicitFocusOrder="0" pos="416 368 72 24" edTextCol="ff000000"
         edBkgCol="0" labelText="0.001" editableSingleClick="1" editableDoubleClick="1"
         focusDiscardsChanges="0" fontname="Default font" fontsize="15"
         bold="0" italic="0" justification="36"/>
  <TOGGLEBUTTON name="rbmTrainV2ToggleButton toggle button" id="92c647c1f8b110a2"
                memberName="rbmTrainV2ToggleButton" virtualName="" explicitFocusOrder="0"
                pos="336 200 128 24" buttonText="Train Ver. 2" connectedEdges="0"
                needsCallback="1" radioGroupId="0" state="0"/>
</JUCER_COMPONENT>

END_JUCER_METADATA
*/
#endif


//[EndFile] You can add extra defines here...
//[/EndFile]
