December 2019
Intermediate to advanced
368 pages
11h 10m
English
To train game agents, we need to implement a function that starts the Atari environment from a particular random state. It is vital to implement a stochastic Atari reset function to guarantee that our agent can play the game from any initial state. The function is implemented as follows:
def reset(self, indices=None, max_frames=None, name=None): if indices is None: indices = np.arange(self.batch_size) with tf.variable_scope(name, default_name='AtariReset'): noops = tf.random_uniform(tf.shape(indices), minval=1, maxval=31, dtype=tf.int32) if max_frames is None: max_frames = tf.ones_like(indices, dtype=tf.int32) * \ (100000 * self.frameskip) import collections if not isinstance(max_frames, collections.Sequence): ...
Read now
Unlock full access