- added grayscale display

- reconstruction and hidden probs can be displayed

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@15 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-09-26 05:30:16 +00:00
parent 470437eecb
commit b1a0c90ea0
10 changed files with 216 additions and 194 deletions
+1 -60
View File
@@ -10,7 +10,6 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include "MainComponent.h"
#include "Rbm.hpp"
//==============================================================================
class RBMApplication : public JUCEApplication
@@ -19,7 +18,6 @@ public:
//==============================================================================
RBMApplication()
: mainWindow(nullptr)
, m_pRbm(nullptr)
{
}
@@ -31,70 +29,14 @@ public:
//==============================================================================
void initialise (const String& commandLine) override
{
double trainingData[6][16] =
{
{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1},
{0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1},
{1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}
};
double hiddenTest[16][4] =
{
{0, 0, 0, 0},
{0, 0, 0, 1},
{0, 0, 1, 0},
{0, 0, 1, 1},
{0, 1, 0, 0},
{0, 1, 0, 1},
{0, 1, 1, 0},
{0, 1, 1, 1},
{1, 0, 0, 0},
{1, 0, 0, 1},
{1, 0, 1, 0},
{1, 0, 1, 1},
{1, 1, 0, 0},
{1, 1, 0, 1},
{1, 1, 1, 0},
{1, 1, 1, 1}
};
// Add your application's initialisation code here..
m_pRbm = new Rbm(16, 4);
// mainWindow = new MainWindow;
m_pRbm->weightsShuffle(0.01);
m_pRbm->setNumTrainingPatterns(6);
for (uint32_t i=0; i < 6; i++)
{
m_pRbm->setTrainingInput(i, trainingData[i]);
}
m_pRbm->train(10000, 0.2);
m_pRbm->prob();
/*
m_pRbm->weightsPrint();
// Test the network
for (uint32_t i=0; i < 6; i++)
{
m_pRbm->toHidden(trainingData[i]);
}
for (uint32_t i=0; i < 16; i++)
{
m_pRbm->toVisible(hiddenTest[i]);
}
*/
mainWindow = new MainWindow;
}
void shutdown() override
{
// Add your application's shutdown code here..
mainWindow = nullptr; // (deletes our window)
m_pRbm = nullptr;
}
//==============================================================================
@@ -151,7 +93,6 @@ public:
private:
ScopedPointer<MainWindow> mainWindow;
ScopedPointer<Rbm> m_pRbm;
};