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

Check for complex synapse fails in create_dense #129

Closed
3 of 10 tasks
Michaeljurado42 opened this issue Nov 18, 2022 · 1 comment · Fixed by #130
Closed
3 of 10 tasks

Check for complex synapse fails in create_dense #129

Michaeljurado42 opened this issue Nov 18, 2022 · 1 comment · Fixed by #130

Comments

@Michaeljurado42
Copy link
Contributor

Michaeljurado42 commented Nov 18, 2022

Objective of issue: Check for complex synapse fails in create_dense

Lava DL version:

  • 0.3.0 (feature release)
  • 0.2.1 (bug fixes)
  • [] 0.2.0 (current version)
  • 0.1.2

Lava version:

  • 0.4.0 (feature release)
  • 0.3.1 (bug fixes)
  • [] 0.3.0 (current version)
  • 0.2.0
  • 0.1.2

I'm submitting a ...

  • bug report
  • feature request
  • documentation request

Current behavior:

In hdf5.py there is a line like this:

        if isinstance(layer_config["weight"], NetDict):

Expected behavior:

It should go like this

        if layer_config["complex_synapse"]

or like this

        if "weight/imag" in layer_config.f:

Steps to reproduce:

import torch
from lava.lib.dl import slayer, netx
import h5py

rf_neuron_params = {
    'threshold': 1.0,
    "period": 10, 
    "decay": .07,
}

class TestModel(torch.nn.Module):
    def __init__(self):
        super(TestModel, self).__init__()
        self.blocks = [slayer.block.rf.Dense(rf_neuron_params, 1, 1)]
    def forward(self, x):
        return self.blocks[0](x)
    def export_hdf5(self, filename):
        # network export to hdf5 format
        h = h5py.File(filename, 'w')
        layer = h.create_group('layer')
        for i, b in enumerate(self.blocks):
            b.export_hdf5(layer.create_group(f'{i}'))

model = TestModel()
model.forward(torch.zeros(1, 1, 1))
model.export_hdf5('network.net')

net = netx.hdf5.Network(net_config="network.net")

Related code:

Other information:

Error that is produced.

Traceback (most recent call last):
  File "/home/mjurado3/lava-dl/error_reproduce.py", line 28, in <module>
    net = netx.hdf5.Network(net_config="network.net")
  File "/home/mjurado3/lava-dl/.venv/src/lava/src/lava/magma/core/process/process.py", line 33, in __call__
    obj = type.__call__(cls, *args, **kwargs)
  File "/home/mjurado3/lava-dl/.venv/lib/python3.9/site-packages/lava/lib/dl/netx/hdf5.py", line 79, in __init__
    self.layers = self._create()
  File "/home/mjurado3/lava-dl/.venv/lib/python3.9/site-packages/lava/lib/dl/netx/hdf5.py", line 544, in _create
    layer, table = self.create_dense(
  File "/home/mjurado3/lava-dl/.venv/lib/python3.9/site-packages/lava/lib/dl/netx/hdf5.py", line 318, in create_dense
    if isinstance(layer_config["weight"], NetDict):
  File "/home/mjurado3/lava-dl/.venv/lib/python3.9/site-packages/lava/lib/dl/netx/utils.py", line 68, in __getitem__
    return self.f[key][()].astype(int).copy()
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/mjurado3/lava-dl/.venv/lib/python3.9/site-packages/h5py/_hl/group.py", line 330, in __getitem__
    raise TypeError("Accessing a group is done with bytes or str, "
TypeError: Accessing a group is done with bytes or str,  not <class 'tuple'>
@Michaeljurado42
Copy link
Contributor Author

I'll post a fix for this soon.

@Michaeljurado42 Michaeljurado42 changed the title Create dense needs to use "complex_dense" key Check for complex synapse fails in create_dense Nov 18, 2022
@bamsumit bamsumit linked a pull request Nov 30, 2022 that will close this issue
16 tasks
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

Successfully merging a pull request may close this issue.

1 participant