Book Image

Deep Reinforcement Learning Hands-On

By : Maxim Lapan
Book Image

Deep Reinforcement Learning Hands-On

By: Maxim Lapan

Overview of this book

Deep Reinforcement Learning Hands-On is a comprehensive guide to the very latest DL tools and their limitations. You will evaluate methods including Cross-entropy and policy gradients, before applying them to real-world environments. Take on both the Atari set of virtual games and family favorites such as Connect4. The book provides an introduction to the basics of RL, giving you the know-how to code intelligent learning agents to take on a formidable array of practical tasks. Discover how to implement Q-learning on 'grid world' environments, teach your agent to buy and trade stocks, and find out how natural language models are driving the boom in chatbots.
Table of Contents (23 chapters)
Deep Reinforcement Learning Hands-On
Other Books You May Enjoy

Multiprocessing in Python

Python includes the multiprocessing (most of the time abbreviated to just mp) module to support process-level parallelism and the required communication primitives. In our example, we'll use the two main classes from this module:

  • mp.Queue: Concurrent multi-producer, multi-consumer FIFO queue with transparent serialization and deserialization of objects placed in the queue

  • mp.Process: A piece of code that is run in the child process and methods to control it from the parent's process

PyTorch provides its own thin wrapper around the multiprocessing module, which adds the proper handling of tensors and variables on CUDA devices and shared memory. It provides exactly the same functionality as the multiprocessing module from the standard library, so all you need to do is to use import torch.multiprocessing instead of import multiprocessing.