torchsummary() extensions by input_initializer, dtype - #89
Open
DrStoop wants to merge 1 commit into
Open
Conversation
* added 'dtype' to torchsummary input variables
* added 'input_initializer' to torchsummary input variables
Bugfix:
* total_input return TypeError:
File "/home/developer/AmI/pytorch-summary/torchsummary/torchsummary.py", line 96, in summary
total_input_size = abs(np.prod(input_size) * batch_size * 4. / (1024 ** 2.))
File "/conda/envs/rapids/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2772, in prod
initial=initial)
File "/conda/envs/rapids/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
TypeError: can't multiply sequence by non-int of type 'tuple'
This was referenced Aug 12, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
I needed to summarize the OpenAIGPTDoubleHeadsModel in huggingface/pytorch-transformers which takes as (dummy) input multiple
torch.zeors()tensors withdtype=torch.int64. This is currently not supported in the pytorch-summary tool, so I extended it.Extensions:
dtypetotorchsummary()input variablesinput_initializertotorchsummary()input variablesBugfix:
batch_sizedefault value from-1to2so it is acutally uses and returns a correcttotal_input_sizeTypeError:Testing:
run_openai_gpt.py-script after modificationrun_openai_gpt.py-script by adding the following lines after the model was loaded:To analyze the input tensors you can use this code snippet:
P.S.:
Thanks for the tool 👍, guess I'll be using it quite often... it's nice & simple with great overview!