liveBook · Manning

Reinforcement learning

As explained in Evolutionary Deep Learning: Genetic algorithms and neural networks

Reinforcement learning is a machine-learning paradigm in which an agent learns behavior by interacting with an environment and receiving rewards or other evaluative feedback.

Reinforcement learning (RL) trains an agent through interaction: it observes a current environment state, chooses an action, receives a reward, and repeats. Actions that tend to yield higher accumulated rewards for a state become more valuable. Early behavior is often random exploration, making RL a trial-and-error approach rather than learning from labeled answers. section 11.1

Figure 11.1b Reinforcement learning

The agent–environment loop makes the core units visible: state enters the agent, an action affects the environment, and reward evaluates that action. section 11.1.1

A common first implementation is Q-learning. A Q-table stores an estimated quality for every state–action pair. During training, the agent sometimes selects the table’s best action and sometimes samples a random action; after each environment step, it updates the selected table entry using the immediate reward and the best estimated value of the next state. Exploration decreases over episodes through epsilon decay. section 11.1.1

Frozen lake Q-learning agent

In a 4-by-4 frozen-lake environment, an agent moves up, down, left, or right. Reaching the bottom-right goal earns a reward; falling through a hole ends the episode with a negative reward. A runnable setup creates the Gym environment, initializes a zero Q-table, sets episode, learning-rate, discount, and epsilon parameters, trains over episodes, then plays using each state’s highest-valued action. section 11.1.1

A practical RL workflow is:

  • Inspect the environment’s observation/state space and action space before defining the agent. section 11.1.1 section 11.2.1
  • Run episodes that reset the environment, choose an action, step the environment, collect reward, and stop when done. section 11.1.1
  • Evaluate the learned policy separately by selecting the highest-valued action rather than random exploration. section 11.1.1
  • Experiment with other Gym environments, beginning with random play to understand their behavior. section 11.2.1

Rewards can also evaluate agents without being the mechanism that learns from them. In a NEAT setup, a network receives an observation and outputs action scores; accumulated rewards become genome fitness, and evolution selects higher-fitness genomes. That uses RL-style environments and reward-based evaluation, but the underlying optimizer is evolution rather than RL. Deep Q-learning is another extension, replacing a Q-table or policy with deep learning for more complex environments such as lunar lander. section 11.3 section 11.6

Trial-and-error exploration can be costly: solving a problem may require millions of actions. This limitation motivates looking beyond derived reward equations toward approaches such as evolutionary learning, while retaining environments as controlled places to test decision-making agents. section 11.1 section 11.2.1

How Evolutionary Deep Learning: Genetic algorithms and neural networks covers it

How deep it goes
Explains the state–action–reward loop and implements tabular Q-learning, while deferring advanced deep Q-learning treatment.
Examples
Uses pet training, a 4-by-4 FrozenLake agent, Gym environment exercises, and reward-scored NEAT agents.
What it assumes
Introduces the reward-learning premise from a pet-training analogy, then uses Python, notebooks, and Gym setup.
What you can do after
Build it from scratch as a tabular Q-learning agent and evaluate it in a Gym environment.
How it connects
Connects reinforcement learning with supervised learning, generative modeling, Q-learning, deep Q-learning, OpenAI Gym, and NEAT.

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 Evolutionary Deep Learning: Genetic algorithms and neural networks. The section links point to the parts of the book it draws on.