- handle full path names
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@661 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -46,6 +46,7 @@ MainComponent::MainComponent (const String prjname)
|
||||
, m_trainingIndex(0)
|
||||
, m_weightIndex(0)
|
||||
, m_toolTipWindow(this)
|
||||
, m_file(prjname)
|
||||
{
|
||||
addAndMakeVisible (trainButton = new TextButton ("Train button"));
|
||||
trainButton->setButtonText (TRANS("Train"));
|
||||
@@ -116,7 +117,7 @@ MainComponent::MainComponent (const String prjname)
|
||||
createButton->addListener (this);
|
||||
|
||||
addAndMakeVisible (projectNameLabel = new Label ("Project Name label",
|
||||
prjname));
|
||||
m_file.getFileNameWithoutExtension()));
|
||||
projectNameLabel->setFont (Font (15.00f, Font::plain));
|
||||
projectNameLabel->setJustificationType (Justification::centred);
|
||||
projectNameLabel->setEditable (true, true, false);
|
||||
@@ -517,7 +518,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
int numHid = numHiddenLabel->getText().getIntValue();
|
||||
if (!m_stack)
|
||||
{
|
||||
m_stack = new Stack(std::string(projectNameLabel->getText().getCharPointer()));
|
||||
m_stack = new Stack(m_file.getParentDirectory().getFullPathName().toStdString(), std::string(projectNameLabel->getText().getCharPointer()));
|
||||
}
|
||||
m_stack->addLayer(onConstruct("Layer", next_index, numVisX, numVisY, numHid));
|
||||
m_rbmSelect->addItem(String(next_index), next_index+1);
|
||||
@@ -527,7 +528,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
else if (buttonThatWasClicked == loadButton)
|
||||
{
|
||||
//[UserButtonCode_loadButton] -- add your button handler code here..
|
||||
m_stack = new Stack(std::string(projectNameLabel->getText().getCharPointer()));
|
||||
m_stack = new Stack(m_file.getParentDirectory().getFullPathName().toStdString(), std::string(projectNameLabel->getText().getCharPointer()));
|
||||
m_stack->load(this);
|
||||
m_stack->loadWeights();
|
||||
m_rbmSelect->clear(dontSendNotification);
|
||||
|
||||
@@ -93,6 +93,8 @@ private:
|
||||
String m_baseDir;
|
||||
TooltipWindow m_toolTipWindow;
|
||||
bool m_doStop;
|
||||
juce::File m_file;
|
||||
|
||||
void clearTraining()
|
||||
{
|
||||
patterSlider->setRange(0, m_stack->numTraining()-1, 1);
|
||||
|
||||
+11
-9
@@ -15,14 +15,16 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
Stack::Stack(const std::string &name)
|
||||
: m_name(name)
|
||||
Stack::Stack(const std::string &dir, const std::string &name)
|
||||
: m_dir(dir)
|
||||
, m_name(name)
|
||||
, m_pLayers(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Stack::Stack(const Stack& orig)
|
||||
: m_name(orig.m_name)
|
||||
: m_dir(orig.m_dir)
|
||||
, m_name(orig.m_name)
|
||||
, m_pLayers(orig.m_pLayers)
|
||||
{
|
||||
}
|
||||
@@ -92,7 +94,7 @@ Layer* Stack::getLayer(size_t layerId) const
|
||||
bool Stack::load(LayerConstructor *pLayerConstructor)
|
||||
{
|
||||
std::cout << "Importing Project " << m_name << std::endl;
|
||||
ifstream ifs(m_name + string(".prj"));
|
||||
ifstream ifs(m_dir + "/" + m_name + string(".prj"));
|
||||
|
||||
Json::Reader reader;
|
||||
Json::Value project;
|
||||
@@ -132,7 +134,7 @@ bool Stack::load(LayerConstructor *pLayerConstructor)
|
||||
bool Stack::save()
|
||||
{
|
||||
std::cout << "Exporting Project " << m_name << std::endl;
|
||||
ofstream ofs(m_name + string(".prj"));
|
||||
ofstream ofs(m_dir + "/" + m_name + string(".prj"));
|
||||
|
||||
Json::StyledWriter writer;
|
||||
Json::Value project;
|
||||
@@ -167,7 +169,7 @@ bool Stack::loadWeights()
|
||||
Layer *pLayer = m_pLayers;
|
||||
while(pLayer)
|
||||
{
|
||||
if (!pLayer->loadWeights(m_name))
|
||||
if (!pLayer->loadWeights(m_dir + "/" + m_name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -181,7 +183,7 @@ bool Stack::saveWeights()
|
||||
Layer *pLayer = m_pLayers;
|
||||
while(pLayer)
|
||||
{
|
||||
if (!pLayer->saveWeights(m_name))
|
||||
if (!pLayer->saveWeights(m_dir + "/" + m_name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -227,7 +229,7 @@ size_t Stack::loadTraining(bool doNormalize)
|
||||
uint32_t numTraining = 0;
|
||||
uint32_t numVisible = 0;
|
||||
|
||||
std::string filename = m_name + ".training.dat";
|
||||
std::string filename = m_dir + "/" + m_name + ".training.dat";
|
||||
FILE *pFile = fopen(filename.c_str(), "r");
|
||||
|
||||
if (!pFile)
|
||||
@@ -273,7 +275,7 @@ size_t Stack::loadTraining(bool doNormalize)
|
||||
|
||||
size_t Stack::saveTraining()
|
||||
{
|
||||
std::string filename = m_name + ".training.dat";
|
||||
std::string filename = m_dir + "/" + m_name + ".training.dat";
|
||||
FILE *pFile = fopen(filename.c_str(), "w");
|
||||
|
||||
if (!pFile)
|
||||
|
||||
+2
-1
@@ -35,7 +35,7 @@ public:
|
||||
class Stack
|
||||
{
|
||||
public:
|
||||
Stack(const std::string &name);
|
||||
Stack(const std::string &dir, const std::string &name);
|
||||
Stack(const Stack& orig);
|
||||
virtual ~Stack();
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
arma::mat trainingData(Layer *pLayer);
|
||||
|
||||
private:
|
||||
std::string m_dir;
|
||||
std::string m_name;
|
||||
Layer *m_pLayers;
|
||||
arma::mat m_trainingData;
|
||||
|
||||
Reference in New Issue
Block a user