Skip to content

Commit

Permalink
update to pymdp.Agent:
Browse files Browse the repository at this point in the history
- in case inductive matrix `I` is not present,do not update it when updating transition parameters. This avoids an error in `tree_at` for updating None-valued leaves (`self.I` will be None in case `self.use_inductive = False`)
  • Loading branch information
conorheins committed Sep 24, 2024
1 parent b882927 commit fd44804
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pymdp/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,9 @@ def infer_parameters(self, beliefs_A, outcomes, actions, beliefs_B=None, lr_pA=1
# if you have updated your beliefs about transitions, you need to re-compute the I matrix used for inductive inferenece
if self.use_inductive and self.H is not None:
I_updated = vmap(control.generate_I_matrix)(self.H, E_qB, self.inductive_threshold, self.inductive_depth)
agent = tree_at(lambda x: (x.B, x.pB, x.I), agent, (E_qB, qB, I_updated))
else:
I_updated = self.I

agent = tree_at(lambda x: (x.B, x.pB, x.I), agent, (E_qB, qB, I_updated))
agent = tree_at(lambda x: (x.B, x.pB), agent, (E_qB, qB))

return agent

Expand Down

0 comments on commit fd44804

Please sign in to comment.