4

I want to apply a ConvNet on my one dimensional data retrieved from 13 sensors. So, each of my samples consists of 13 channels (of 51 values)

I am using 'conv1d' to apply a ConvNet on my data. The network works nicely, but I wonder how 'conv1d' determines the number of channels for it's filters... To my knowledge, a filter should have an equal number of channels as its input data, which makes it a $5x13$ filter. I set the filter to have a width of 5, but don't need to set the number of channels anywhere.

My question is: how does layer 'conv1' determine it's number of channels?

Below is a portion of my code:

# We have 13 1D channels of 51 points each

# Note that we've indicated -1 for batch size, which specifies that this dimension should be dynamically computed 
# based on the number of input values in features["x"], holding the size of all other dimensions constant.

input_layer = tf.reshape(features["x"], [-1, 51, 13])

# Convolutional Layer #1
# Shouldn't this filter also need to number of channels? 
This should match the input number of channels
conv1 = tf.layers.conv1d(inputs=input_layer, filters=32, kernel_size=5, padding="same", activation=tf.nn.relu)

# Pooling Layer #1
pool1 = tf.layers.max_pooling1d(inputs=conv1, pool_size=2, strides=2)
Ethan
  • 1,657
  • 9
  • 25
  • 39
Ben
  • 250
  • 4
  • 12

1 Answers1

2

In TensorFlow there are different convolution layers. Conv1d, Conv2d and Conv3d. the first one is used for one dimensional signals like sounds, the second one is used for images, gray-scale or RGB images and both cases are considered to be two dimensional signals. The last one is used for three dimensional signals like video frames, images as two dimensional signals vary during time. In your case Conv1d is used as one dimensional signal and you can specify the number of filters in the arguments of the method. You can take a look at here and here.

Green Falcon
  • 14,308
  • 10
  • 59
  • 98