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

TypeError: summary() got an unexpected keyword argument 'dtypes' #206

Closed
vfdff opened this issue Nov 2, 2024 · 1 comment
Closed

TypeError: summary() got an unexpected keyword argument 'dtypes' #206

vfdff opened this issue Nov 2, 2024 · 1 comment

Comments

@vfdff
Copy link

vfdff commented Nov 2, 2024

The test is come from the user guide, https://pypi.org/project/torch-summary

import torch
import torch.nn as nn
import torch.nn.functional as F
from torchsummary import summary

class LSTMNet(nn.Module):
    """ Batch-first LSTM model. """
    def __init__(self, vocab_size=20, embed_dim=300, hidden_dim=512, num_layers=2):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.embedding = nn.Embedding(vocab_size, embed_dim)
        self.encoder = nn.LSTM(embed_dim, hidden_dim, num_layers=num_layers, batch_first=True)
        self.decoder = nn.Linear(hidden_dim, vocab_size)

    def forward(self, x):
        embed = self.embedding(x)
        out, hidden = self.encoder(embed)
        out = self.decoder(out)
        out = out.view(-1, out.size(2))
        return out, hidden

summary(
    LSTMNet(),
    (100,),
    dtypes=[torch.long],
    branching=False,
    verbose=2,
    col_width=16,
    col_names=["kernel_size", "output_size", "num_params", "mult_adds"],
)

and my local error information:

[root@huawei-pc mytest]# python test3.py 
Traceback (most recent call last):
  File "/home/zhongyunde/mytest/test3.py", line 22, in <module>
    summary(
TypeError: summary() got an unexpected keyword argument 'dtypes'

similar to ##193, but with detail test

@vfdff
Copy link
Author

vfdff commented Nov 2, 2024

  • solution

pip uninstall torchsummary # 卸载原来的torchsummary库
pip install torch-summary==1.4.4 # 安装升级版本torch-summary

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

No branches or pull requests

1 participant