tsong.me | would appreciate it if you provide a link | Static Site Generator library
kandi X-RAY | tsong.me Summary
kandi X-RAY | tsong.me Summary
This site is available at (with decreasing priority).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tsong.me
tsong.me Key Features
tsong.me Examples and Code Snippets
Community Discussions
Trending Discussions on tsong.me
QUESTION
I'm currently trying to implement a piecewise max pooling operation in Tensorflow, as described here. Given a sentence, I want to divide it to three different portions and max pool all of those portions separately, so that I'd end up with 3 different values instead of 1.
More concretely, I have a tensor training
of shape [batch_len, 1, sentence_len, feature_len]
. I also have another tensor splits
of shape [batch_len, 2]
, where the first element of any row is the index to split off the first portion, and the second element is the index to split off the last portion. I want to index the training
tensor in a way that divides it into tree parts based on the value index values provided in the splits
tensor.
We cannot simply index the training
tensor using the other tensor, as we have different lengths for the first, second, and third portions for different examples. I could loop through all the training data and do it that way, but that would be horribly inefficient. I want to make this as efficient as possible.
Note: since they will be max pooled, I'm fine with having 3 different tensors of shape [batch_len, 1, sentence_len, feature_len]
, where in the first tensor, only the elements in the first portion of each sentence has values, and the others have zero. The second tensor would only have values in the middle part, and so on.
ANSWER
Answered 2018-Apr-27 at 08:59Exploring and implementing PCNN model leads me to the same problem: splitting borders (positions of entities) may vary in input.
To implement piecewise max pooling, the combination of tf.split
calls for obtaining three parts and tf.pad
call for each part were used. Then we apply tf.nn.max_pool
to perform max pooling for each padded part.
Here is a tensorflow implementation of PCNN model as an application for sentiment classification. Here is an exact position of the network description in code.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tsong.me
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page