From 4d6b2ece6c658432f458b489d749d84b780828ae Mon Sep 17 00:00:00 2001 From: Steve Petersen Date: Tue, 14 Dec 2021 21:45:00 -0500 Subject: [PATCH 1/3] Two proposed fixes: 1) control.py's action_marginals should sum only over the first time step, 2) utils.py's sample(probabilities) throws an error with the argument squeezed --- inferactively_pymdp.egg-info/SOURCES.txt | 34 +++++++++++++++++++ .../dependency_links.txt | 1 + inferactively_pymdp.egg-info/requires.txt | 22 ++++++++++++ inferactively_pymdp.egg-info/top_level.txt | 1 + pymdp/control.py | 6 ++-- pymdp/utils.py | 2 +- 6 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 inferactively_pymdp.egg-info/SOURCES.txt create mode 100644 inferactively_pymdp.egg-info/dependency_links.txt create mode 100644 inferactively_pymdp.egg-info/requires.txt create mode 100644 inferactively_pymdp.egg-info/top_level.txt diff --git a/inferactively_pymdp.egg-info/SOURCES.txt b/inferactively_pymdp.egg-info/SOURCES.txt new file mode 100644 index 00000000..8c92f709 --- /dev/null +++ b/inferactively_pymdp.egg-info/SOURCES.txt @@ -0,0 +1,34 @@ +LICENSE +README.md +setup.py +inferactively_pymdp.egg-info/PKG-INFO +inferactively_pymdp.egg-info/SOURCES.txt +inferactively_pymdp.egg-info/dependency_links.txt +inferactively_pymdp.egg-info/requires.txt +inferactively_pymdp.egg-info/top_level.txt +pymdp/__init__.py +pymdp/agent.py +pymdp/control.py +pymdp/default_models.py +pymdp/inference.py +pymdp/learning.py +pymdp/maths.py +pymdp/utils.py +pymdp/algos/__init__.py +pymdp/algos/fpi.py +pymdp/algos/mmp.py +pymdp/algos/mmp_old.py +pymdp/envs/__init__.py +pymdp/envs/env.py +pymdp/envs/grid_worlds.py +pymdp/envs/mdp_search_env.py +pymdp/envs/tmaze.py +pymdp/envs/visual_foraging.py +test/test_SPM_validation.py +test/test_agent.py +test/test_control.py +test/test_demos.py +test/test_inference.py +test/test_learning.py +test/test_mmp.py +test/test_wrappers.py \ No newline at end of file diff --git a/inferactively_pymdp.egg-info/dependency_links.txt b/inferactively_pymdp.egg-info/dependency_links.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/inferactively_pymdp.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/inferactively_pymdp.egg-info/requires.txt b/inferactively_pymdp.egg-info/requires.txt new file mode 100644 index 00000000..16b4e81f --- /dev/null +++ b/inferactively_pymdp.egg-info/requires.txt @@ -0,0 +1,22 @@ +attrs>=20.3.0 +cycler>=0.10.0 +iniconfig>=1.1.1 +kiwisolver>=1.3.1 +matplotlib>=3.1.3 +nose>=1.3.7 +numpy>=1.19.5 +openpyxl>=3.0.7 +packaging>=20.8 +pandas>=1.2.4 +Pillow>=8.2.0pluggy>=0.13.1 +py>=1.10.0 +pyparsing>=2.4.7 +pytest>=6.2.1 +python-dateutil>=2.8.1 +pytz>=2020.5 +scipy>=1.6.0 +seaborn>=0.11.1 +six>=1.15.0 +toml>=0.10.2 +typing-extensions>=3.7.4.3 +xlsxwriter>=1.4.3 diff --git a/inferactively_pymdp.egg-info/top_level.txt b/inferactively_pymdp.egg-info/top_level.txt new file mode 100644 index 00000000..07673474 --- /dev/null +++ b/inferactively_pymdp.egg-info/top_level.txt @@ -0,0 +1 @@ +pymdp diff --git a/pymdp/control.py b/pymdp/control.py index 307e72de..80bfd16b 100644 --- a/pymdp/control.py +++ b/pymdp/control.py @@ -492,9 +492,9 @@ def sample_action(q_pi, policies, num_controls, action_selection="deterministic" # weight each action according to its integrated posterior probability over policies and timesteps for pol_idx, policy in enumerate(policies): - for t in range(policy.shape[0]): - for factor_i, action_i in enumerate(policy[t, :]): - action_marginals[factor_i][action_i] += q_pi[pol_idx] + for factor_i, action_i in enumerate(policy[0, :]): + # to get the marginals we just want to add up the actions at time 0 + action_marginals[factor_i][action_i] += q_pi[pol_idx] selected_policy = np.zeros(num_factors) for factor_i in range(num_factors): diff --git a/pymdp/utils.py b/pymdp/utils.py index 7d823082..1a0b9ea0 100644 --- a/pymdp/utils.py +++ b/pymdp/utils.py @@ -13,7 +13,7 @@ import itertools def sample(probabilities): - sample_onehot = np.random.multinomial(1, probabilities.squeeze()) + sample_onehot = np.random.multinomial(1, probabilities) return np.where(sample_onehot == 1)[0][0] def sample_obj_array(arr): From 95d4f03f090797f953935e736c657f7667bfb289 Mon Sep 17 00:00:00 2001 From: conorheins Date: Thu, 25 Nov 2021 17:41:42 +0100 Subject: [PATCH 2/3] Two proposed small fixes to control.py and utils.py: action_marginals should only sum over time 0, and sample(probabilities) throws an error when squeezed --- .github/{pymdp_logo.jpeg => pymdp_logo_2.jpeg} | Bin README.md | 2 +- pymdp/control.py | 6 +++--- pymdp/utils.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename .github/{pymdp_logo.jpeg => pymdp_logo_2.jpeg} (100%) diff --git a/.github/pymdp_logo.jpeg b/.github/pymdp_logo_2.jpeg similarity index 100% rename from .github/pymdp_logo.jpeg rename to .github/pymdp_logo_2.jpeg diff --git a/README.md b/README.md index 678bf0cd..7eea0bbe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

- +

diff --git a/pymdp/control.py b/pymdp/control.py index 307e72de..80bfd16b 100644 --- a/pymdp/control.py +++ b/pymdp/control.py @@ -492,9 +492,9 @@ def sample_action(q_pi, policies, num_controls, action_selection="deterministic" # weight each action according to its integrated posterior probability over policies and timesteps for pol_idx, policy in enumerate(policies): - for t in range(policy.shape[0]): - for factor_i, action_i in enumerate(policy[t, :]): - action_marginals[factor_i][action_i] += q_pi[pol_idx] + for factor_i, action_i in enumerate(policy[0, :]): + # to get the marginals we just want to add up the actions at time 0 + action_marginals[factor_i][action_i] += q_pi[pol_idx] selected_policy = np.zeros(num_factors) for factor_i in range(num_factors): diff --git a/pymdp/utils.py b/pymdp/utils.py index 7d823082..1a0b9ea0 100644 --- a/pymdp/utils.py +++ b/pymdp/utils.py @@ -13,7 +13,7 @@ import itertools def sample(probabilities): - sample_onehot = np.random.multinomial(1, probabilities.squeeze()) + sample_onehot = np.random.multinomial(1, probabilities) return np.where(sample_onehot == 1)[0][0] def sample_obj_array(arr): From d4b9cff7e40b4998c416900acb9ddaa97b9095a4 Mon Sep 17 00:00:00 2001 From: Steve Petersen Date: Wed, 15 Dec 2021 09:48:10 -0500 Subject: [PATCH 3/3] Proposed fixes to control.py and utils.py: action_marginals should only sum over time 0, and squeezing sample(probabilities) throws an error --- inferactively_pymdp.egg-info/SOURCES.txt | 34 ------------------- .../dependency_links.txt | 1 - inferactively_pymdp.egg-info/requires.txt | 22 ------------ inferactively_pymdp.egg-info/top_level.txt | 1 - 4 files changed, 58 deletions(-) delete mode 100644 inferactively_pymdp.egg-info/SOURCES.txt delete mode 100644 inferactively_pymdp.egg-info/dependency_links.txt delete mode 100644 inferactively_pymdp.egg-info/requires.txt delete mode 100644 inferactively_pymdp.egg-info/top_level.txt diff --git a/inferactively_pymdp.egg-info/SOURCES.txt b/inferactively_pymdp.egg-info/SOURCES.txt deleted file mode 100644 index 8c92f709..00000000 --- a/inferactively_pymdp.egg-info/SOURCES.txt +++ /dev/null @@ -1,34 +0,0 @@ -LICENSE -README.md -setup.py -inferactively_pymdp.egg-info/PKG-INFO -inferactively_pymdp.egg-info/SOURCES.txt -inferactively_pymdp.egg-info/dependency_links.txt -inferactively_pymdp.egg-info/requires.txt -inferactively_pymdp.egg-info/top_level.txt -pymdp/__init__.py -pymdp/agent.py -pymdp/control.py -pymdp/default_models.py -pymdp/inference.py -pymdp/learning.py -pymdp/maths.py -pymdp/utils.py -pymdp/algos/__init__.py -pymdp/algos/fpi.py -pymdp/algos/mmp.py -pymdp/algos/mmp_old.py -pymdp/envs/__init__.py -pymdp/envs/env.py -pymdp/envs/grid_worlds.py -pymdp/envs/mdp_search_env.py -pymdp/envs/tmaze.py -pymdp/envs/visual_foraging.py -test/test_SPM_validation.py -test/test_agent.py -test/test_control.py -test/test_demos.py -test/test_inference.py -test/test_learning.py -test/test_mmp.py -test/test_wrappers.py \ No newline at end of file diff --git a/inferactively_pymdp.egg-info/dependency_links.txt b/inferactively_pymdp.egg-info/dependency_links.txt deleted file mode 100644 index 8b137891..00000000 --- a/inferactively_pymdp.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/inferactively_pymdp.egg-info/requires.txt b/inferactively_pymdp.egg-info/requires.txt deleted file mode 100644 index 16b4e81f..00000000 --- a/inferactively_pymdp.egg-info/requires.txt +++ /dev/null @@ -1,22 +0,0 @@ -attrs>=20.3.0 -cycler>=0.10.0 -iniconfig>=1.1.1 -kiwisolver>=1.3.1 -matplotlib>=3.1.3 -nose>=1.3.7 -numpy>=1.19.5 -openpyxl>=3.0.7 -packaging>=20.8 -pandas>=1.2.4 -Pillow>=8.2.0pluggy>=0.13.1 -py>=1.10.0 -pyparsing>=2.4.7 -pytest>=6.2.1 -python-dateutil>=2.8.1 -pytz>=2020.5 -scipy>=1.6.0 -seaborn>=0.11.1 -six>=1.15.0 -toml>=0.10.2 -typing-extensions>=3.7.4.3 -xlsxwriter>=1.4.3 diff --git a/inferactively_pymdp.egg-info/top_level.txt b/inferactively_pymdp.egg-info/top_level.txt deleted file mode 100644 index 07673474..00000000 --- a/inferactively_pymdp.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -pymdp