Skip to content
Permalink
Browse files

fix bugs

  • Loading branch information
lesit committed Nov 17, 2018
1 parent 30fe542 commit 7b7029f6357b21b3abe70f19c5c5a0d61cb14684
@@ -51,48 +51,66 @@ bool NeuralNetworkTrainer::Train(const TRAIN_SETUP& setup)

_producer_layer_data_vector data_vector;
data_vector.resize(input_engine_vector.size()+ output_engine_vector.size());
_producer_layer_data_vector test_data_vector;
test_data_vector.resize(data_vector.size());

_producer_layer_data_vector::iterator it_data = data_vector.begin();
_producer_layer_data_vector::iterator it_test_data = test_data_vector.begin();

// test batch generator에 data.provider가 아닌 data.test_provider 의 producer를 넣어야 한다!
for (neuro_u32 i = 0; i < input_engine_vector.size(); i++)
{
InputLayerEngine* engine = input_engine_vector[i];

_PRODUCER_LAYER_DATA_SET& producer_layer_data_set = *(it_data++);
_PRODUCER_LAYER_DATA_SET& data_set = *(it_data++);

producer_layer_data_set.producer = FindLayerBindingProducer(*setup.data.provider, *engine);
if (producer_layer_data_set.producer == NULL)
data_set.producer = FindLayerBindingProducer(*setup.data.provider, *engine);
if (data_set.producer == NULL)
{
DEBUG_OUTPUT(L"no binding producer for input layer[%u]", engine->m_layer.uid);
return false;
}
producer_layer_data_set.producer_dim_size = producer_layer_data_set.producer->m_data_dim_size;
data_set.producer_dim_size = data_set.producer->m_data_dim_size;

const tensor::_NEURO_TENSOR_DATA& data = engine->GetOutputData();
producer_layer_data_set.layer_mm = &data.data.mm;
producer_layer_data_set.layer_buffer = data.GetBuffer();
producer_layer_data_set.layer_data_size = data.GetTimeValueSize();
data_set.layer_mm = &data.data.mm;
data_set.layer_buffer = data.GetBuffer();
data_set.layer_data_size = data.GetTimeValueSize();

if (setup.data.test_provider)
{
_PRODUCER_LAYER_DATA_SET& test_data_set = *(it_test_data++);
test_data_set = data_set;
test_data_set.producer = FindLayerBindingProducer(*setup.data.test_provider, *engine);
}
}
for (neuro_u32 i = 0; i < output_engine_vector.size(); i++)
{
OutputLayerEngine* engine = output_engine_vector[i];

_PRODUCER_LAYER_DATA_SET& producer_layer_data_set = *(it_data++);
_PRODUCER_LAYER_DATA_SET& data_set = *(it_data++);

producer_layer_data_set.producer = FindLayerBindingProducer(*setup.data.provider, *engine);
if (producer_layer_data_set.producer == NULL)
data_set.producer = FindLayerBindingProducer(*setup.data.provider, *engine);
if (data_set.producer == NULL)
{
DEBUG_OUTPUT(L"no binding producer for output layer[%u]", engine->m_layer.uid);
return false;
}
producer_layer_data_set.producer_dim_size = producer_layer_data_set.producer->m_data_dim_size;
data_set.producer_dim_size = data_set.producer->m_data_dim_size;

producer_layer_data_set.read_label = producer_layer_data_set.producer->m_label_out_type!=dp::model::_label_out_type::none;
data_set.read_label = data_set.producer->m_label_out_type!=dp::model::_label_out_type::none;

const tensor::_TYPED_TENSOR_DATA<void*, 4>& data = engine->GetTargetData();
producer_layer_data_set.layer_mm = &data.data.mm;
producer_layer_data_set.layer_buffer = data.GetBuffer();
producer_layer_data_set.layer_data_size = data.GetTimeValueSize();
data_set.layer_mm = &data.data.mm;
data_set.layer_buffer = data.GetBuffer();
data_set.layer_data_size = data.GetTimeValueSize();

if (setup.data.test_provider)
{
_PRODUCER_LAYER_DATA_SET& test_data_set = *(it_test_data++);
test_data_set = data_set;
test_data_set.producer = FindLayerBindingProducer(*setup.data.test_provider, *engine);
}
}

_learn_type learn_type = setup.learn.learn_type;
@@ -108,8 +126,8 @@ bool NeuralNetworkTrainer::Train(const TRAIN_SETUP& setup)
TrainFunctions train_funcs;
if (!train_funcs.Initialize(m_network.GetNetParam().run_pdtype, m_network.GetNetParam().cuda_instance
, m_network.GetLearningInfo(), opt_parameters
, *setup.data.provider, setup.data.test_provider
, data_vector))
, *setup.data.provider, data_vector
, setup.data.test_provider, test_data_vector))
{
DEBUG_OUTPUT(L"failed initialize train functions");
return false;
@@ -27,9 +27,8 @@ namespace np
bool Initialize(core::math_device_type pdtype, core::cuda::CudaInstance* cuda_instance
, const network::_LEARNING_INFO& info
, const std::vector<neuro_float>& opt_parameters
, dp::preprocessor::DataProvider& provider
, dp::preprocessor::DataProvider* test_provider
, const _producer_layer_data_vector& data_vector)
, dp::preprocessor::DataProvider& provider, const _producer_layer_data_vector& data_vector
, dp::preprocessor::DataProvider* test_provider, const _producer_layer_data_vector& test_data_vector)
{
optimize_epoch = optimizer::OptimizeInEpoch::CreateInstance(pdtype, cuda_instance, info.optimizer_type, opt_parameters, info.optimizing_rule);
if (optimize_epoch == NULL)
@@ -55,7 +54,7 @@ namespace np

if (test_provider)
{
test_batch_gen = new MiniBatchSequentialGenerator(*test_provider, data_vector);
test_batch_gen = new MiniBatchSequentialGenerator(*test_provider, test_data_vector);
if (!test_batch_gen->Ready(provider.batch_size))
{
DEBUG_OUTPUT(L"failed ready of batch generator to test after learn");
@@ -322,7 +322,8 @@ void SimulationTrainStatusControl::SetOnehotResultList(const _output_analysis_on
for (neuro_u32 output = 0; output < output_analysis_onehot_vector.size(); output++)
{
const _output_analysys_onehot& output_analysys_onehot = output_analysis_onehot_vector[output];
CString header; header.Format(L"%u", output_analysys_onehot.layer->m_layer.uid); // 원래는 layer의 matrix 포인터를 넣어야 한다.
CString header; header.Format(L"%u,%u", output_analysys_onehot.layer->m_layer.gui_grid_point.x,
output_analysys_onehot.layer->m_layer.gui_grid_point.y);
ctrOnehotResultList.InsertGroupHeader(output, header);

for (neuro_u32 i = 0, n = output_analysys_onehot.results.size(); i < n; i++)
@@ -344,10 +345,10 @@ void SimulationTrainStatusControl::SetOnehotResultList(const _output_analysis_on

if (test_result)
{
const _analysis_onehot& test_after_learn_analysis = output_analysys_onehot.test_after_learn[i];
ctrOnehotResultList.SetItemText(onehot_result_index, 4, util::StringUtil::Transform<wchar_t>(test_after_learn_analysis.target_accumulate).c_str());
ctrOnehotResultList.SetItemText(onehot_result_index, 5, util::StringUtil::Transform<wchar_t>(test_after_learn_analysis.out_accumulate).c_str());
ctrOnehotResultList.SetItemText(onehot_result_index, 6, util::StringUtil::Transform<wchar_t>(test_after_learn_analysis.accord_accumulate).c_str());
const _analysis_onehot& test_analysis = output_analysys_onehot.test_after_learn[i];
ctrOnehotResultList.SetItemText(onehot_result_index, 4, util::StringUtil::Transform<wchar_t>(test_analysis.target_accumulate).c_str());
ctrOnehotResultList.SetItemText(onehot_result_index, 5, util::StringUtil::Transform<wchar_t>(test_analysis.out_accumulate).c_str());
ctrOnehotResultList.SetItemText(onehot_result_index, 6, util::StringUtil::Transform<wchar_t>(test_analysis.accord_accumulate).c_str());
}
}
}
@@ -538,12 +538,14 @@ void LoadNSProject::LoadSimTrainData(const XERCES_CPP_NAMESPACE::DOMElement* ele
{
const XERCES_CPP_NAMESPACE::DOMElement* trainElem = elem->getFirstElementChild();

project::SimDefinition& sim_def = m_project.GetSimManager();

for (; trainElem != NULL; trainElem = trainElem->getNextElementSibling())
{
if (wcscmp(trainElem->getLocalName(), elem::szTrainLearn) == 0)
LoadSimData(trainElem, m_project.GetSimManager().GetLastLearnData());
LoadSimData(trainElem, sim_def.GetLastLearnData());
else if (wcscmp(trainElem->getLocalName(), elem::szTrainTest) == 0)
LoadSimData(trainElem, m_project.GetSimManager().GetLastTestData());
LoadSimData(trainElem, sim_def.GetLastTestData());
}
}

BIN +0 Bytes (100%) Sample/Numeric-Mnist/mnist.nsas
Binary file not shown.
@@ -55,14 +55,19 @@
<train.learn>
<item id="0">
<file filepath="train-images.idx3-ubyte"/>
<file filepath="t10k-images.idx3-ubyte"/>
</item>
<item id="1">
<file filepath="train-labels.idx1-ubyte"/>
<file filepath="t10k-labels.idx1-ubyte"/>
</item>
</train.learn>
<train.test/>
<train.test>
<item id="0">
<file filepath="t10k-images.idx3-ubyte"/>
</item>
<item id="1">
<file filepath="t10k-labels.idx1-ubyte"/>
</item>
</train.test>
</train.data>
<predict.data>
<predict.input>
BIN +1 KB (100%) bin/NeuroStudio.exe
Binary file not shown.

0 comments on commit 7b7029f

Please sign in to comment.
You can’t perform that action at this time.