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

added safety check on number of examples extracted to avoid disk filling

parent 59751292
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ class Trainer
{
private :
static constexpr std::size_t safetyNbExamplesMax = 10*1000*1000;
struct Examples
{
std::vector<torch::Tensor> contexts;
......
......@@ -122,6 +122,8 @@ void Trainer::extractExamples(SubConfig & config, bool debug, std::filesystem::p
int goldIndex = machine.getTransitionSet().getTransitionIndex(goldTransition);
totalNbExamples += context.size();
if (totalNbExamples >= (int)safetyNbExamplesMax)
util::myThrow(fmt::format("Trying to extract more examples than the limit ({})", util::int2HumanStr(safetyNbExamplesMax)));
examplesPerState[config.getState()].addContext(context);
examplesPerState[config.getState()].addClass(goldIndex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment