Closed lijiayi9712 closed 1 year ago
@lijiayi9712 The reason you are getting None
values for mean and standard deviation and the consequent assertion error is because the condition for eventually calculating those values are not met when your episode has only 10 time steps.
The condition is if self.time_step >= self.standardize_start_time_step and self.batch_size <= len(self.replay_buffer[i])
(see in code).
So, to solve the error, you need to make sure that by the time you exceed end_exploration_time_step
, you have collected enough samples in the replay buffer that it is less than or equal to batch_size
(or you reduce the batch size to something < 10). You also want to make sure that self.time_step >= self.standardize_start_time_step
evaluates to True
at that time.
Thanks! I modified the steps and it worked!
Issue Description
When i run: " from citylearn.citylearn import CityLearnEnv from citylearn.agents.sac import SAC as RLAgent
dataset_name = 'baeda_3dem' env = CityLearnEnv(dataset_name, central_agent=False, simulation_end_time_step=10) model = RLAgent(env) model.learn(episodes=2, deterministic_finish=True) "
I get this: " obs: [-2.44929360e-16 1.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 5.40640817e-01 8.41253533e-01 2.39775427e-01 -1.93590194e-08 6.18397155e-01 3.73208446e-01 0.00000000e+00 5.10551796e-01 0.00000000e+00 0.00000000e+00 4.57856874e-09 4.57856874e-09 4.57856874e-09 4.57856874e-09 4.95913909e-01 0.00000000e+00 0.00000000e+00 3.75607514e-01] mean: None std: None " with the trace back: "--------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~/opt/anaconda3/lib/python3.8/site-packages/citylearn/agents/sac.py in get_normalized_observations(self, index, observations) 230 try: --> 231 return (np.array(observations, dtype = float) - self.norm_mean[index])/self.norm_std[index] 232 except:
TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
During handling of the above exception, another exception occurred:
AssertionError Traceback (most recent call last)