Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning resources #2918

Open
JackCaster opened this issue Feb 22, 2024 · 9 comments
Open

Learning resources #2918

JackCaster opened this issue Feb 22, 2024 · 9 comments

Comments

@JackCaster
Copy link

Hi, I stumbled upon this repo and I got excited by the opportunities in using it. I have no formal cognitive modelling training, so I am trying to get up and running by reading some of the examples you shared in the Scripts folder. Unfortunately, most of them do not run. Reasons include missing function, API changes, ... Can you recommend some resources (tutorials, simple implementations) to learn about Psyneulink?

@jdcpni
Copy link
Collaborator

jdcpni commented Feb 22, 2024 via email

@JackCaster
Copy link
Author

JackCaster commented Feb 27, 2024

I tried the tutorial but that seems outdated too. For example, in the section "Organizing into Processes" I get:

Traceback (most recent call last):
  File "/workspaces/accumulate/scrapbook/psyneulink/hello-world.py", line 18, in <module>
    linear_transfer_process = pnl.Process(pathway=[linear_transfer_mechanism])
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/__init__.py", line 107, in Process
    show_warning_sys_and_proc_warning()
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/__init__.py", line 110, in show_warning_sys_and_proc_warning
    raise ComponentError(f"'System' and 'Process' are no longer supported in PsyNeuLink; "
psyneulink.core.components.component.ComponentError: 'System' and 'Process' are no longer supported in PsyNeuLink; use 'Composition' and/or 'Pathway' instead
(project) root@20ca5cf48464:/workspaces/accumulate# 

I'll try with the Primer in the doc now.

@jdcpni
Copy link
Collaborator

jdcpni commented Feb 27, 2024 via email

@JackCaster
Copy link
Author

I am going through the Basics and primer but got stuck at Dynamics of Execution:

# Modify consruction of decision Mechanism:
decision = DDM(name='DECISION',
               input_format=ARRAY,
               reset_stateful_function_when=AtTrialStart(),
               function=DriftDiffusionIntegrator(noise=0.5, threshold=20)
               )
Stroop_model.run(inputs={color_input:red, word_input:green, task_input:color},
                 termination_processing={TimeScale.TRIAL: WhenFinished(decision)}
                 )
print (Stroop_model.results)

but received the error:

Traceback (most recent call last):
  File "/workspaces/accumulate/scrapbook/psyneulink/hello-world.py", line 96, in <module>
    Stroop_model.run(
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 749, in wrapper
    raise e
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 742, in wrapper
    return func(*args, context=context, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/compositions/composition.py", line 11332, in run
    trial_output = self.execute(inputs=execution_stimuli,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 749, in wrapper
    raise e
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 742, in wrapper
    return func(*args, context=context, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/compositions/composition.py", line 12102, in execute
    for next_execution_set in execution_sets:
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/scheduling/scheduler.py", line 160, in run
    yield from super().run(
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/scheduler.py", line 913, in run
    not termination_conds[TimeScale.ENVIRONMENT_STATE_UPDATE].is_satisfied(**is_satisfied_kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 749, in wrapper
    raise e
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 742, in wrapper
    return func(*args, context=context, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/scheduling/condition.py", line 113, in is_satisfied
    return super().is_satisfied(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/condition.py", line 1008, in is_satisfied
    return call_with_pruned_args(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/utilities.py", line 103, in call_with_pruned_args
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/condition.py", line 2249, in func
    return dependency.is_finished(execution_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 751, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/library/components/mechanisms/processing/integrator/ddm.py", line 1237, in is_finished
    abs(single_value) >= self.function._get_current_parameter_value(THRESHOLD, context)
    ^^^^^^^^^^^^^^^^^
TypeError: bad operand type for abs(): 'NoneType'

Would you be able to help?

@jdcpni
Copy link
Collaborator

jdcpni commented Feb 28, 2024 via email

@kmantel
Copy link
Collaborator

kmantel commented Mar 1, 2024

I am going through the Basics and primer but got stuck at Dynamics of Execution:

# Modify consruction of decision Mechanism:
decision = DDM(name='DECISION',
               input_format=ARRAY,
               reset_stateful_function_when=AtTrialStart(),
               function=DriftDiffusionIntegrator(noise=0.5, threshold=20)
               )
Stroop_model.run(inputs={color_input:red, word_input:green, task_input:color},
                 termination_processing={TimeScale.TRIAL: WhenFinished(decision)}
                 )
print (Stroop_model.results)

but received the error:

Traceback (most recent call last):
  File "/workspaces/accumulate/scrapbook/psyneulink/hello-world.py", line 96, in <module>
    Stroop_model.run(
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 749, in wrapper
    raise e
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 742, in wrapper
    return func(*args, context=context, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/compositions/composition.py", line 11332, in run
    trial_output = self.execute(inputs=execution_stimuli,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 749, in wrapper
    raise e
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 742, in wrapper
    return func(*args, context=context, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/compositions/composition.py", line 12102, in execute
    for next_execution_set in execution_sets:
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/scheduling/scheduler.py", line 160, in run
    yield from super().run(
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/scheduler.py", line 913, in run
    not termination_conds[TimeScale.ENVIRONMENT_STATE_UPDATE].is_satisfied(**is_satisfied_kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 749, in wrapper
    raise e
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 742, in wrapper
    return func(*args, context=context, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/scheduling/condition.py", line 113, in is_satisfied
    return super().is_satisfied(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/condition.py", line 1008, in is_satisfied
    return call_with_pruned_args(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/utilities.py", line 103, in call_with_pruned_args
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/graph_scheduler/condition.py", line 2249, in func
    return dependency.is_finished(execution_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/core/globals/context.py", line 751, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/project/lib/python3.11/site-packages/psyneulink/library/components/mechanisms/processing/integrator/ddm.py", line 1237, in is_finished
    abs(single_value) >= self.function._get_current_parameter_value(THRESHOLD, context)
    ^^^^^^^^^^^^^^^^^
TypeError: bad operand type for abs(): 'NoneType'

Would you be able to help?

The blocks of code on the primer page are less like a sequence of things to run and more like chunks of a script. So

decision = DDM(name='DECISION',
               input_format=ARRAY,
               reset_stateful_function_when=AtTrialStart(),
               function=DriftDiffusionIntegrator(noise=0.5, threshold=20)
               )

should replace

decision = DDM(name='DECISION', input_format=ARRAY)

in a script which is then rerun. Otherwise, the new DDM isn't added to the composition and pathways, it's just created on its own. This is the cause of the error above.

About the tutorial - it shouldn't be outdated to the point of not functioning. I can't find "Organizing into Processes," and processes are an old construction that we haven't used for a while. I'm interested in where you found that.

The binder link is a third party service and maybe isn't working well, but locally using jupyter, the tutorial seems to be fine for me, following the steps at https://github.com/PrincetonUniversity/PsyNeuLink/?tab=readme-ov-file#tutorial.

@kmantel
Copy link
Collaborator

kmantel commented Mar 1, 2024

@JackCaster Just to make sure, check the version of psyneulink you have installed with

python -c 'import psyneulink; print(psyneulink.__version__)'.

The current master branch is at version 0.15.1.0, which is what I tested the tutorial locally with.

@JackCaster
Copy link
Author

The blocks of code on the primer page are less like a sequence of things to run and more like chunks of a script. So

decision = DDM(name='DECISION',
               input_format=ARRAY,
               reset_stateful_function_when=AtTrialStart(),
               function=DriftDiffusionIntegrator(noise=0.5, threshold=20)
               )

should replace

decision = DDM(name='DECISION', input_format=ARRAY)

in a script which is then rerun. Otherwise, the new DDM isn't added to the composition and pathways, it's just created on its own. This is the cause of the error above.

I see. Would it be possible to add a sentence in the doc to make clear what you just explained?

About the tutorial - it shouldn't be outdated to the point of not functioning. I can't find "Organizing into Processes," and processes are an old construction that we haven't used for a while. I'm interested in where you found that.

I think I was looking at an old tutorial. I was looking at the one in the master branch on GH but realized it is 4 yr old
image
What branch should I be looking at instead?

@kmantel
Copy link
Collaborator

kmantel commented Mar 5, 2024

I see. Would it be possible to add a sentence in the doc to make clear what you just explained?

Yeah, we'll add something like this, or change it to be able to be followed in the way you expected.

I think I was looking at an old tutorial. I was looking at the one in the master branch on GH but realized it is 4 yr old image What branch should I be looking at instead?

That should be correct. It is old, but Process is even older and still shouldn't be there. Would you be able to give me some more info on what steps you followed? When I click through to tutorial/PsyNeuLink Tutorial.ipynb on master, and look at the raw file, I don't see the text pnl.Process, referencing your second comment:

I tried the tutorial but that seems outdated too. For example, in the section "Organizing into Processes" I get:

 File "/workspaces/accumulate/scrapbook/psyneulink/hello-world.py", line 18, in <module>
   linear_transfer_process = pnl.Process(pathway=[linear_transfer_mechanism])
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Did you get it by cloning the repo and then trying to run the tutorial notebook? Were you just reading it somewhere without cloning and copied code into your hello-world.py? Or something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants