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

cuba.Affine layer cannot be exported to hdf5 #221

Closed
ahenkes1 opened this issue Aug 12, 2023 · 0 comments · Fixed by #222
Closed

cuba.Affine layer cannot be exported to hdf5 #221

ahenkes1 opened this issue Aug 12, 2023 · 0 comments · Fixed by #222
Labels
0-needs-review 1-bug Something isn't working

Comments

@ahenkes1
Copy link
Contributor

Describe the bug
A network consisting of an cuba.Affine layer cannot be exported to hd5f due to missing shape information. This is caused by h5py interpreting the missing shapes ('None') as object type ('O'), which is not supported by the hd5f format.

To reproduce current behavior
Steps to reproduce the behavior:

        in_features = 10
        out_features = 5

        # create slayer network and evaluate output
        net = slayer.block.cuba.Affine(neuron_param, in_features, out_features)

        # export slayer network
        net.export_hdf5(
            h5py.File(tempdir + "/cuba_affine.net", "w").create_group(
                "layer/0"
            )
        )

Expected behavior
The export should work.

Environment (please complete the following information):

  • Device: Laptop
  • OS: Ubuntu
  • Lava version 0.8.0, DL version 0.4.0

Additional context
I already fixed the problem by inferring the shapes from the respective Dense layer (see PR).

@ahenkes1 ahenkes1 added the 1-bug Something isn't working label Aug 12, 2023
@ahenkes1 ahenkes1 mentioned this issue Aug 12, 2023
7 tasks
@bamsumit bamsumit linked a pull request Aug 16, 2023 that will close this issue
7 tasks
bamsumit added a commit that referenced this issue Sep 9, 2023
* E501.

The test file failed with message:

    'test_cuba.py:19:80: E501 line too long (80 > 79 characters)'

Fixed by reformatting.

* Added test for Affine hdf5 export.

The test will fail, if a network consisting of an Affine layer cannot be
exported. This is the case, e.g., if the layer has no shape ('none'). In that
case, h5py will interpret it as an ('o') object, which is not supported by the
hdf5 format.

* Dense -> Affine.

* Added shape.

The shape of the Affine layer is set with respect to the output of the
respective Dense layer. Previously this was 'None', resulting in an error while
exporting to hdf5 due to being interpreted as object type by h5py. Now
everything works due to being set to Float.

* Changed the shape to 'torch.Size()'.

* Added two tests for different modes of the "dynamics" flag.

Currently, both tests are failing. This is due to 'l.394' of
'/lib/dl/slayer/block/base.py' not being executed. This has to be fixed (?).

* Some corrections to the temp_file names.

* Added 'vThMant' export in 'base.py'.

* Added modiefied tests. Still failing.

* 'neuron' in ... -> 'neuron' not in. 1/2 pass.

* Set threshold=-1 and corrected 1 << 17 to 1 << 18.

* Check 'vThMant' in h5 file.

---------

Co-authored-by: PhilippPlank <32519998+PhilippPlank@users.noreply.github.com>
Co-authored-by: bamsumit <bam_sumit@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-needs-review 1-bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant