Describe the bug
For a non-regular "image", the same output size is given regardless of the kernel size.
A typical image is shaped (N, 3, H, W), but my input is multivariate timeseries signal shaped (N, 1, n_electrodes, n_timesteps) = (N, 3, 62, 1000). Where I tried to use Convolution of kernel sized (1,10) or (62, 1) to convolve along the time or electrode dimension respectively, I get the same sized output (N, 1, n_electrodes, n_timesteps), which equals to the input size.
def loop_over_all_models(x):
models_ls = get_models()
for model in models_ls:
model = model.to(device)
y = model(x)
print(f'-------------------------------------------{model.class.name}', y.shape) #torch.Size([2, 1, 62, 1000]
y = tensor_to_cpu_np(y)
test_if_zeros_are_zeros(y)
Expected behavior
A clear and concise description of what you expected to happen.
Desktop (please complete the following information):
OS: [e.g. Ubuntu 22]
Python version: [e.g. 3.8.5]
Pytorch version: [e.g. 1.9.1]
CUDA version: [e.g. 11.1]
NVIDIA Driver version: [e.g. 450.11]
Minkowski Engine version [e.g. 0.5.42]
Output of the following command. (If you installed the latest MinkowskiEngine, paste the output of python -c "import MinkowskiEngine as ME; ME.print_diagnostics()". Otherwise, paste the output of the following command.)
Describe the bug For a non-regular "image", the same output size is given regardless of the kernel size.
A typical image is shaped (N, 3, H, W), but my input is multivariate timeseries signal shaped (N, 1, n_electrodes, n_timesteps) = (N, 3, 62, 1000). Where I tried to use Convolution of kernel sized (1,10) or (62, 1) to convolve along the time or electrode dimension respectively, I get the same sized output (N, 1, n_electrodes, n_timesteps), which equals to the input size.
This is not right.
kernel = (1,10) , expected output (N, 1, n_eletrodes, n_timsteps - kernel size + 1), actual output (N, 1, n_eletrodes, n_timsteps) kernel = (62,1) , expected output (N, 1, 1, n_timsteps), actual output (N, 1, n_eletrodes, n_timsteps)
To Reproduce
import torch import torch.nn as nn import numpy as np
from MinkowskiEngine import ( MinkowskiConvolution, MinkowskiELU, MinkowskiLinear, MinkowskiReLU, MinkowskiMaxPooling, MinkowskiBatchNorm, MinkowskiDropout,
) from MinkowskiOps import ( to_sparse, )
`class ToyCNN(nn.Module): def init(self): super(ToyCNN, self).init() self.conv1 = nn.Sequential( MinkowskiConvolution( in_channels=1, out_channels=1, kernel_size=10, stride=1, dilation=1,
has_bias=False,
class SpatialKernerl(ToyCNN): def init(self): super(SpatialKernerl, self).init() self.conv1 = nn.Sequential( MinkowskiConvolution( in_channels=1, out_channels=1, kernel_size=(62,1), stride=1, dilation=1,
has_bias=False,
class TemporalKernerl(ToyCNN): def init(self): super(TemporalKernerl, self).init() self.conv1 = nn.Sequential( MinkowskiConvolution( in_channels=1, out_channels=1, kernel_size=(1,10), stride=1, dilation=1,
has_bias=False,
def test_if_zeros_are_zeros(x): dash = '-'*20 print(f'{dash}test_if_zeros_are_zeros{dash}') print(x[:, :, :, 100:200] == 0) #100 zeros print(x[:, :, :, 300:350] == 0) #50 zeros print(x[:, :, :, 500:600] == 0) #100 zeros
def tensor_to_cpu_np(x): return x.cpu().detach().numpy()
def get_models(): return [ TemporalKernerl(), SpatialKernerl(),
def loop_over_all_models(x): models_ls = get_models() for model in models_ls: model = model.to(device) y = model(x) print(f'-------------------------------------------{model.class.name}', y.shape) #torch.Size([2, 1, 62, 1000] y = tensor_to_cpu_np(y) test_if_zeros_are_zeros(y)
return y
if name == 'main':
``
Expected behavior A clear and concise description of what you expected to happen.
Desktop (please complete the following information):
python -c "import MinkowskiEngine as ME; ME.print_diagnostics()"
. Otherwise, paste the output of the following command.)Additional context Add any other context about the problem here.