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

Allow ndarrays in process_inputs #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Erotemic
Copy link

@Erotemic Erotemic commented Sep 2, 2023

Currently if the input to the model forward pass contains an ndarray it is treated as an iterable causing the error:

File ~/code/torchview/torchview/torchview.py:372, in traverse_data(data, action_fn, aggregate_fn)
    368     return aggregate(
    369         *(traverse_data(d, action_fn, aggregate_fn) for d in data)
    370     )
    371 if isinstance(data, Iterable) and not isinstance(data, str):
--> 372     return aggregate(
    373         [traverse_data(d, action_fn, aggregate_fn) for d in data]
    374     )
    375 # Data is neither a tensor nor a collection
    376 return data

TypeError: 'numpy.float64' object cannot be interpreted as an integer

This patch fixes it by simply letting ndarrays pass through as-is. Associated tests are added.

@vercel
Copy link

vercel bot commented Sep 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
torchview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 2, 2023 10:55pm

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 this pull request may close these issues.

None yet

1 participant