class_docstr: Encode a sequence using a Convolution Model.
class_docstr_tok: ["Encode","a","sequence","using","a","Convolution","Model","."]
docstr: Embed sequence using a layer of 2d Convolution.
docstr_tok: ["Embed","sequence","using","a","layer","of","2d","Convolution","."]
code: def embed(self, inputs, mask):
      """Embed sequence using a layer of 2d Convolution."""
      # Create CNN
      inp = inputs * tf.expand_dims(tf.cast(mask, tf.float32), -1)
      inp = tf.expand_dims(inp, -1)
      outputs = []
      for filter_width in self.filter_widths:
          w_filter, b = self.filters[filter_width]
          conv = tf.nn.conv2d(
              inp,
              w_filter,
              strides=[1, 1, 1, 1],
              padding="VALID",
              name="conv",
          )
          conv_bias = tf.nn.bias_add(conv, b)
          # conv_bias = tf.contrib.layers.batch_norm(conv_bias)
          if self.nonlinearity == "relu":
              conv_bias = tf.nn.relu(conv_bias, name="relu")
          else:
              conv_bias = tf.nn.tanh(conv_bias, name="tanh")
          pooled = tf.nn.max_pool(
              conv_bias,
              ksize=[1, self.max_seq_len - filter_width + 1, 1, 1],
              strides=[1, 1, 1, 1],
              padding="VALID",
              name="max_pool",
          )
  
          outputs.append(pooled)
      n_out = self.num_filters * len(self.filter_widths)
      h_out = tf.concat(outputs, 3)
      conv_output = tf.reshape(h_out, [-1, n_out])
  
      proj_w, proj_b = self.proj_params
      conv_embedding = tf.nn.xw_plus_b(
          conv_output, proj_w, proj_b, name="affine"
      )
      out_mask = tf.greater(tf.reduce_sum(mask, -1, keep_dims=True), 0)
      out_mask = tf.cast(out_mask, tf.float32)
      conv_embedding = conv_embedding * out_mask
      output = tf.cond(
          self.is_train,
          lambda: tf.nn.dropout(
              conv_embedding, self.dropout, name="dropout"
          ),
          lambda: conv_embedding,
      )
      return output
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  import utils
label_desc: Use image node_id 2 for calling the ConvSeqEncoder obj's underlying member method code with example usage: obj.embed(inputs, mask) and returns: output