build 190809. load weights data file

This commit is contained in:
tmj-fstate
2019-08-09 23:49:41 +02:00
parent c951b1b955
commit 7ebf6bd7cf
7 changed files with 66 additions and 25 deletions

View File

@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
#include "Globals.h"
#include "simulation.h"
#include "Train.h"
#include "dictionary.h"
#include "sceneeditor.h"
#include "renderer.h"
#include "uilayer.h"
@@ -128,6 +129,9 @@ eu07_application::init( int Argc, char *Argv[] ) {
if( ( result = init_audio() ) != 0 ) {
return result;
}
if( ( result = init_data() ) != 0 ) {
return result;
}
m_taskqueue.init();
if( ( result = init_modes() ) != 0 ) {
return result;
@@ -523,6 +527,23 @@ eu07_application::init_audio() {
return 0;
}
int
eu07_application::init_data() {
// HACK: grab content of the first {} block in load_unit_weights using temporary parser, then parse it normally. on any error our weight list will be empty string
auto loadweights { cParser( cParser( "data/load_weights.txt", cParser::buffer_FILE ).getToken<std::string>( true, "{}" ), cParser::buffer_TEXT ) };
while( true == loadweights.getTokens( 2 ) ) {
std::pair<std::string, float> weightpair;
loadweights
>> weightpair.first
>> weightpair.second;
weightpair.first.erase( weightpair.first.end() - 1 ); // trim trailing ':' from the key
simulation::Weights.emplace( weightpair.first, weightpair.second );
}
return 0;
}
int
eu07_application::init_modes() {