Skip to content
Snippets Groups Projects
Commit 4cd70514 authored by Franck Dary's avatar Franck Dary
Browse files

Corrected multimlp

parent 09537fce
No related branches found
No related tags found
No related merge requests found
...@@ -90,24 +90,20 @@ std::vector<float> MultiMLP::predict(FeatureModel::FeatureDescription & fd) ...@@ -90,24 +90,20 @@ std::vector<float> MultiMLP::predict(FeatureModel::FeatureDescription & fd)
float MultiMLP::update(FeatureModel::FeatureDescription & fd, int gold) float MultiMLP::update(FeatureModel::FeatureDescription & fd, int gold)
{ {
try float loss = 0.0;
{
for (auto & mlp : mlps) for (auto & mlp : mlps)
try
{ {
int id = std::stoi(split(mlp.name, '_')[1]); int id = std::stoi(split(mlp.name, '_')[1]);
float loss = 0.0;
mlp.setBatchSize(getBatchSize()); mlp.setBatchSize(getBatchSize());
loss = mlp.update(fd, id == gold ? 1 : 0); loss += mlp.update(fd, id == gold ? 1 : 0);
trainer->update(); trainer->update();
return loss;
}
} catch (BatchNotFull &) } catch (BatchNotFull &)
{ {
return 0.0;
} }
return 0.0; return loss;
} }
float MultiMLP::update(FeatureModel::FeatureDescription &, const std::vector<float> &) float MultiMLP::update(FeatureModel::FeatureDescription &, const std::vector<float> &)
...@@ -120,19 +116,14 @@ float MultiMLP::update(FeatureModel::FeatureDescription &, const std::vector<flo ...@@ -120,19 +116,14 @@ float MultiMLP::update(FeatureModel::FeatureDescription &, const std::vector<flo
float MultiMLP::getLoss(FeatureModel::FeatureDescription & fd, int gold) float MultiMLP::getLoss(FeatureModel::FeatureDescription & fd, int gold)
{ {
float loss = 0.0; float loss = 0.0;
try
{
for (auto & mlp : mlps) for (auto & mlp : mlps)
try
{ {
int id = std::stoi(split(mlp.name, '_')[1]); int id = std::stoi(split(mlp.name, '_')[1]);
mlp.setBatchSize(getBatchSize()); mlp.setBatchSize(getBatchSize());
loss += mlp.getLoss(fd, id == gold ? 1 : 0); loss += mlp.getLoss(fd, id == gold ? 1 : 0);
trainer->update();
}
} catch (BatchNotFull &) } catch (BatchNotFull &)
{ {
return 0.0;
} }
return loss; return loss;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment