neuralmonkey.encoders.sequence_cnn_encoder module¶
Encoder for sentence classification with 1D convolutions and max-pooling.
-
class
neuralmonkey.encoders.sequence_cnn_encoder.
SequenceCNNEncoder
(name: str, vocabulary: neuralmonkey.vocabulary.Vocabulary, data_id: str, embedding_size: int, filters: List[Tuple[int, int]], max_input_len: int = None, dropout_keep_prob: float = 1.0, reuse: neuralmonkey.model.model_part.ModelPart = None, save_checkpoint: str = None, load_checkpoint: str = None, initializers: List[Tuple[str, Callable]] = None) → None¶ Bases:
neuralmonkey.model.model_part.ModelPart
,neuralmonkey.model.stateful.Stateful
Encoder processing a sequence using a CNN.
-
__init__
(name: str, vocabulary: neuralmonkey.vocabulary.Vocabulary, data_id: str, embedding_size: int, filters: List[Tuple[int, int]], max_input_len: int = None, dropout_keep_prob: float = 1.0, reuse: neuralmonkey.model.model_part.ModelPart = None, save_checkpoint: str = None, load_checkpoint: str = None, initializers: List[Tuple[str, Callable]] = None) → None¶ Create a new instance of the CNN sequence encoder.
Based on: Yoon Kim: Convolutional Neural Networks for Sentence Classification (http://emnlp2014.org/papers/pdf/EMNLP2014181.pdf)
Parameters: - vocabulary – Input vocabulary
- data_id – Identifier of the data series fed to this encoder
- name – An unique identifier for this encoder
- max_input_len – Maximum length of an encoded sequence
- embedding_size – The size of the embedding vector assigned to each word
- filters – Specification of CNN filters. It is a list of tuples specifying the filter size and number of channels.
- dropout_keep_prob – The dropout keep probability (default 1.0)
-
embedded_inputs
¶
-
feed_dict
(dataset: neuralmonkey.dataset.Dataset, train: bool = False) → Dict[tensorflow.python.framework.ops.Tensor, Any]¶ Populate the feed dictionary with the encoder inputs.
Parameters: - dataset – The dataset to use
- train – Boolean flag telling whether it is training time
-
output
¶ Return the object output.
A 2D Tensor of shape (batch, state_size) which contains the resulting state of the object.
-