liveBook · Manning

Reinforcement learning

As explained in Grokking AI Algorithms, Second Edition

Reinforcement learning is a machine-learning paradigm in which an agent learns behavior through rewards for useful actions and penalties for harmful or unsuccessful actions in an environment.

Reinforcement learning trains an agent to act in an environment using feedback from its actions. Useful actions earn rewards; harmful actions receive penalties. Like a dog learning to sit after repeated treats, the agent tries actions, observes what happens, and learns which behavior helps it reach a goal. section 10.1 section 10.2

Choose this approach when the goal and available actions are known, but the best sequence of actions is not. Unlike supervised learning, it does not learn from labeled answers to each question; unlike unsupervised learning, it is not chiefly looking for clusters or trends. It learns from the consequences of acting. section 10.1 section 10.3

A car in a parking lot

Imagine a simulated parking lot containing a car, other vehicles, pedestrians, and the car’s owner. The agent can move north, south, east, or west. Its goal is to reach the owner while avoiding collisions. A collision with a pedestrian has a more severe consequence than one with a car. Training therefore needs to assess a series of moves, not just whether each move looks good in isolation: a move with little immediate benefit may help the car reach its destination safely. section 10.3 section 10.4

The training loop can be understood in four steps:

  • Set up an environment that simulates the problem and a goal that defines useful outcomes. section 10.4
  • Let the agent take an available action in its current situation, or state. section 10.4
  • Measure the outcome and give feedback as a reward or penalty. section 10.2
  • Repeat so the agent learns which actions support the greatest cumulative reward toward its goal. section 10.1 section 10.3
Figure 10.6 The Markov Decision Process for reinforcement learning
10_06

The decision-process diagram helps connect the agent’s situation, action, and measured outcome to the repeated training cycle. section 10.4

Reinforcement learning is especially useful when decisions build toward a longer-term result. Applications include strategic games, robotics, and industrial-process automation. In games too complex to solve by simply searching for a winning move, agents can improve through many rounds of play and feedback. The approach is most practical when a realistic environment can be simulated at scale and a clear reward function can be defined. section 1.31 section 10.12 section 10.3

The learning method may use classical techniques or deep learning with artificial neural networks. Reinforcement learning with human feedback also uses human preferences to help fine-tune large language models toward more helpful responses. section 10.1 section 11.37

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Explains rewards, cumulative outcomes, and a simulated training life cycle, without detailing an implementation in the supplied evidence.
Examples
Uses dog training, simulated parking-lot navigation, and strategic games to illustrate feedback and decisions over time.
What it assumes
Introduces the agent-and-environment idea through a familiar analogy and distinguishes reinforcement learning from supervised and unsupervised learning.
What you can do after
Evaluate/understand it by identifying an agent, its available actions, a goal, and feedback for cumulative outcomes.
How it connects
Relates reinforcement learning to supervised learning, unsupervised learning, Markov Decision Processes, artificial neural networks, and human-feedback fine-tuning.

Also explained in

Compare how 18 books explain reinforcement learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.