Keras - 1D Convolution How It Works

In this example: https://github.com/fchollet/keras/blob/master/examples/imdb_cnn.py

this snippet appears below. The injection level displays a 400 x 50 matrix for each example in the package. My question is: how does 1D convolution work? How does it work through a 400 x 50 matrix?

# we start off with an efficient embedding layer which maps # our vocab indices into embedding_dims dimensions model.add(Embedding(max_features, embedding_dims, input_length=maxlen, dropout=0.2)) # we add a Convolution1D, which will learn nb_filter # word group filters of size filter_length: model.add(Convolution1D(nb_filter=nb_filter, filter_length=filter_length, border_mode='valid', activation='relu', subsample_length=1)) 
+8
neural-network keras convolution
source share
1 answer

In convolutional neural networks (CNN), 1D and 2D filters are not 1 and 2-dimensional. This description is for description.

In your example, each 1D filter is actually an Lx50 filter, where L is the filter length parameter. Convolution is performed in only one dimension. Perhaps this is called 1D. Thus, when properly filled, each convolution of the 1D filter gives a 400 × 1 vector. The Convolution1D layer will eventually output the 400 * nb_filter .

+8
source share

All Articles