예제 #1
0
 def observation(self, indices=None, name=None):
     with tf.variable_scope(name, default_name='MazeObservation'):
         with tf.device('/cpu:0'):
             obs = gym_tensorflow_module.environment_observation(self.instances, indices, T=tf.float32)
             obs.set_shape((None,) + (11,))
             #obs = tf.Print(obs, [obs], "obs=")
             return tf.expand_dims(obs, axis=1)
예제 #2
0
 def observation(self, indices=None, name=None):
     if indices is None:
         indices = np.arange(self.batch_size)
     with tf.variable_scope(name, default_name='RivercrossingObservation'):
         with tf.device('/cpu:0'):
             obs = gym_tensorflow_module.environment_observation(self.instances, indices, T=tf.float32)
         obs.set_shape((None,) + self.env_size + (self.num_stacked_frames,))
     return obs
예제 #3
0
 def render(self, indices=None):
     if indices is None:
         indices = np.arange(self.batch_size)
     with tf.device('/cpu:0'):
         obs = gym_tensorflow_module.environment_observation(self.instances,
                                                             indices,
                                                             T=tf.uint8)
         return tf.gather(tf.constant(rgb_palette_uint8),
                          tf.cast(obs, tf.int32))
예제 #4
0
    def observation(self, indices=None, name=None):
        '''Returns current observation after preprocessing (skip, grayscale, warp, stack).\nMust be called ONCE each time step is called if num_stacked_frames > 1
        '''
        if indices is None:
            batch_size = self.batch_size
            indices = np.arange(self.batch_size)
        else:
            batch_size = indices.get_shape()[0]
        with tf.variable_scope(name, default_name='AtariObservation'):
            with tf.device('/cpu:0'):
                obs = gym_tensorflow_module.environment_observation(self.instances, indices, T=tf.uint8)

            obs = tf.gather(tf.constant(self.color_pallete), tf.cast(obs, tf.int32))
            obs = tf.reduce_max(obs, axis=1)
            obs = tf.image.resize_bilinear(obs, self.warp_size, align_corners=True)
            obs.set_shape((batch_size,) + self.warp_size + (1,))
            return obs