MCPcopy Create free account
hub / github.com/deepdrive/deepdrive / run

Function run

tensorflow_agent/agent.py:255–338  ·  view source on GitHub ↗
(experiment, env_id='DeepDrivePreproTensorflow-v0', should_record=False, net_path=None, should_benchmark=True,
        run_baseline_agent=False, camera_rigs=None, should_rotate_sim_types=False,
        should_record_recovery_from_random_actions=False, render=False, path_follower=False, fps=c.DEFAULT_FPS)

Source from the content-addressed store, hash-verified

253
254
255def run(experiment, env_id='DeepDrivePreproTensorflow-v0', should_record=False, net_path=None, should_benchmark=True,
256 run_baseline_agent=False, camera_rigs=None, should_rotate_sim_types=False,
257 should_record_recovery_from_random_actions=False, render=False, path_follower=False, fps=c.DEFAULT_FPS):
258 if run_baseline_agent:
259 net_path = ensure_baseline_weights(net_path)
260 reward = 0
261 episode_done = False
262 max_episodes = 1000
263 tf_config = tf.ConfigProto(
264 gpu_options=tf.GPUOptions(
265 per_process_gpu_memory_fraction=0.8,
266 # leave room for the game,
267 # NOTE: debugging python, i.e. with PyCharm can cause OOM errors, where running will not
268 allow_growth=True
269 ),
270 )
271 sess = tf.Session(config=tf_config)
272 if camera_rigs:
273 cameras = camera_rigs[0]
274 else:
275 cameras = None
276
277 if should_record and camera_rigs is not None and len(camera_rigs) >= 1:
278 should_rotate_camera_rigs = True
279 else:
280 should_rotate_camera_rigs = False
281
282 if should_rotate_camera_rigs:
283 randomize_cameras(cameras)
284
285 use_sim_start_command_first_lap = c.SIM_START_COMMAND is not None
286 gym_env = deepdrive.start(experiment, env_id, should_benchmark=should_benchmark, cameras=cameras,
287 use_sim_start_command=use_sim_start_command_first_lap, render=render,
288 fps=fps)
289 dd_env = gym_env.env
290
291 # Perform random actions to reduce sampling error in the recorded dataset
292 agent = Agent(gym_env.action_space, sess, env=gym_env.env,
293 should_record_recovery_from_random_actions=should_record_recovery_from_random_actions,
294 should_record=should_record, net_path=net_path, random_action_count=4, non_random_action_count=5,
295 path_follower=path_follower)
296 if net_path:
297 log.info('Running tensorflow agent checkpoint: %s', net_path)
298
299 def close():
300 gym_env.close()
301 agent.close()
302
303 session_done = False
304 episode = 0
305 try:
306 while not session_done:
307 if episode_done:
308 obz = gym_env.reset()
309 episode_done = False
310 else:
311 obz = None
312 while not episode_done:

Callers

nothing calls this directly

Calls 11

actMethod · 0.95
ensure_baseline_weightsFunction · 0.85
randomize_camerasFunction · 0.85
AgentClass · 0.85
closeFunction · 0.85
resetMethod · 0.80
stepMethod · 0.80
renderMethod · 0.80
change_viewpointMethod · 0.80

Tested by

no test coverage detected