Reputation: 417
I'm looking at Keras' example for convolutional neural networks. (See https://github.com/fchollet/keras/blob/master/examples/imdb_cnn.py for example.) However, I cannot figure out what they mean by the "maxlen" parameter. Would it have something to do with padding? It isn't the maximum number of features; they have a max_features parameter for that.
Upvotes: 3
Views: 209
Reputation: 10174
The maxlen
parameter is the length of your text samples in words.
In the Keras code example you have these settings:
# set parameters:
max_features = 5000
maxlen = 400
...
embedding_dims = 50
This means you have a vocabulary of 5000 words, each of these words are embedded into a feature vector with 50 dimensions and each of your text samples can be 400 words long.
Indirectly this also has a relation to padding when you have text samples that are shorter than 400 words. Then you have to pad these to a length of 400.
For 1D-ConvNets for text classification see also this paper and this blog post:
https://arxiv.org/abs/1408.5882
http://www.wildml.com/2015/11/understanding-convolutional-neural-networks-for-nlp/
Upvotes: 2