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

[Bug] Model summary does not display submodules in execution order. #223

Open
lkhphuc opened this issue Mar 8, 2022 · 2 comments
Open
Labels
bug Something isn't working

Comments

@lkhphuc
Copy link
Contributor

lkhphuc commented Mar 8, 2022

Describe the bug
Model summary does not display submodules in execution order. I believe it's sorted in alphebetical order.
Screen Shot 2022-03-08 at 18 16 35

Reproduce

class VAE(eg.Module):
    @eg.compact
    def __call__(self, img):
        z = EncoderConv()(img)
        y = DecoderConv()(z)
        return dict(img=y, latents=z)

Expected behavior
Have the rows list in execution order, i.e encoder -> decoder would be great. I might recalled this wrong but I don't have this issue in the past.

Additional context
I found the rows are output by jax.tree_flatten, so it might not be trivial to sort the rows again based on execution order.

            flat, _ = jax.tree_flatten(self)
            tree_part_types: tp.Tuple[tp.Type[types.TreePart], ...] = tuple(
                {
                    field_info.kind
                    for field_info in flat
                    if utils._generic_issubclass(field_info.kind, types.TreePart)
                }
@lkhphuc lkhphuc added the bug Something isn't working label Mar 8, 2022
@cgarciae
Copy link
Collaborator

cgarciae commented Mar 8, 2022

Hey @lkhphuc, thanks for bringing this up. Just guessing but I think this has to do with the fact that JAX sort dict keys alphabetically. I'll look into it. Should we move this to Treex?

@lkhphuc
Copy link
Contributor Author

lkhphuc commented Mar 8, 2022

Thanks. If that's indeed due to Jax's tree_flatten then moving to treex seems more appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants