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

Method toggle_random_action

tensorflow_agent/agent.py:148–169  ·  view source on GitHub ↗

Reduce sampling error by diversifying experience

(self)

Source from the content-addressed store, hash-verified

146 self.obz_recording = []
147
148 def toggle_random_action(self):
149 """Reduce sampling error by diversifying experience"""
150 if self.performing_random_actions:
151 if self.action_count < self.random_action_count and self.previous_action is not None:
152 action = self.previous_action
153 else:
154 # switch to non-random
155 action = Action(has_control=False)
156 self.action_count = 0
157 self.performing_random_actions = False
158 else:
159 if self.action_count < self.non_random_action_count and self.previous_action is not None:
160 action = self.previous_action
161 else:
162 # switch to random
163 steering = np.random.uniform(-0.5, 0.5, 1)[0] # Going too large here gets us stuck
164 log.debug('random steering %f', steering)
165 throttle = 0.65 # TODO: Make throttle random to get better variation here
166 action = Action(steering, throttle)
167 self.action_count = 0
168 self.performing_random_actions = True
169 return action
170
171 def load_net(self, net_path, is_frozen=False):
172 ''&#x27;

Callers 1

actMethod · 0.95

Calls 1

ActionClass · 0.90

Tested by

no test coverage detected