Giter VIP home page Giter VIP logo

Comments (4)

longcw avatar longcw commented on July 17, 2024

I think it's feasible and easy to convert torch.nn.ConvTransposed2d to Deconvolution since I already did that for UpsamplingBilinear2d. But I don't have enough time to implement it now.
You can follow here to implement it. You need to

  1. convert the layer parameters of ConvTransposed2d to that of Deconvolution in caffe,
  2. and check if weight and bias of ConvTransposed2d are saved properly for caffe: https://github.com/longcw/pytorch2caffe/blob/master/pytorch2caffe.py#L101

from pytorch2caffe.

ssdutHB avatar ssdutHB commented on July 17, 2024

Hi, longcw. Thanks for your quick reply. Yesterday, I transferred "conv_transpose2d" from pytorch to caffe as what you said above. But I found that there is a parameter "output_padding" in "conv_transpose2d". That optional parameter will add specific padding to the result of deconvolution, so that the user can get a specific output shape. But the Decovolution layer in caffe has no such parameter. So it's a problem now for me.
Consider, if we want to convert a deconv layer from pytorch, which is "nn.ConvTranspose2d(128,128,kernel_size =3,stride=2,padding =1,output_padding = 1)",
How can we write a caffe layer?

The code above can convert a tensor with shape(batch,channel,width,height) to shape(batch,channel,widthx2,heightx2).

if we write a caffe layer with above parameter
layer {
name: "ConvNdBackward73"
type: "Deconvolution"
bottom: "AddBackward72"
top: "ConvNdBackward73"
convolution_param {
num_output: 128
pad: 1
kernel_size: 3
stride: 2
bias_term: false
}
}

we get (batch,channel,width,height) to (batch,channel,widthx2-1.heightx2-1)

In conclusion, I think the deconv operation in pytorch can't be perfectly converted to caffe. Am I right?

from pytorch2caffe.

longcw avatar longcw commented on July 17, 2024

So the only difference is the output_padding. If the output_padding is not zero then we will need an extra "padding layer" (?) in caffe. BTW, welcome to send pull requests for your improvement.

from pytorch2caffe.

OPPOA113 avatar OPPOA113 commented on July 17, 2024

@longcw @ssdutHB
so finally, if "conv_transpose2d" can be transferred to "Deconvolution"? and how? thank you

from pytorch2caffe.

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.