akataba / rl-repo

Contains different reinforcement learning models
3 stars 3 forks source link

Fix bug in save_env_transitions #25

Closed Farquhar13 closed 8 months ago

Farquhar13 commented 9 months ago

Issue with saving in the numpy format.

I believe the issue can be solved by unpacking the lists in self.env_transitions of the environment classes.

  File "/Users/collinfarquhar/Code/rl-repo/src/relaqs/save_results.py", line 98, in save_env_transitions
    np.save(f, np.array(self.env.transition_history))

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (2002, 5) + inhomogeneous part.
Farquhar13 commented 9 months ago

The change where the list unpacking was lost was introduced in this commit on these lines.

@akataba, is the format you've introduced here for the self.env_transitions object relied on by any analysis code or can we change it back?

akataba commented 9 months ago

@Farquhar13 This allowed me to format the saved CSV file in such a way that for a pandas frame each column in the CSV file can correspond to a column in the pandas dataframe and each row easily correspond to an episode. I forget the details but the essence is that the pandas dataframes would be easier to use.

Farquhar13 commented 9 months ago

@akataba thanks! I think using a pandas dataframe is a good idea. I'll work on switching over to that.