     dimBatch
   };
 
-  int device = options["device"].as<int>();
+  int device = options.get<int>("device");
 
   auto graph = New<ExpressionGraph>();
   graph->setDevice(device);


    size_t epochs = 1;
    size_t batches = 0;
    while((options["after-epochs"].as<size_t>() == 0
           || epochs <= options["after-epochs"].as<size_t>()) &&
          (options["after-batches"].as<size_t>() == 0
           || batches < options["after-batches"].as<size_t>())) {

      batchGenerator->prepare();


          wordsDisp = 0;
        }

        if(batches % options.get<size_t>("save-freq") == 0) {
          if(options.get<bool>("overwrite"))
            save(options.get<std::string>("model") + ".npz");
          else
            save(options.get<std::string>("model") + "." + std::to_string(batches) + ".npz");
        }
      }
      epochs++;
      LOG(info) << "Starting epoch " << epochs << " after " << samples << " samples";
    }
    LOG(info) << "Training finshed";
    save(options.get<std::string>("model") + ".npz");
    LOG(info) << timer.format(2, "%ws");
  }
}
