xxradon / PytorchToCaffe

Pytorch model to caffe model, supported pytorch 0.3, 0.3.1, 0.4, 0.4.1 ,1.0 , 1.0.1 , 1.2 ,1.3 .notice that only pytorch 1.1 have some bugs
MIT License
782 stars 224 forks source link

为啥你的分析的两个代码都有bug #72

Open kaiwang960112 opened 4 years ago

kaiwang960112 commented 4 years ago

第一个bug是assert(kernel_size) == conv_dims,这个一直assert错误 第二个是import 不了resnet18. 谢谢啦。 按照你release的code执行是这样的结果

guochunhe commented 4 years ago

@kaiwang960112 这个问题 “第一个bug是assert(kernel_size) == conv_dims,这个一直assert错误” 解决了吗 ? 如果解决能否告知该如何修改?

on2022 commented 2 years ago

可以试试在analysis\layers.py 修改

class Sliding(Base): def init(self,input,kernel_size,num_out,stride=1,pad=0,name='sliding',ceil=False,transpose=False): ........ if type(kernel_size) == int: self.kernel_size = [kernel_size] * conv_dims else: assert len(kernel_size)==conv_dims self.kernel_size = [i for i in kernel_size] ........

改为 :

    if type(kernel_size) == int:
        self.kernel_size = [kernel_size] * conv_dims
    elif len(kernel_size)==1:
        self.kernel_size = [kernel_size[0]] * conv_dims
    else:
        assert len(kernel_size)==conv_dims
        self.kernel_size = [i for i in kernel_size]