GithubHelp home page GithubHelp logo

Comments (4)

yizt avatar yizt commented on June 3, 2024

@Iron4dam 感谢您的反馈;在main.py中增加了如下代码;测试resnet34没有错误;不清楚您是怎么改动channel数的, 可否详细描述下,谢谢!

    elif net_name in ['resnet34']:
        net = models.resnet34(pretrained=pretrain)

from grad-cam.pytorch.

adamxyang avatar adamxyang commented on June 3, 2024

@yizt 感谢回复!我的model是:

model = models.resnet34(pretrained=True)

kernel = model.conv1.weight
new_conv = nn.Conv2d(4, 64, kernel_size=7, stride=2, padding=3, bias=False)
with torch.no_grad():
    new_conv.weight[:,:] = torch.stack([torch.mean(kernel, 1)]*4, dim=1)
model.conv1 = new_conv

model.fc = torch.nn.Linear(512, 2)

input也是四个channel(类似RGBY),dimension是(1,4,2048,2048)

from grad-cam.pytorch.

yizt avatar yizt commented on June 3, 2024

@Iron4dam 您,我测试报了如下错:

Traceback (most recent call last):
  File "main.py", line 211, in <module>
    main(arguments)
  File "main.py", line 172, in main
    mask = grad_cam(inputs, args.class_id)  # cam mask
  File "E:\pyspace\Grad-CAM.pytorch\interpretability\grad_cam.py", line 60, in __call__
    output = self.net(inputs)  # [1,num_classes]
  File "F:\Anaconda3-5.0.1\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "F:\Anaconda3-5.0.1\envs\pytorch\lib\site-packages\torchvision\models\resnet.py", line 196, in forward
    x = self.conv1(x)
  File "F:\Anaconda3-5.0.1\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "F:\Anaconda3-5.0.1\envs\pytorch\lib\site-packages\torch\nn\modules\conv.py", line 343, in forward
    return self.conv2d_forward(input, self.weight)
  File "F:\Anaconda3-5.0.1\envs\pytorch\lib\site-packages\torch\nn\modules\conv.py", line 340, in conv2d_forward
    self.padding, self.dilation, self.groups)
RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #2 'weight'

from grad-cam.pytorch.

adamxyang avatar adamxyang commented on June 3, 2024

@yizt 这个我好像没有遇到,不过我加了一个inputs.requires_grad=True就解决了之前的问题,谢谢!

from grad-cam.pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.