The trainDDPG() and testDDPG() functions that we used earlier will now be defined in TrainOrTest.py. The steps that are involved are as follows:
- 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 *
- 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 ...