rasa/core/policies/embedding_policy.py
def cell_input_fn(self, rnn_inputs: tf.Tensor, attention: tf.Tensor,
                      num_cell_input_memory_units: int) -> tf.Tensor:
        """Combine rnn inputs and attention into cell input.

        Args:
          rnn_inputs: Tensor, first output from `rnn_and_attn_inputs_fn`.

          attention: Tensor, concatenated all attentions for one time step.

          num_cell_input_memory_units: int, number of the first units in
                                       `attention` that are responsible for
                                       enhancing cell input.

        Returns:
          A Tensor `cell_inputs` to feed to an rnn cell.
        """

        if num_cell_input_memory_units:
            if num_cell_input_memory_units == self.embed_dim:
                # since attention can contain additional
                # attention mechanisms, only attention
                # from previous user input is used as an input
                # for rnn cell and only if memory before rnn
                # is the same size as embed_utter
                return tf.concat([rnn_inputs[:, :self.embed_dim] +
                                  attention[:, :num_cell_input_memory_units],
                                  rnn_inputs[:, self.embed_dim:]], -1)
            else:
                # in current implementation it cannot fall here,
                # but this Exception exists in case
                # attention before rnn is changed
                raise ValueError("Number of memory units {} is not "
                                 "equal to number of utter units {}. "
                                 "Please modify cell input function "
                                 "accordingly."
                                 "".format(num_cell_input_memory_units,
                                           self.embed_dim))
        else:
            return rnn_inputs
Combine rnn inputs and attention into cell input.

        Args:
          rnn_inputs: Tensor, first output from `rnn_and_attn_inputs_fn`.

          attention: Tensor, concatenated all attentions for one time step.

          num_cell_input_memory_units: int, number of the first units in
                                       `attention` that are responsible for
                                       enhancing cell input.

        Returns:
          A Tensor `cell_inputs` to feed to an rnn cell.
        
Combine rnn inputs and attention into cell input.
Combine rnn inputs and attention into cell input .
def cell_input_fn(self, rnn_inputs: tf.Tensor, attention: tf.Tensor,
                      num_cell_input_memory_units: int) -> tf.Tensor:
        if num_cell_input_memory_units:
            if num_cell_input_memory_units == self.embed_dim:
                return tf.concat([rnn_inputs[:, :self.embed_dim] +
                                  attention[:, :num_cell_input_memory_units],
                                  rnn_inputs[:, self.embed_dim:]], -1)
            else:
                raise ValueError("Number of memory units {} is not "
                                 "equal to number of utter units {}. "
                                 "Please modify cell input function "
                                 "accordingly."
                                 "".format(num_cell_input_memory_units,
                                           self.embed_dim))
        else:
            return rnn_inputs
def cell_input_fn ( self , rnn_inputs : tf . Tensor , attention : tf . Tensor , num_cell_input_memory_units : int ) -> tf . Tensor : if num_cell_input_memory_units : if num_cell_input_memory_units == self . embed_dim : return tf . concat ( [ rnn_inputs [ : , : self . embed_dim ] + attention [ : , : num_cell_input_memory_units ] , rnn_inputs [ : , self . embed_dim : ] ] , - 1 ) else : raise ValueError ( "Number of memory units {} is not " "equal to number of utter units {}. " "Please modify cell input function " "accordingly." "" . format ( num_cell_input_memory_units , self . embed_dim ) ) else : return rnn_inputs
Combine rnn inputs and attention into cell input.
Combine rnn inputs and attention into cell input .
"""Combine rnn inputs and attention into cell input.

        Args:
          rnn_inputs: Tensor, first output from `rnn_and_attn_inputs_fn`.

          attention: Tensor, concatenated all attentions for one time step.

          num_cell_input_memory_units: int, number of the first units in
                                       `attention` that are responsible for
                                       enhancing cell input.

        Returns:
          A Tensor `cell_inputs` to feed to an rnn cell.
        """ # since attention can contain additional # attention mechanisms, only attention # from previous user input is used as an input # for rnn cell and only if memory before rnn # is the same size as embed_utter # in current implementation it cannot fall here, # but this Exception exists in case # attention before rnn is changed
A Tensor `cell_inputs` to feed to an rnn cell.
A Tensor ` cell_inputs ` to feed to an rnn cell .
self
rnn_inputs
tf.Tensor
Tensor, first output from `rnn_and_attn_inputs_fn`.
Tensor first output from ` rnn_and_attn_inputs_fn ` .
attention
tf.Tensor
Tensor, concatenated all attentions for one time step.
Tensor concatenated all attentions for one time step .
num_cell_input_memory_units
int
int, number of the first units in
`attention` that are responsible for
enhancing cell input.
int number of the first units in ` attention ` that are responsible for enhancing cell input .