Comments (4)
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
- convert the layer parameters of
ConvTransposed2d
to that ofDeconvolution
in caffe, - 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.
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.
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.
@longcw @ssdutHB
so finally, if "conv_transpose2d" can be transferred to "Deconvolution"? and how? thank you
from pytorch2caffe.
Related Issues (20)
- 'Dot' object is not iterable HOT 3
- got error: Segmentation fault (core dumped) HOT 1
- pytorch 0.4 support
- ResNet size issue -> not accepting 224
- Does one model with nn.MaxUnpool2d layers in pytorch can be transformed to caffe model?
- CudnnBatchNormBackward
- KeyError: 'MkldnnConvolutionBackward' HOT 9
- which version of pytorch and torchvision should be used? advice needed HOT 5
- AttributeError: tuple object has no attribute 'grad_fn' HOT 6
- pytorch2caffe doesn't work for the last two layyers's convertion HOT 5
- ExpandBackward HOT 3
- layer_dict的对应关系
- "dot" not found in path HOT 2
- undefined symbol: _ZN3MPI8Datatype4FreeEv HOT 2
- training error
- 关于pytorch2caffe的步骤
- convert KeyError: 'MkldnnConvolutionBackward' HOT 1
- "TypeError: argument 0 is not a Variable", torch version:0.2.0
- Can it transform LSTM layer? HOT 1
- how do i transform pth file to caffemodel? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch2caffe.