Skip to content

Commit

Permalink
Fix foodlog shape
Browse files Browse the repository at this point in the history
  • Loading branch information
kngwyu committed Mar 25, 2024
1 parent c416f56 commit bf94ccd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/emevo/exp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,21 @@ def push_foodlog(self, log: FoodLog) -> None:
# Move log to CPU
self._foodlog_list.append(jax.tree_map(np.array, log))

if len(self._log_list) % self.log_interval == 0:
if len(self._foodlog_list) % self.log_interval == 0:
self._save_foodlog()

def _save_foodlog(self) -> None:
if len(self._foodlog_list) == 0:
return

all_log = jax.tree_map(
lambda *args: np.stack(args, axis=0),
lambda *args: np.concatenate(args, axis=0),
*self._foodlog_list,
)
log_dict = {}
for i in range(all_log.eaten.shape[1]):
log_dict[f"eaten_{i}"] = all_log.eaten[:, i].ravel()
log_dict[f"regen_{i}"] = all_log.regenerated[:, i].ravel()
log_dict[f"eaten_{i}"] = all_log.eaten[:, i]
log_dict[f"regen_{i}"] = all_log.regenerated[:, i]

# Don't change log_index here
pq.write_table(
Expand Down

0 comments on commit bf94ccd

Please sign in to comment.