Skip to content

strange import behavior of penzai.nn and pz #114

@hrbigelow

Description

@hrbigelow

I'm confused what the intended behavior is between penzai.nn and pz and pz.nn. Here's an example of the confusing behavior. Basically, when you import nn, you don't get everything in that namespace unless you also import pz.

>>> from penzai import nn
>>> help(nn.linear_and_affine.Linear)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    help(nn.linear_and_affine.Linear)
         ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'penzai.nn' has no attribute 'linear_and_affine'
>>> from penzai import pz
>>> help(nn.linear_and_affine.Linear)
Help on class Linear in module penzai.nn.linear_and_affine:

class Linear(penzai.nn.layer.Layer)
 |  Linear(*args, **kwargs)
...

>>> help(pz.nn.linear_and_affine.Linear)
Traceback (most recent call last):
  File "<python-input-4>", line 1, in <module>
    help(pz.nn.linear_and_affine.Linear)
         ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'penzai.pz.nn' has no attribute 'linear_and_affine'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions