         samples += batch->size();
         wordsDisp += batch->words();
         batches++;
-        if(options["after-batches"].as<size_t>()
-           && batches >= options["after-batches"].as<size_t>())
+        if(options.get<size_t>("after-batches")
+           && batches >= options.get<size_t>("after-batches"))
           break;
 
-        if(batches % options["disp-freq"].as<size_t>() == 0) {
+        if(batches % options.get<size_t>("disp-freq") == 0) {
           std::stringstream ss;
           ss << "Ep. " << epochs
              << " : Up. " << batches
              << " : Sen. " << samples
              << " : Cost " << std::fixed << std::setprecision(2)
-                           << costSum / options["disp-freq"].as<size_t>()
+                           << costSum / options.get<size_t>("disp-freq")
              << " : Time " << timer.format(2, "%ws");
 
           float seconds = std::stof(timer.format(5, "%w"));

    nematus->save(graph, name);
  };


  auto trainSets = options["trainsets"].as<std::vector<std::string>>();
  auto vocabs = options["vocabs"].as<std::vector<std::string>>();
  size_t maxSentenceLength = options["max-length"].as<size_t>();

  auto corpus = New<Corpus>(trainSets, vocabs, dimVocabs, maxSentenceLength);
  auto bg = New<BatchGenerator<Corpus>>(corpus, dimBatch, dimMaxiBatch);

  Config options(argc, argv);
  std::cerr << options << std::endl;

  auto dimVocabs = options.get<std::vector<int>>("dim-vocabs");
  int dimEmb = options.get<int>("dim-emb");
  int dimRnn = options.get<int>("dim-rnn");
  int dimBatch = options.get<int>("mini-batch");
  int dimMaxiBatch = options.get<int>("maxi-batch");

  std::vector<int> dims = {
    dimVocabs[0], dimEmb, dimRnn,
