deepmatcher.word_aggregators

Pool

class deepmatcher.word_aggregators.Pool(*args, **kwargs)[source]

Pooling based Word Aggregator.

Takes the same parameters as the Pool module.

AttentionWithRNN

class deepmatcher.word_aggregators.AttentionWithRNN(hidden_size=None, input_dropout=0, rnn='gru', rnn_pool_style='birnn-last', score_dropout=0, input_context_comparison_network='1-layer-highway', value_transform_network=None, transform_dropout=0, input_size=None)[source]

Attention and RNN based Word Aggregator. This class can be used when the aggregation on the primary input also needs the information from the context. Specifically, the Hybrid attribute summarizer uses this aggregation approach by default. This module takes a primary input sequence and a context input sequence and computes a single summary vector for the primary input sequence based on the information in the context input. To do so, it does the following:

  1. Applies an RNN over the context input.
  2. Uses a Pool operation over the RNN to obtain a single vector summarizing the information in the context input.
  3. Based on this context summary vector, uses attention to score the relevance of each vector in the primary input sequence.
  4. Performs a weighted average of the vectors in the primary input sequence based on the computed scores to obtain a context dependent summary of the primary input sequence.
Parameters:
  • hidden_size (int) – The default hidden size to use for the RNN, input_context_comparison_network, and the value_transform_network.
  • input_dropout (float) – If non-zero, applies dropout to the input to this module. Dropout probability must be between 0 and 1.
  • rnn (string or RNN or callable) – The RNN used in Step 1 described above. Argument must specify an RNN operation.
  • rnn_pool_style (string) – The pooling operation used in Step 2 described above. Argument must specify a Pool operation.
  • score_dropout (float) – If non-zero, applies dropout to the attention scores computed in Step 3 described above. Dropout probability must be between 0 and 1.
  • input_context_comparison_network (string or Transform or callable) – The neural network that takes each vector in the primary input sequence concatenated with the context summary vector to obtain a hidden vector representing the primary vector’s relevance to the context input. Argument must specify a Transform operation.
  • value_transform_network (string or Transform or callable) – The neural network to transform the primary input sequence before taking its weighted average in Step 4 described above. Argument must be None or specify a Transform operation.
  • transform_dropout (float) – If non-zero, applies dropout to the output of the value_transform_network, if applicable. Dropout probability must be between 0 and 1.
  • input_size (int) – The number of features in the input to the module. This parameter will be automatically specified by LazyModule.