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

Improper cast in rf neuron process #472

Closed
2 of 9 tasks
Michaeljurado42 opened this issue Nov 9, 2022 · 0 comments
Closed
2 of 9 tasks

Improper cast in rf neuron process #472

Michaeljurado42 opened this issue Nov 9, 2022 · 0 comments

Comments

@Michaeljurado42
Copy link
Contributor

Michaeljurado42 commented Nov 9, 2022

Objective of issue: sin_decay, and cos decay need to be casted to np.int32 instead of int. (Else you can't instantiate an array of neurons).

Lava version:

  • 0.6.0 (feature release)
  • 0.5.1 (bug fixes)
  • [] 0.5.0 (current version)
  • 0.4.1
  • 0.4.0
  • 0.3.0
  • 0.1.2

I'm submitting a ...

  • bug report
  • feature request
  • documentation request

Current behavior:

  • Rf neuron fails with array of periods passed into the neuron

Expected behavior:

  • Rf neuron should be able to be instantiated with an array or list of periods.

Steps to reproduce:

  1. Instantiate an rf neuron: neuron = RF(shape=(2,), period=np.array([10, 20]))
  2. Run the graph: neuron.run(condition=RunSteps(num_steps=num_steps, blocking=True), run_cfg=run_config)

Related code:

rf/process.py looks like this:

...
        if decay_bits > 0:
            sin_decay = int(sin_decay * (1 << decay_bits))
            cos_decay = int(cos_decay * (1 << decay_bits))

when it should look like this:

...
        if decay_bits > 0:
            sin_decay = np.int32(sin_decay * (1 << decay_bits))
            cos_decay = np.int32(cos_decay * (1 << decay_bits))

Other information:

Traceback (most recent call last):
  File "C:\Users\mjurado3\workspace\lava_dev\lava\test_resonator_process.py", line 65, in <module>
    neuron = RF(shape=(n_neurons,), period=np.array([10, 20]), alpha=alpha,
  File "C:\Users\mjurado3\workspace\lava_dev\lava-dl\.venv\lib\site-packages\lava\magma\core\process\process.py", line 33, in __call__
    obj = type.__call__(cls, *args, **kwargs)
  File "C:\Users\mjurado3\workspace\lava_dev\lava-dl\.venv\lib\site-packages\lava\proc\rf\process.py", line 71, in __init__
    sin_decay = int(sin_decay * (1 << decay_bits))
TypeError: only size-1 arrays can be converted to Python scalars

Issue came up when I was writing rf neuron code for netx.

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

1 participant