Convolution layers

For one-dimensional convolutional, layers we can use keras.layers.Conv1D. We will need to use MaxPooling1D layers to go along with our Conv1D layers, as shown in the following code:

x = Conv1D(128, 5, activation='relu')(embedding_layer)x = MaxPooling1D(5)(x)x = Conv1D(128, 5, activation='relu')(x)x = MaxPooling1D(5)(x)x = Conv1D(128, 5, activation='relu')(x)x = GlobalMaxPooling1D()(x)

For the Conv1D layers, the first integer argument is the number of units and the second is the filter size. Our filter only has one dimension, hence the name 1D convolution. Our window size in the preceding example is 5.

The MaxPooling1D layers that I'm using will also use a window size of 5. The same rules apply for the pooling layers in ...

Get Deep Learning Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.