class_docstr: Encode a sequence using a Convolution Model.
class_docstr_tok: ["Encode","a","sequence","using","a","Convolution","Model","."]
code: def __init__(
      self,
      emb_dim,
      input_dim,
      max_seq_len,
      is_train,
      train_dropout=1.0,
      filter_widths=(1, 2),
      num_filters=64,
      scope="CNN",
      nonlinearity="tanh",
  ):
      super(ConvSeqEncoder, self).__init__()
      self.max_seq_len = max_seq_len
      self.emb_dim = emb_dim
      self.filter_widths = filter_widths
      self.num_filters = num_filters
      self.filters = {}
      self.is_train = is_train
      self.dropout = train_dropout
      self.input_dim = input_dim
      self.nonlinearity = nonlinearity
      with tf.variable_scope(scope):
          for filter_width in self.filter_widths:
              filter_shape = [
                  filter_width,
                  self.input_dim,
                  1,
                  self.num_filters,
              ]
              w_filter = tf.get_variable(
                  "W_filterwidth%d" % filter_width,
                  shape=filter_shape,
                  dtype=tf.float32,
                  initializer=tf.truncated_normal_initializer(),
              )
              b = tf.get_variable(
                  "b_filterwidth%d" % filter_width,
                  shape=[self.num_filters],
                  dtype=tf.float32,
                  initializer=tf.constant_initializer(0.1),
              )
              self.filters[filter_width] = (w_filter, b)
          n_out = self.num_filters * len(self.filter_widths)
          w_final = tf.get_variable(
              "W_affine",
              shape=[n_out, self.emb_dim],
              initializer=tf.glorot_uniform_initializer(),
          )
          b_final = tf.get_variable(
              "b_afffine",
              shape=[self.emb_dim],
              initializer=tf.constant_initializer(0.01),
          )
          self.proj_params = (w_final, b_final)
  
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 1 to create a new ConvSeqEncoder object from inherited base classes: Encoder with example: obj = ConvSeqEncoder(emb_dim, input_dim, max_seq_len, is_train, train_dropout, filter_widths, num_filters, scope, nonlinearity)