Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Hands-On Intelligent Agents with OpenAI Gym
Hands-On Intelligent Agents with OpenAI Gym

Hands-On Intelligent Agents with OpenAI Gym: Your guide to developing AI agents using deep reinforcement learning

Arrow left icon
Profile Icon Palanisamy
Arrow right icon
Mex$504.99 Mex$721.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (3 Ratings)
eBook Jul 2018 254 pages 1st Edition
eBook
Mex$504.99 Mex$721.99
Paperback
Mex$902.99
Subscription
Free Trial
Arrow left icon
Profile Icon Palanisamy
Arrow right icon
Mex$504.99 Mex$721.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (3 Ratings)
eBook Jul 2018 254 pages 1st Edition
eBook
Mex$504.99 Mex$721.99
Paperback
Mex$902.99
Subscription
Free Trial
eBook
Mex$504.99 Mex$721.99
Paperback
Mex$902.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Intelligent Agents with OpenAI Gym

Reinforcement Learning and Deep Reinforcement Learning

This chapter provides a concise explanation of the basic terminology and concepts in reinforcement learning. It will give you a good understanding of the basic reinforcement learning framework for developing artificial intelligent agents. This chapter will also introduce deep reinforcement learning and provide you with a flavor of the types of advanced problems the algorithms enable you to solve. You will find mathematical expressions and equations used in quite a few places in this chapter. Although there's enough theory behind reinforcement learning and deep reinforcement learning to fill a whole book, the key concepts that are useful for practical implementation are discussed in this chapter, so that when we actually implement the algorithms in Python to train our agents, you can clearly understand the logic behind...

What is reinforcement learning?

If you are new to the field of Artificial Intelligence (AI) or machine learning, you might be wondering what reinforcement learning is all about. In simple terms, it is learning through reinforcement. Reinforcement, as you know from general English or psychology, is the act of increasing or strengthening the choice to take a particular action in response to something, because of the perceived benefit of receiving higher rewards for taking that action. We humans are good at learning through reinforcement from a very young age. Those who have kids may be utilizing this fact more often to teach good habits to them. Nevertheless, we will all be able to relate to this, because not so long ago we all went through that phase of life! Say parents reward their kid with chocolate if the kid completes their homework on time after school every day. The kid...

Understanding what AI means and what's in it in an intuitive way

The intelligence demonstrated by humans and animals is called natural intelligence, but the intelligence demonstrated by machines is called AI, for obvious reasons. We humans develop algorithms and technologies that provide intelligence to machines. Some of the greatest developments on this front are in the fields of machine learning, artificial neural networks, and deep learning. These fields collectively drive the development of AI. There are three main types of machine learning paradigms that have been developed to some reasonable level of maturity so far, and they are the following:

  • Supervised learning
  • Unsupervised learning
  • Reinforcement learning

In the following diagram, you can get an intuitive picture of the field of AI. You can see that these learning paradigms are subsets of the field of machine learning...

Practical reinforcement learning

Now that you have an intuitive understanding of what AI really means and the various classes of algorithm that drive its development, we will now focus on the practical aspects of building a reinforcement learning machine.

Here are the core concepts that you need to be aware of to develop reinforcement learning systems:

  • Agent
  • Rewards
  • Environment
  • State
  • Value function
  • Policy

Agent

In the reinforcement learning world, a machine is run or instructed by a (software) agent. The agent is the part of the machine that possesses intelligence and makes decisions on what to do next. You will come across the term "agent" several times as we dive deeper into reinforcement learning. Reinforcement...

Markov Decision Process

A Markov Decision Process (MDP) provides a formal framework for reinforcement learning. It is used to describe a fully observable environment where the outcomes are partly random and partly dependent on the actions taken by the agent or the decision maker. The following diagram is the progression of a Markov Process into a Markov Decision Process through the Markov Reward Process:

These stages can be described as follows:

  • A Markov Process (or a markov chain) is a sequence of random states s1, s2,... that obeys the Markov property. In simple terms, it is a random process without any memory about its history.
  • A Markov Reward Process (MRP) is a Markov Process (also called a Markov chain) with values.
  • A Markov Decision Process is a Markov Reward Process with decisions.

Planning with dynamic programming

Dynamic programming is a very general method to efficiently solve problems that can be decomposed into overlapping sub-problems. If you have used any type of recursive function in your code, you might have already got some preliminary flavor of dynamic programming. Dynamic programming, in simple terms, tries to cache or store the results of sub-problems so that they can be used later if required, instead of computing the results again.

Okay, so how is that relevant here, you may ask. Well, they are pretty useful for solving a fully defined MDP, which means that an agent can find the most optimal way to act in an environment to achieve the highest reward using dynamic programming if it has full knowledge of the MDP! In the following table, you will find a concise summary of what the inputs and outputs are when we are interested in sequential prediction...

Monte Carlo learning and temporal difference learning

At this point, we understand that it is very useful for an agent to learn the state value function , which informs the agent about the long-term value of being in state so that the agent can decide if it is a good state to be in or not. The Monte Carlo (MC) and Temporal Difference (TD) learning methods enable an agent to learn that!

The goal of MC and TD learning is to learn the value functions from the agent's experience as the agent follows its policy .

The following table summarizes the value estimate's update equation for the MC and TD learning methods:

Learning method State-value function
Monte Carlo
Temporal Difference

MC learning updates the value towards the actual return , which is the total discounted reward from time step t. This means that until the end. It is important to note that we...

SARSA and Q-learning

It is also very useful for an agent to learn the action value function , which informs the agent about the long-term value of taking action in state so that the agent can take those actions that will maximize its expected, discounted future reward. The SARSA and Q-learning algorithms enable an agent to learn that! The following table summarizes the update equation for the SARSA algorithm and the Q-learning algorithm:

Learning method Action-value function

SARSA

Q-learning

SARSA is so named because of the sequence State->Action->Reward->State'->Action' that the algorithm's update step depends on. The description of the sequence goes like this: the agent, in state S, takes an action A and gets a reward R, and ends up in the next state S', after which the agent decides to take an action A' in the new state...

Deep reinforcement learning

With a basic understanding of reinforcement learning, you are now in a better state (hopefully you are not in a strictly Markov state where you have forgotten the history/things you have learned so far) to understand the basics of the cool new suite of algorithms that have been rocking the field of AI in recent times.

Deep reinforcement learning emerged naturally when people made advancements in the deep learning field and applied them to reinforcement learning. We learned about the state-value function, action-value function, and policy. Let's briefly look at how they can be represented mathematically or realized through computer code. The state-value function is a real-value function that takes the current state as the input and outputs a real-value number (such as 4.57). This number is the agent's prediction of how good it is to be in...

Practical applications of reinforcement and deep reinforcement learning algorithms

Until recently, practical applications of reinforcement learning and deep reinforcement learning were limited, due to sample complexity and instability. But, these algorithms proved to be quite powerful in solving some really hard practical problems. Some of them are listed here to give you an idea:

  • Learning to play video games better than humans: This news has probably reached you by now. Researchers at DeepMind and others developed a series of algorithms, starting with DeepMind's Deep-Q-Network, or DQN for short, which reached human-level performance in playing Atari games. We will actually be implementing this algorithm in a later chapter of this book! In essence, it is a deep variant of the Q-learning algorithm we briefly saw in this chapter, with a few changes that increased the speed...

Summary

In this chapter, we discussed how an agent interacts with an environment by taking an action based on the observation it receives from the environment, and the environment responds to the agent's action with an (optional) reward and the next observation.

With a concise understanding of the foundations of reinforcement learning, we went deeper to understand what deep reinforcement learning is, and uncovered the fact that we could use deep neural networks to represent value functions and policies. Although this chapter was a little heavy on notation and definitions, hopefully it laid a strong foundation for us to develop some cool agents in the upcoming chapters. In the next chapter, we will consolidate our learning in the first two chapters and put it to use by laying out the groundwork to train an agent to solve some interesting problems.

...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore the OpenAI Gym toolkit and interface to use over 700 learning tasks
  • Implement agents to solve simple to complex AI problems
  • Study learning environments and discover how to create your own

Description

Many real-world problems can be broken down into tasks that require a series of decisions to be made or actions to be taken. The ability to solve such tasks without a machine being programmed requires a machine to be artificially intelligent and capable of learning to adapt. This book is an easy-to-follow guide to implementing learning algorithms for machine software agents in order to solve discrete or continuous sequential decision making and control tasks. Hands-On Intelligent Agents with OpenAI Gym takes you through the process of building intelligent agent algorithms using deep reinforcement learning starting from the implementation of the building blocks for configuring, training, logging, visualizing, testing, and monitoring the agent. You will walk through the process of building intelligent agents from scratch to perform a variety of tasks. In the closing chapters, the book provides an overview of the latest learning environments and learning algorithms, along with pointers to more resources that will help you take your deep reinforcement learning skills to the next level.

Who is this book for?

If you’re a student, game/machine learning developer, or AI enthusiast looking to get started with building intelligent agents and algorithms to solve a variety of problems with the OpenAI Gym interface, this book is for you. You will also find this book useful if you want to learn how to build deep reinforcement learning-based agents to solve problems in your domain of interest. Though the book covers all the basic concepts that you need to know, some working knowledge of Python programming language will help you get the most out of it.

What you will learn

  • Explore intelligent agents and learning environments
  • Understand the basics of RL and deep RL
  • Get started with OpenAI Gym and PyTorch for deep reinforcement learning
  • Discover deep Q learning agents to solve discrete optimal control tasks
  • Create custom learning environments for real-world problems
  • Apply a deep actor-critic agent to drive a car autonomously in CARLA
  • Use the latest learning environments and algorithms to upgrade your intelligent agent development skills

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 31, 2018
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781788835138
Vendor :
OpenAI
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Jul 31, 2018
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781788835138
Vendor :
OpenAI
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 2,707.97
Python Reinforcement Learning Projects
Mex$1004.99
Hands-On Markov Models with Python
Mex$799.99
Hands-On Intelligent Agents with OpenAI Gym
Mex$902.99
Total Mex$ 2,707.97 Stars icon

Table of Contents

11 Chapters
Introduction to Intelligent Agents and Learning Environments Chevron down icon Chevron up icon
Reinforcement Learning and Deep Reinforcement Learning Chevron down icon Chevron up icon
Getting Started with OpenAI Gym and Deep Reinforcement Learning Chevron down icon Chevron up icon
Exploring the Gym and its Features Chevron down icon Chevron up icon
Implementing your First Learning Agent - Solving the Mountain Car problem Chevron down icon Chevron up icon
Implementing an Intelligent Agent for Optimal Control using Deep Q-Learning Chevron down icon Chevron up icon
Creating Custom OpenAI Gym Environments - CARLA Driving Simulator Chevron down icon Chevron up icon
Implementing an Intelligent - Autonomous Car Driving Agent using Deep Actor-Critic Algorithm Chevron down icon Chevron up icon
Exploring the Learning Environment Landscape - Roboschool, Gym-Retro, StarCraft-II, DeepMindLab Chevron down icon Chevron up icon
Exploring the Learning Algorithm Landscape - DDPG (Actor-Critic), PPO (Policy-Gradient), Rainbow (Value-Based) Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
(3 Ratings)
5 star 0%
4 star 33.3%
3 star 0%
2 star 0%
1 star 66.7%
baheri Oct 26, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
At some extend helped me to solve problem.
Amazon Verified review Amazon
Wilhem Kornhauser Jul 09, 2021
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Trying to install this onto a Ubuntu machine is anything but simple. The bash line commands given in the book do not install all of the required files for setup. I had to seek out an addition .yaml file from Github. Then, the numpy version installed using the given commands would not match the "updated" .yaml file specifications from the authors Github. I got that resolved, but am facing issues with the roboschool version. Given how many issues I am seeing with the setup, I have major doubts that the code in this book will execute smoothly and allow me to actually have a hands-on experience with intelligent agents in OpenAI Gym; I'm really having a Hands-On time with Stack Overflow.
Amazon Verified review Amazon
Matthew R. Versaggi Mar 27, 2022
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
I'm in the AI space dealing with Intelligent Agents for my daily job - the title of this book thus spoke to me, but the implementation of it left me seriously doubting the value of fighting through the setup of the experiments. The environment setup on Ubuntu 20 is non-trivial, and the library version issues have consumed hours of my time with a persistent issue of "No module named 'gym-envs.stari' " that hasn't even adequately been solved with authority online just yet. It just seemed like the book was slapped together w/out the engineering thought on how others would be able to engage in the technical experiments and actually get something valuable from it. It's a pity - I had such high hopes for this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.