小白菜~ 2021-07-02 22:49 采纳率: 0%
浏览 97

跑VGG16网络报错: not all arguments converted during

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-32-12a4df166eda> in <module>
    118 
    119 if __name__ == '__main__':
--> 120     main()

<ipython-input-32-12a4df166eda> in main()
     64 
     65     model_name = "vgg16"
---> 66     net = vgg(model_name=model_name, num_classes=5, init_weights=True)
     67     net.to(device)
     68     loss_function = nn.CrossEntropyLoss()

~/Jupyter-notebook/pytorch学习/VGG-16/model.py in vgg(model_name, **kwargs)
     76         print('Warning: model number {} not in cfgs dict'.format(model_name))
     77         exit(-1)
---> 78     model = VGG(make_features(cfg), **kwargs)  # 长度可变的字典变量
     79     return model
     80 

~/Jupyter-notebook/pytorch学习/VGG-16/model.py in make_features(cfg)
     55                     layers += [nn.MaxPool2d(kernel_size=2, stride=2)]
     56                 else:
---> 57                     conv2d = nn.Conv2d(in_channel, v, kernel_size=3, stride=1, padding=1)
     58                     layers += [conv2d, nn.ReLU(True)]
     59                 in_channel = v

~/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py in __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation, groups, bias, padding_mode)
    384         padding_ = _pair(padding)
    385         dilation_ = _pair(dilation)
--> 386         super(Conv2d, self).__init__(
    387             in_channels, out_channels, kernel_size_, stride_, padding_, dilation_,
    388             False, _pair(0), groups, bias, padding_mode)

~/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py in __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation, transposed, output_padding, groups, bias, padding_mode)
     77                  padding_mode: str) -> None:
     78         super(_ConvNd, self).__init__()
---> 79         if in_channels % groups != 0:
     80             raise ValueError('in_channels must be divisible by groups')
     81         if out_channels % groups != 0:

TypeError: not all arguments converted during string formatting
  • 写回答

1条回答 默认 最新

  • 屁话精 2021-07-13 15:24
    关注

    请问这个问题你现在解决了吗

    评论

报告相同问题?

悬赏问题

  • ¥15 我想在WPF的Model Code中获取ViewModel Code中的一个参数
  • ¥15 arcgis处理土地利用道路 建筑 林地分类
  • ¥20 使用visual studio 工具用C++语音,调用openslsx库读取excel文件的sheet问题
  • ¥100 寻会做云闪付tn转h5支付链接的技术
  • ¥15 DockerSwarm跨节点无法访问问题
  • ¥15 使用dify通过OpenAI 的API keys添加OpenAI模型时报了“Connection Error”错误
  • ¥40 想找个软件,但我不知道怎么找到它,我甚至不知道有没有
  • ¥15 怎么把60秒的视频时长改成显示0秒?且视频内容没有任何变化的正常播放?目的是为了解决一些平台对视频时长的要求,最好有自动处理的工具!
  • ¥15 累加器设初值为00H
  • ¥15 webAPI接口返回值判断