I would like to build a CNN from the following diagram

I presume that each time the sentence can have various lengths and it is still possible to build it.
The below is a something I found on the web but kind of got lost
ngram_filters = [2, 3, 4] conv_filters = [] for n_gram in ngram_filters: conv_filters.append(Sequential()) conv_filters[-1].add(Conv2D(1, 1, n_gram, 5)) conv_filters[-1].add(MaxPooling2D(poolsize=(nb_tokens - n_gram + 1, 1))) conv_filters[-1].add(Flatten()) model = Sequential() model.add(Merge(conv_filters, mode='concat')) The picture comes from the following blog - http://www.wildml.com/2015/11/understanding-convolutional-neural-networks-for-nlp/