0
$\begingroup$

i'm trying to implement this paper and I'm stuck for quite some time now. Here is the issue:

I have a 3D tensor and has (180,200,20) as dimension and I'm trying to append 5 of them as the paper states:

Now that each frame is represented as a 3D tensor, we can append multiple frames’ along a new temporal dimension to create a 4D tensor

what I did is I applied the tensorflow command tf.stack() and now so far so good, I have my input as a 4D tensor and has (5,180,200,20) as stated in the paper:

Thus our input is a 4 dimensional tensor consisting of time, height, X and Y

Now what I'm trying to do is to apply a 1D convolution on this 4D tensor as the paper mentions:

given a 4D input tensor, we first use a 1D convolution with kernel size n on temporal dimension to reduce the temporal dimension from n to 1

is this case n = 5.

And here where I got stuck, I created the kernel as follow:

kernel = tf.Variable(tf.truncated_normal([5,16,16], dtype = tf.float64, stddev = 1e-1, name = 'weights'))

and tried to apply a 1D convolution:

conv = tf.nn.conv1d(myInput4D, kernel, 1 , padding = 'SAME')

and I get this error

Shape must be rank 4 but is rank 5 for 'conv1d_42/Conv2D' (op: 'Conv2D') with input shapes: [5,180,1,200,20], [1,5,16,16]

I don't understand how 1 is added to the dimensions at the index = 2 and index = 0 in the first and second tensors.

I also tried this:

conv = tf.layers.conv1d(myInput4D, filters = 16, kernel_size = 5, strides = 1, padding = 'same)

And get the following error:

Input 0 of layer conv1d_4 is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: [5, 180, 200, 20]

My question is: Is it possible to apply a 1D convolution on a 4D input and if yes can anyone suggests a way to do so? Because in the Tenssorflow documentations it says the input must be 3D

tf.nn.conv1d( value=None, filters=None, stride=None, padding=None, use_cudnn_on_gpu=None, data_format=None, name=None, input=None, dilations=None )

value: A 3D Tensor. Must be of type float16, float32, or float64.

Thank you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.