Created
August 12, 2016 03:41
-
-
Save AlbertXiebnu/7a1e2521d5963550ff3c381474d4034b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## from github discuss | |
ngram_filters = [3, 4, 5, 6, 7, 8] | |
conv_filters = [] | |
for n_gram in ngram_filters: | |
conv_filters.append(Sequential()) | |
conv_filters[-1].add(Convolution2D(nb_feature_maps, 1, n_gram, wv_sz)) | |
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')) | |
model.add(Dropout(0.5)) | |
model.add(Dense(nb_feature_maps * len(ngram_filters), 1)) | |
model.add(Activation('sigmoid')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment