candle icon indicating copy to clipboard operation
candle copied to clipboard

Trainable maxpool where kernel size != stride

Open Awpteamoose opened this issue 2 years ago • 3 comments

I'm trying to port a text detection model from PyTorch. It has a particular layer:

nn.MaxPool2d(kernel_size=3, stride=1, padding=1)

which I have ported like so:

let xs = xs.pad_with_zeros(2, 1, 1)?.pad_with_zeros(3, 1, 1)?;
let xs = xs.max_pool2d_with_stride(3, 1)?;

(I know I'm meant to pad with -inf but I was just checking if it would even start training)

I got the error:

thread 'main' panicked at src\main.rs:111:48:
called Result::unwrap() on an Err value: Msg("backward not supported for maxpool2d if ksize (3, 3) != stride (1, 1)")
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Awpteamoose avatar Jan 15 '24 14:01 Awpteamoose

that is a serious problem. I try to write a demo to train resnet but it can't work because of this error.

chenwanqq avatar Jan 31 '24 09:01 chenwanqq

oh, I meet the same problem.

https://github.com/asukaminato0721/d2l.ai-rs/blob/87e5614e9920fd1501076c1145a1ea8a3efdda8c/src/ch8/ch8_4.rs#L65

asukaminato0721 avatar Jun 15 '24 11:06 asukaminato0721

that is a serious problem. I try to write a demo to train resnet but it can't work because of this error.

here is an example https://github.com/huggingface/candle/blob/main/candle-transformers/src/models/resnet.rs

asukaminato0721 avatar Jun 15 '24 22:06 asukaminato0721