def __init__(
      self, reward_range, observation_space, action_space, frame_stack_size,
      frame_height, frame_width, initial_frame_chooser, batch_size, model_name,
      model_hparams, model_dir, intrinsic_reward_scale=0.0, sim_video_dir=None
  ):
    """Batch of environments inside the TensorFlow graph."""
    super(SimulatedBatchEnv, self).__init__(observation_space, action_space)

    self._ffmpeg_works = common_video.ffmpeg_works()
    self.batch_size = batch_size
    self._min_reward = reward_range[0]
    self._num_frames = frame_stack_size
    self._intrinsic_reward_scale = intrinsic_reward_scale
    self._episode_counter = tf.get_variable(
        "episode_counter", initializer=tf.zeros((), dtype=tf.int32),
        trainable=False, dtype=tf.int32)
    if sim_video_dir:
      self._video_every_epochs = 100
      self._video_dir = sim_video_dir
      self._video_writer = None
      self._video_counter = 0
      tf.gfile.MakeDirs(self._video_dir)
      self._video_condition = tf.equal(
          self._episode_counter.read_value() % self._video_every_epochs, 0)
    else:
      self._video_condition = tf.constant(False, dtype=tf.bool, shape=())

    model_hparams = copy.copy(model_hparams)
    problem = DummyWorldModelProblem(action_space, reward_range,
                                     frame_height, frame_width)
    trainer_lib.add_problem_hparams(model_hparams, problem)
    model_hparams.force_full_predict = True
    self._model = registry.model(model_name)(
        model_hparams, tf.estimator.ModeKeys.PREDICT
    )

    self.history_buffer = HistoryBuffer(
        initial_frame_chooser, self.observ_shape, self.observ_dtype,
        self._num_frames, self.batch_size
    )

    self._observ = tf.Variable(
        tf.zeros((batch_size,) + self.observ_shape, self.observ_dtype),
        trainable=False
    )

    self._reset_model = tf.get_variable(
        "reset_model", [], trainable=False, initializer=tf.zeros_initializer())

    self._model_dir = model_dir
def __init__ ( self , reward_range , observation_space , action_space , frame_stack_size , frame_height , frame_width , initial_frame_chooser , batch_size , model_name , model_hparams , model_dir , intrinsic_reward_scale = 0.0 , sim_video_dir = None ) : super ( SimulatedBatchEnv , self ) . __init__ ( observation_space , action_space ) self . _ffmpeg_works = common_video . ffmpeg_works ( ) self . batch_size = batch_size self . _min_reward = reward_range [ 0 ] self . _num_frames = frame_stack_size self . _intrinsic_reward_scale = intrinsic_reward_scale self . _episode_counter = tf . get_variable ( "episode_counter" , initializer = tf . zeros ( ( ) , dtype = tf . int32 ) , trainable = False , dtype = tf . int32 ) if sim_video_dir : self . _video_every_epochs = 100 self . _video_dir = sim_video_dir self . _video_writer = None self . _video_counter = 0 tf . gfile . MakeDirs ( self . _video_dir ) self . _video_condition = tf . equal ( self . _episode_counter . read_value ( ) % self . _video_every_epochs , 0 ) else : self . _video_condition = tf . constant ( False , dtype = tf . bool , shape = ( ) ) model_hparams = copy . copy ( model_hparams ) problem = DummyWorldModelProblem ( action_space , reward_range , frame_height , frame_width ) trainer_lib . add_problem_hparams ( model_hparams , problem ) model_hparams . force_full_predict = True self . _model = registry . model ( model_name ) ( model_hparams , tf . estimator . ModeKeys . PREDICT ) self . history_buffer = HistoryBuffer ( initial_frame_chooser , self . observ_shape , self . observ_dtype , self . _num_frames , self . batch_size ) self . _observ = tf . Variable ( tf . zeros ( ( batch_size , ) + self . observ_shape , self . observ_dtype ) , trainable = False ) self . _reset_model = tf . get_variable ( "reset_model" , [ ] , trainable = False , initializer = tf . zeros_initializer ( ) ) self . _model_dir = model_dir
Batch of environments inside the TensorFlow graph.