MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / _init_params

Method _init_params

numpy_ml/rl_models/agents.py:164–193  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

162 self._init_params()
163
164 def _init_params(self):
165 E = self.env_info
166 assert not E["continuous_actions"], "Action space must be discrete"
167
168 self._create_2num_dicts()
169 b_len = np.prod(E["n_actions_per_dim"])
170 W_len = b_len * np.prod(E["obs_dim"])
171 theta_dim = b_len + W_len
172
173 # init mean and variance for mv gaussian with dimensions theta_dim
174 theta_mean = np.random.rand(theta_dim)
175 theta_var = np.ones(theta_dim)
176
177 self.parameters = {"theta_mean": theta_mean, "theta_var": theta_var}
178 self.derived_variables = {
179 "b_len": b_len,
180 "W_len": W_len,
181 "W_samples": [],
182 "b_samples": [],
183 "episode_num": 0,
184 "cumulative_rewards": [],
185 }
186
187 self.hyperparameters = {
188 "agent": "CrossEntropyAgent",
189 "retain_prcnt": self.retain_prcnt,
190 "n_samples_per_episode": self.n_samples_per_episode,
191 }
192
193 self.episode_history = {"rewards": [], "state_actions": []}
194
195 def act(self, obs):
196 r"""

Callers 1

__init__Method · 0.95

Calls 1

_create_2num_dictsMethod · 0.80

Tested by

no test coverage detected