pcnn | 使用pcnn网络进行关系分类,中文注解,有数据集,可跑通。附带绘图
kandi X-RAY | pcnn Summary
kandi X-RAY | pcnn Summary
使用pcnn网络进行关系分类,中文注解,有数据集,可跑通。附带绘图
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Iterate through the corpus
- Updates the histogram .
- Run one epoch
- generator of minibatches
- Draw a visual representation of the evaluation .
- Return a function to get a processing word .
- helper function to create a bag
- Pad a sequence of sequences .
- Get a logger .
- returns piece of data
pcnn Key Features
pcnn Examples and Code Snippets
Community Discussions
Trending Discussions on pcnn
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 pcnn
You can use pcnn like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
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