---
title: "An Introduction to Deep Reinforcement Learning"
description: "Deep reinforcement learning trains an agent to act in an environment through trial and error, using rewards as its only feedback, with the goal of maximizing expected cumulative (discounted) return."
url: "https://swe.quest/articles/an-introduction-to-deep-reinforcement-learning-d17541fa32bf28e1"
canonical: "https://huggingface.co/blog/deep-rl-intro"
source: "Hugging Face"
published: "2022-05-04"
difficulty: "easy"
kind: "How-to"
reading_minutes: 16
tags: ["machine-learning","model-training"]
---

# An Introduction to Deep Reinforcement Learning

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-05-04, 16 min read, How-to. Original: [https://huggingface.co/blog/deep-rl-intro](https://huggingface.co/blog/deep-rl-intro)

## Summary

Deep reinforcement learning trains an agent to act in an environment through trial and error, using rewards as its only feedback, with the goal of maximizing expected cumulative (discounted) return. The core concepts are the state/action/reward loop, the Markov property, observation vs. state, discrete vs. continuous action spaces, discounting with gamma (typically 0.95–0.99), episodic vs. continuing tasks, and the exploration/exploitation tradeoff. The two main ways to learn an optimal policy are policy-based methods, which map states directly to actions or action distributions, and value-based methods, which learn state values and act greedily toward them. It is the first unit of Hugging Face's free Deep RL course, which goes on to train a lunar lander agent with Stable Baselines3.

Written by swe.quest, not by the author.

**Difficulty:** Easy: no special background needed; explains what something is and why it matters

## Topics

- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)

## Prerequisites

- basic machine learning concepts ([easy posts on Machine learning](https://swe.quest/tags/machine-learning.md?difficulty=easy))

## Keywords

Deep Reinforcement Learning, Markov Decision Process, Stable Baselines3, Hugging Face Hub, Deep Q-Learning

## Related posts

- [Policy Gradient with PyTorch](https://swe.quest/articles/policy-gradient-with-pytorch-8cc397d15e17e5f8.md): Hugging Face · 2022-06-30 · Easy · 7 min read · Machine learning, Model training, Python
  Policy-gradient methods optimize a stochastic policy directly via gradient ascent on expected return, instead of deriving a policy from learned Q-values as in Deep Q-Learning.
- [An Introduction to Q-Learning Part 1](https://swe.quest/articles/an-introduction-to-q-learning-part-1-02c8621463858d6d.md): Hugging Face · 2022-05-18 · Medium · 13 min read · Machine learning, Model training, Algorithms
  Value-based reinforcement learning methods learn a state-value or action-value function and derive the policy from it, typically a greedy or epsilon-greedy policy, rather than training the policy directly.
- [Advantage Actor Critic (A2C)](https://swe.quest/articles/advantage-actor-critic-a2c-5b4f17254e3ab304.md): Hugging Face · 2022-07-22 · Medium · 7 min read · Machine learning, Model training, Algorithms
  Actor-Critic methods reduce the high variance of Monte-Carlo policy-gradient estimates in Reinforce by pairing a policy network (Actor) with a value network (Critic) that scores the actions taken.
- [Deep Q-Learning with Space Invaders](https://swe.quest/articles/deep-q-learning-with-space-invaders-f474bfcf35b2c89d.md): Hugging Face · 2022-06-07 · Medium · 10 min read · Machine learning, Model training, Games
  Deep Q-Learning replaces the tabular Q-table with a neural network that maps a state to Q-values for every action, making RL feasible for huge state spaces like Atari frames (256^100800 possible observations).
- [An Introduction to Q-Learning Part 2/2](https://swe.quest/articles/an-introduction-to-q-learning-part-2-2-2282a7e5e80bee59.md): Hugging Face · 2022-05-20 · Medium · 9 min read · Machine learning, Model training, Algorithms
  Q-Learning is an off-policy, value-based reinforcement learning algorithm that uses temporal-difference updates to train a Q-table of state-action values, from which the optimal policy follows directly.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
