- 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:
@@ -51,6 +51,7 @@ ifeq ($(CONFIG),Release)
|
||||
endif
|
||||
|
||||
OBJECTS := \
|
||||
$(OBJDIR)/DrawComponent_eda766fa.o \
|
||||
$(OBJDIR)/noise_3051d25b.o \
|
||||
$(OBJDIR)/MainComponent_a6ffb4a5.o \
|
||||
$(OBJDIR)/Main_90ebc5c2.o \
|
||||
@@ -85,6 +86,11 @@ strip:
|
||||
@echo Stripping RBM
|
||||
-@strip --strip-unneeded $(OUTDIR)/$(TARGET)
|
||||
|
||||
$(OBJDIR)/DrawComponent_eda766fa.o: ../../Source/DrawComponent.cpp
|
||||
-@mkdir -p $(OBJDIR)
|
||||
@echo "Compiling DrawComponent.cpp"
|
||||
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
|
||||
|
||||
$(OBJDIR)/noise_3051d25b.o: ../../Source/noise.c
|
||||
-@mkdir -p $(OBJDIR)
|
||||
@echo "Compiling noise.c"
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
includeBinaryInAppConfig="1" jucerVersion="3.1.0">
|
||||
<MAINGROUP id="hrLNxO" name="RBM">
|
||||
<GROUP id="{0B901282-EB61-03B7-A07A-9BAA374DBACA}" name="Source">
|
||||
<FILE id="C5LCke" name="DrawComponent.cpp" compile="1" resource="0"
|
||||
file="Source/DrawComponent.cpp"/>
|
||||
<FILE id="ulqEkU" name="DrawComponent.h" compile="0" resource="0" file="Source/DrawComponent.h"/>
|
||||
<FILE id="vWUgBu" name="Layer.hpp" compile="0" resource="0" file="Source/Layer.hpp"/>
|
||||
<FILE id="pDF4Vt" name="noise.h" compile="0" resource="0" file="Source/noise.h"/>
|
||||
<FILE id="yHwJFK" name="noise.c" compile="1" resource="0" file="Source/noise.c"/>
|
||||
@@ -22,19 +25,19 @@
|
||||
targetName="RBM"/>
|
||||
</CONFIGURATIONS>
|
||||
<MODULEPATHS>
|
||||
<MODULEPATH id="juce_core" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_events" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_graphics" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_data_structures" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_gui_basics" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_cryptography" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_video" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_opengl" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_basics" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_devices" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_formats" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_processors" path="../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_core" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_events" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_graphics" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_data_structures" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_gui_basics" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_cryptography" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_video" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_opengl" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_basics" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_devices" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_formats" path="../../../../../../JUCE/modules"/>
|
||||
<MODULEPATH id="juce_audio_processors" path="../../../../../../JUCE/modules"/>
|
||||
</MODULEPATHS>
|
||||
</LINUX_MAKE>
|
||||
</EXPORTFORMATS>
|
||||
|
||||
+19
-17
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="0.10692699">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.10692699" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<cconfiguration id="0.1854593711">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1854593711" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
@@ -15,27 +15,26 @@
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.10692699" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.10692699." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2087661599" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.eclipse.cdt.build.core.prefbase.toolchain.2087661599.1142336933" name=""/>
|
||||
<builder autoBuildTarget="" buildPath="/home/jens/work/RBM/Builds/Linux" command="" enableAutoBuild="false" enableCleanBuild="false" enabledIncrementalBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.1283324089" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1278010779" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.62358562" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.875592394" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1854593711" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.1854593711." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2006039765" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.eclipse.cdt.build.core.prefbase.toolchain.2006039765.1599815985" name=""/>
|
||||
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1820544125" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.750397548" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.906730718" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1467109729" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.751305630" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1332004879" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1370151108" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1834882069" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.447702799" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1580487548" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.280954803" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1317583303" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="JuceLibraryCode|modules" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="JuceLibraryCode" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="JuceLibraryCode"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="modules"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
@@ -43,10 +42,13 @@
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="RBM.null.1518814991" name="RBM"/>
|
||||
<project id="RBM.null.244565344" name="RBM"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="0.1854593711">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="0.10692699">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers></triggers>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
@@ -28,7 +28,7 @@
|
||||
<link>
|
||||
<name>JuceLibraryCode</name>
|
||||
<type>2</type>
|
||||
<location>/home/jens/work/RBM/JuceLibraryCode</location>
|
||||
<location>/home/jens/work/repos/software/trunk/projects/RBM/JuceLibraryCode</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>modules</name>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="0.10692699" name="Default">
|
||||
<configuration id="0.1854593711" name="Default">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector"/>
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/>
|
||||
</extension>
|
||||
|
||||
+1
-60
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -34,12 +34,14 @@ MainComponent::MainComponent ()
|
||||
|
||||
|
||||
//[UserPreSize]
|
||||
addAndMakeVisible (Draw = new DrawComponent (4, 4, 32));
|
||||
//[/UserPreSize]
|
||||
|
||||
setSize (600, 400);
|
||||
|
||||
|
||||
//[Constructor] You can add your own custom stuff here..
|
||||
m_pRbm = new Rbm(16, 4);
|
||||
//[/Constructor]
|
||||
}
|
||||
|
||||
@@ -52,6 +54,8 @@ MainComponent::~MainComponent()
|
||||
|
||||
|
||||
//[Destructor]. You can add your own custom destruction code here..
|
||||
Draw = nullptr;
|
||||
m_pRbm = nullptr;
|
||||
//[/Destructor]
|
||||
}
|
||||
|
||||
@@ -69,20 +73,77 @@ void MainComponent::paint (Graphics& g)
|
||||
|
||||
void MainComponent::resized()
|
||||
{
|
||||
textButton->setBounds (88, 96, 150, 24);
|
||||
textButton->setBounds (72, 312, 150, 24);
|
||||
//[UserResized] Add your own custom resize handling here..
|
||||
Draw->setBounds (16, 16, 336, 232);
|
||||
//[/UserResized]
|
||||
}
|
||||
|
||||
void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
{
|
||||
//[UserbuttonClicked_Pre]
|
||||
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}
|
||||
};
|
||||
//[/UserbuttonClicked_Pre]
|
||||
|
||||
if (buttonThatWasClicked == textButton)
|
||||
{
|
||||
//[UserButtonCode_textButton] -- add your button handler code here..
|
||||
//[/UserButtonCode_textButton]
|
||||
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();
|
||||
|
||||
// Draw->drawGray(m_pRbm->toVisible(m_pRbm->toHidden(trainingData[rand()%6])));
|
||||
Draw->drawGray(m_pRbm->toVisible(hiddenTest[rand()%16]));
|
||||
|
||||
#if 0
|
||||
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]);
|
||||
}
|
||||
#endif
|
||||
|
||||
//[/UserButtonCode_textButton]
|
||||
}
|
||||
|
||||
//[UserbuttonClicked_Post]
|
||||
@@ -107,11 +168,14 @@ BEGIN_JUCER_METADATA
|
||||
<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
|
||||
parentClasses="public Component" constructorParams="" variableInitialisers=""
|
||||
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
|
||||
fixedSize="0" initialWidth="600" initialHeight="400">
|
||||
fixedSize="1" initialWidth="600" initialHeight="400">
|
||||
<BACKGROUND backgroundColour="ffffffff"/>
|
||||
<TEXTBUTTON name="new button" id="7909d74b5522987c" memberName="textButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="88 96 150 24" buttonText="new button"
|
||||
virtualName="" explicitFocusOrder="0" pos="72 312 150 24" buttonText="new button"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<JUCERCOMP name="" id="5843cf32f5b9956c" memberName="Draw" virtualName=""
|
||||
explicitFocusOrder="0" pos="16 16 336 232" sourceFile="DrawComponent.cpp"
|
||||
constructorParams="200, 200, 2"/>
|
||||
</JUCER_COMPONENT>
|
||||
|
||||
END_JUCER_METADATA
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
|
||||
//[Headers] -- You can add your own extra header files here --
|
||||
#include "JuceHeader.h"
|
||||
#include "Rbm.hpp"
|
||||
//[/Headers]
|
||||
|
||||
#include "DrawComponent.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@@ -54,6 +56,8 @@ public:
|
||||
|
||||
private:
|
||||
//[UserVariables] -- You can add your own custom variables in this section.
|
||||
ScopedPointer<Rbm> m_pRbm;
|
||||
ScopedPointer<DrawComponent> Draw;
|
||||
//[/UserVariables]
|
||||
|
||||
//==============================================================================
|
||||
|
||||
+20
-17
@@ -96,6 +96,8 @@ class Rbm
|
||||
public:
|
||||
Rbm(uint32_t numVisible, uint32_t numHidden)
|
||||
: m_w(numVisible, numHidden)
|
||||
, tv(numVisible)
|
||||
, th(numHidden)
|
||||
, m_numVisible(numVisible)
|
||||
, m_numHidden(numHidden)
|
||||
, m_numTrainingPatterns(0)
|
||||
@@ -313,48 +315,44 @@ public:
|
||||
delete [] h;
|
||||
}
|
||||
|
||||
void toHidden(const double *pVisible)
|
||||
const double* toHidden(const double *pVisible)
|
||||
{
|
||||
double p;
|
||||
uint32_t i;
|
||||
|
||||
VisibleLayer v(m_numVisible);
|
||||
HiddenLayer h(m_numHidden);
|
||||
tv.setInput(pVisible);
|
||||
tv.statesAssignfromInput();
|
||||
|
||||
v.setInput(pVisible);
|
||||
v.statesAssignfromInput();
|
||||
|
||||
h.probsUpdate(v, m_w);
|
||||
th.probsUpdate(tv, m_w);
|
||||
|
||||
printf("pi(t) = (pi^, v>)\n");
|
||||
for (i=0; i < m_numHidden; i++)
|
||||
{
|
||||
p = h.getProbs()[i];
|
||||
p = th.getProbs()[i];
|
||||
printf("%3.6f\n", p);
|
||||
}
|
||||
printf("\n");
|
||||
return th.getProbs();
|
||||
}
|
||||
|
||||
void toVisible(const double *pHidden)
|
||||
const double* toVisible(const double *pHidden)
|
||||
{
|
||||
double p;
|
||||
uint32_t i;
|
||||
|
||||
VisibleLayer v(m_numVisible);
|
||||
HiddenLayer h(m_numHidden);
|
||||
th.setInput(pHidden);
|
||||
th.statesAssignfromInput();
|
||||
|
||||
h.setInput(pHidden);
|
||||
h.statesAssignfromInput();
|
||||
|
||||
v.probsUpdate(h, m_w);
|
||||
tv.probsUpdate(th, m_w);
|
||||
|
||||
printf("pi(t) = (pi^, v>)\n");
|
||||
for (i=0; i < m_numVisible; i++)
|
||||
{
|
||||
p = v.getProbs()[i];
|
||||
p = tv.getProbs()[i];
|
||||
printf("%3.6f\n", p);
|
||||
}
|
||||
printf("\n");
|
||||
return tv.getProbs();
|
||||
}
|
||||
|
||||
void weightsPrint()
|
||||
@@ -367,9 +365,15 @@ public:
|
||||
m_w.shuffle(stdDev);
|
||||
}
|
||||
|
||||
double **getWeights()
|
||||
{
|
||||
return m_w.getWeights();
|
||||
}
|
||||
private:
|
||||
|
||||
Weights m_w;
|
||||
VisibleLayer tv;
|
||||
HiddenLayer th;
|
||||
uint32_t m_numVisible;
|
||||
uint32_t m_numHidden;
|
||||
uint32_t m_numTrainingPatterns;
|
||||
@@ -404,7 +408,6 @@ private:
|
||||
delete [] m_pVisibleTraining;
|
||||
m_pVisibleTraining = nullptr;
|
||||
}
|
||||
m_numTrainingPatterns = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
+79
-79
@@ -1,79 +1,79 @@
|
||||
// --------------------------------------------------------------
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "noise.h"
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// internal funcs
|
||||
// --------------------------------------------------------------
|
||||
#define PM_IA 16807
|
||||
#define PM_IM 2147483647
|
||||
#define PM_AM (1.0/PM_IM)
|
||||
#define PM_IQ 127773
|
||||
#define PM_IR 2836
|
||||
#define PM_MASK 123459876
|
||||
|
||||
// 'Minimal' random number generator of Park and Miller. Returns a uniform random deviate
|
||||
// between 0.0 and 1.0. Set or reset idum to any integer value (except the unlikely value MASK)
|
||||
// to initialize the sequence; idum must not be altered between calls for successive deviates in
|
||||
// a sequence.
|
||||
double ran0(long *idum)
|
||||
{
|
||||
long k;
|
||||
double ans;
|
||||
|
||||
*idum ^= PM_MASK; // XORing with MASK allows use of zero and other
|
||||
k=(*idum)/PM_IQ; // simple bit patterns for idum.
|
||||
*idum=PM_IA*(*idum-k*PM_IQ)-PM_IR *k; // Compute idum=(IA*idum) % IM without over-
|
||||
// flows by Schrage’s method.
|
||||
if (*idum < 0)
|
||||
*idum += PM_IM;
|
||||
|
||||
ans=PM_AM*(*idum); // Convert idumto a floating result.
|
||||
*idum ^= PM_MASK; // Unmask before return.
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Exported functions
|
||||
// --------------------------------------------------------------
|
||||
void Noise_Init(noise_gen_t *pObj, long seed)
|
||||
{
|
||||
pObj->state = seed;
|
||||
}
|
||||
|
||||
void Noise_Free(noise_gen_t *pObj)
|
||||
{
|
||||
}
|
||||
|
||||
double Noise_Uniform(noise_gen_t *pObj, double mu)
|
||||
{
|
||||
return ran0(&pObj->state) + mu -0.5;
|
||||
}
|
||||
|
||||
double Noise_Gaussian(noise_gen_t *pObj, double mu, double sigma)
|
||||
{
|
||||
double U1, U2, V1, V2, S, Y;
|
||||
|
||||
do
|
||||
{
|
||||
U1 = Noise_Uniform(pObj, 0.5); // U1=[0,1]
|
||||
U2 = Noise_Uniform(pObj, 0.5); // U2=[0,1]
|
||||
V1 = 2 * U1 - 1; // V1=[-1,1]
|
||||
V2 = 2 * U2 - 1; // V2=[-1,1]
|
||||
S = V1 * V1 + V2 * V2;
|
||||
|
||||
} while (S >= 1);
|
||||
|
||||
// X = sqrt(-2 * log(S) / S) * V1;
|
||||
Y = sqrt(-2 * log(S) / S) * V2;
|
||||
Y = mu + sigma*Y;
|
||||
|
||||
return Y;
|
||||
}
|
||||
// --------------------------------------------------------------
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "noise.h"
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// internal funcs
|
||||
// --------------------------------------------------------------
|
||||
#define PM_IA 16807
|
||||
#define PM_IM 2147483647
|
||||
#define PM_AM (1.0/PM_IM)
|
||||
#define PM_IQ 127773
|
||||
#define PM_IR 2836
|
||||
#define PM_MASK 123459876
|
||||
|
||||
// 'Minimal' random number generator of Park and Miller. Returns a uniform random deviate
|
||||
// between 0.0 and 1.0. Set or reset idum to any integer value (except the unlikely value MASK)
|
||||
// to initialize the sequence; idum must not be altered between calls for successive deviates in
|
||||
// a sequence.
|
||||
double ran0(long *idum)
|
||||
{
|
||||
long k;
|
||||
double ans;
|
||||
|
||||
*idum ^= PM_MASK; // XORing with MASK allows use of zero and other
|
||||
k=(*idum)/PM_IQ; // simple bit patterns for idum.
|
||||
*idum=PM_IA*(*idum-k*PM_IQ)-PM_IR *k; // Compute idum=(IA*idum) % IM without over-
|
||||
// flows by Schrage’s method.
|
||||
if (*idum < 0)
|
||||
*idum += PM_IM;
|
||||
|
||||
ans=PM_AM*(*idum); // Convert idumto a floating result.
|
||||
*idum ^= PM_MASK; // Unmask before return.
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Exported functions
|
||||
// --------------------------------------------------------------
|
||||
void Noise_Init(noise_gen_t *pObj, long seed)
|
||||
{
|
||||
pObj->state = seed;
|
||||
}
|
||||
|
||||
void Noise_Free(noise_gen_t *pObj)
|
||||
{
|
||||
}
|
||||
|
||||
double Noise_Uniform(noise_gen_t *pObj, double mu)
|
||||
{
|
||||
return ran0(&pObj->state) + mu -0.5;
|
||||
}
|
||||
|
||||
double Noise_Gaussian(noise_gen_t *pObj, double mu, double sigma)
|
||||
{
|
||||
double U1, U2, V1, V2, S, Y;
|
||||
|
||||
do
|
||||
{
|
||||
U1 = Noise_Uniform(pObj, 0.5); // U1=[0,1]
|
||||
U2 = Noise_Uniform(pObj, 0.5); // U2=[0,1]
|
||||
V1 = 2 * U1 - 1; // V1=[-1,1]
|
||||
V2 = 2 * U2 - 1; // V2=[-1,1]
|
||||
S = V1 * V1 + V2 * V2;
|
||||
|
||||
} while (S >= 1);
|
||||
|
||||
// X = sqrt(-2 * log(S) / S) * V1;
|
||||
Y = sqrt(-2 * log(S) / S) * V2;
|
||||
Y = mu + sigma*Y;
|
||||
|
||||
return Y;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user