Book Image

TensorFlow 2 Reinforcement Learning Cookbook

By : Palanisamy P
Book Image

TensorFlow 2 Reinforcement Learning Cookbook

By: Palanisamy P

Overview of this book

With deep reinforcement learning, you can build intelligent agents, products, and services that can go beyond computer vision or perception to perform actions. TensorFlow 2.x is the latest major release of the most popular deep learning framework used to develop and train deep neural networks (DNNs). This book contains easy-to-follow recipes for leveraging TensorFlow 2.x to develop artificial intelligence applications. Starting with an introduction to the fundamentals of deep reinforcement learning and TensorFlow 2.x, the book covers OpenAI Gym, model-based RL, model-free RL, and how to develop basic agents. You'll discover how to implement advanced deep reinforcement learning algorithms such as actor-critic, deep deterministic policy gradients, deep-Q networks, proximal policy optimization, and deep recurrent Q-networks for training your RL agents. As you advance, you’ll explore the applications of reinforcement learning by building cryptocurrency trading agents, stock/share trading agents, and intelligent agents for automating task completion. Finally, you'll find out how to deploy deep reinforcement learning agents to the cloud and build cross-platform apps using TensorFlow 2.x. By the end of this TensorFlow book, you'll have gained a solid understanding of deep reinforcement learning algorithms and their implementations from scratch.
Table of Contents (11 chapters)

Packaging Deep RL agents for the web and Node.js using TensorFlow.js

JavaScript is the language of choice when it comes to developing web applications due to its versatility both as a frontend as well as a backend programming language that can be executed by a web browser or using Node.js. The ability to run out RL agents on the web will unlock several new pathways for deploying RL agents in web apps. This recipe will show how you can train and export RL agent models into a format that you can then use in your JavaScript applications that can be run directly in the browser or in a Node.js environment. The TensorFlow.js (TF.js) library allows us to use JavaScript to run existing models or even train/retrain new models. We will use the tensorflowjs Python module to export our agent's model to a supported format that can be imported into JavaScript-based web or desktop (Node.js/Electron) apps. We will explore two approaches to export the Agent model to the TF.js layers format.

...