Coding TrainOrTest.py

The trainDDPG() and testDDPG() functions that we used earlier will now be defined in TrainOrTest.py. The steps that are involved are as follows:

  1. Import packages and functions: The TrainOrTest.py file starts with the importing of the packages and other Python files:
import tensorflow as tfimport numpy as npimport gymfrom gym import wrappersimport argparseimport pprint as ppimport sysfrom replay_buffer import ReplayBufferfrom AandC import *
  1. Define the trainDDPG() function: Next, we define the trainDDPG() function. First, we initialize all of the networks by calling a sess.run() on tf.global_variables_initializer(). Then, we initialize the target network weights and the replay buffer. Then, we start the main loop over ...

Get TensorFlow Reinforcement Learning Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.