December 2019
Intermediate to advanced
468 pages
14h 28m
English
Finally, we can run the whole thing. The full code for this is available at https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Python/blob/master/Chapter11/imitation_learning/main.py.
The following snippet builds and restores (if available) the network, runs the training, and evaluates the network:
# create cuda devicedev = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")# create the networkmodel = build_network()# if true, try to restore the network from the data filerestore = Falseif restore: model_path = os.path.join(DATA_DIR, MODEL_FILE) model.load_state_dict(torch.load(model_path))# set the model to evaluation (and not training) modemodel.eval()# transfer to the gpumodel = model.to(dev) ...
Read now
Unlock full access