I am trying to implement the
“Time-series modeling with undecimated fully convolutional neural networks, by Roni Mittelman” using pytorch. For that I am using Conv1d on a simple cos function to test my model.
my COS tensor is of the shape : <1,64,1>
and I declare my convolutions as follow :
The arguments being, in order, 1 feature input per timestep, 150 features generated, …
and you would feed it data of shape (batch_size, features, timesteps), in your case (1, 1, 64).
The padding is complicated because you need the right amount of padding on one side in order to ensure that the output at time t does not see any input from time t+1.
Thank you very much my mistake was in the input shape and input size
I have an other stupid questions :
one of my convolution take as input, two outputs from two past Relus. Those inputs must be summed . I did the stupid first thing that came up to my mind which is a simple addition which obviously gives me the error:
RuntimeError: The size of tensor a (60) must match the size of tensor b (56) at non-singleton dimension 2
Any idea ?
thanks a lot for your link I am looking at it to apply it to my code
Again, I am guessing…
One of these outputs has passed through one Conv1d, the other has passed through two Conv1d’s.
I think the problem is that each Conv1d hasn’t got enough padding, so the input sequence got shortened to 60 timesteps after one Conv1d, and then to 56 timesteps after the two Conv1d’s.
Therefore you can’t add them together because the sequence length doesn’t match up.
I think if you correct the padding used in the Conv1d’s, then the problem will go away.
In pytorch you can do Conv1d(..., padding=(kernel_size // 2)) which is equivalent to padding=“same” for odd kernel sizes. But that wouldn’t give you causal convolutions.
However Keras now has padding=“causal” for which pytorch has no easy equivalent.
I’m confused about this. If I have a 1D data set of size 1 by D and want to apply a 1D convolution of kernel size K and the number of filters is F, how does one do it?
Should do the trick, then use it in the forward function. For the parameters take a look at the doc.
I should do a github for the implementation I did.