Coder Social home page Coder Social logo

condconv-pytorch's People

Contributors

lxtgh avatar nibuiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

condconv-pytorch's Issues

Ask a question.

Dear author,

Can this code implement one-dimensional convolution?
Thanks.

Can't support batch size >1

When the batch size > 1, will get a error of mismatch size for shape. The reason is beacuse the operation of flatten and dropout in defination of _routing. Hope you can fix this bug.

AttributeError: 'CondConv2D' object has no attribute '_padding_repeated_twice'

To Reproduce

import torch
from condconv import CondConv2D

inp = torch.rand((2,3,12,12))

f = CondConv2D(3, 6, (3,3), stride=1,
                 padding=1, dilation=1, groups=1,
                 bias=True, padding_mode='replicate', num_experts=3, dropout_rate=0.2)

f(inp)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[354], line 1
----> 1 f(inp).shape

File ~/miniconda3/envs/license-plate/lib/python3.8/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
   1496 # If we don't have any hooks, we want to skip the rest of the logic in
   1497 # this function, and just call forward.
   1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1499         or _global_backward_pre_hooks or _global_backward_hooks
   1500         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501     return forward_call(*args, **kwargs)
   1502 # Do not call functions when jit is used
   1503 full_backward_hooks, non_full_backward_hooks = [], []

Cell In[348], line 82, in CondConv2D.forward(self, inputs)
     80     routing_weights = self._routing_fn(pooled_inputs)
     81     kernels = torch.sum(routing_weights[: ,None, None, None, None] * self.weight, 0)
---> 82     out = self._conv_forward(input, kernels)
     83     res.append(out)
     84 return torch.cat(res, dim=0)

Cell In[348], line 68, in CondConv2D._conv_forward(self, input, weight)
     66 def _conv_forward(self, input, weight):
     67     if self.padding_mode != 'zeros':
---> 68         return F.conv2d(F.pad(input, self._padding_repeated_twice, mode=self.padding_mode),
     69                         weight, self.bias, self.stride,
     70                         _pair(0), self.dilation, self.groups)
     71     return F.conv2d(input, weight, self.bias, self.stride,
     72                     self.padding, self.dilation, self.groups)

File ~/miniconda3/envs/license-plate/lib/python3.8/site-packages/torch/nn/modules/module.py:1614, in Module.__getattr__(self, name)
   1612     if name in modules:
   1613         return modules[name]
-> 1614 raise AttributeError("'{}' object has no attribute '{}'".format(
   1615     type(self).__name__, name))

AttributeError: 'CondConv2D' object has no attribute '_padding_repeated_twice'
  • Pytorch version: '2.0.1+cu117'
  • OS: WSL Ubuntu 22.04
  • Python version: 3.8.18
  • How you installed PyTorch: conda.

size mismatch

class Model(nn.Module):
def init(self, num_experts):
super(Model, self).init()
self.condconv2d = CondConv2D(10, 128, kernel_size=1)

def forward(self, x):
    x = self.condconv2d(x)

if name == "main":
"""Testing
"""
inputs = torch.rand(1,3,224,224)
model=Model(num_experts=3)
y = model(inputs)
print(y)
print(model)

I got the following error:
RuntimeError: size mismatch, m1: [1 x 3], m2: [10 x 3] at ..\aten\src\TH/generic/THTensorMath.cpp:961
could you tell me how to solve it? Thanks!

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.