class_docstr: A sequence tagging model for POS and Chunks written in Tensorflow (and Keras) based on the
  paper 'Deep multi-task learning with low level tasks supervised at lower layers'.
  The model has 3 Bi-LSTM layers and outputs POS and Chunk tags.
  
  Args:
      use_cudnn (bool, optional): use GPU based model (CUDNNA cells)
class_docstr_tok: ["A","sequence","tagging","model","for","POS","and","Chunks","written","in","Tensorflow","(","and","Keras",")","based","on","the","paper","'Deep","multi-task","learning","with","low","level","tasks","supervised","at","lower","layers","'",".","The","model","has","3","Bi-LSTM","layers","and","outputs","POS","and","Chunk","tags",".","Args",":","use_cudnn","(","bool",",","optional",")",":","use","GPU","based","model","(","CUDNNA","cells",")"]
docstr: Build a chunker/POS model
  
  Args:
      vocabulary_size (int): the size of the input vocabulary
      num_pos_labels (int): the size of of POS labels
      num_chunk_labels (int): the sie of chunk labels
      char_vocab_size (int, optional): character vocabulary size
      max_word_len (int, optional): max characters in a word
      feature_size (int, optional): feature size - determines the embedding/LSTM layer                 hidden state size
      dropout (float, optional): dropout rate
      classifier (str, optional): classifier layer, 'softmax' for softmax or 'crf' for                 conditional random fields classifier. default is 'softmax'.
      optimizer (tensorflow.python.training.optimizer.Optimizer, optional): optimizer, if                 None will use default SGD (paper setup)
docstr_tok: ["Build","a","chunker\/POS","model","Args",":","vocabulary_size","(","int",")",":","the","size","of","the","input","vocabulary","num_pos_labels","(","int",")",":","the","size","of","of","POS","labels","num_chunk_labels","(","int",")",":","the","sie","of","chunk","labels","char_vocab_size","(","int",",","optional",")",":","character","vocabulary","size","max_word_len","(","int",",","optional",")",":","max","characters","in","a","word","feature_size","(","int",",","optional",")",":","feature","size","-","determines","the","embedding\/LSTM","layer","hidden","state","size","dropout","(","float",",","optional",")",":","dropout","rate","classifier","(","str",",","optional",")",":","classifier","layer",",","'softmax","'","for","softmax","or","'crf","'","for","conditional","random","fields","classifier",".","default","is","'softmax","'",".","optimizer","(","tensorflow.python.training.optimizer.Optimizer",",","optional",")",":","optimizer",",","if","None","will","use","default","SGD","(","paper","setup",")"]
code: def build(
      self,
      vocabulary_size,
      num_pos_labels,
      num_chunk_labels,
      char_vocab_size=None,
      max_word_len=25,
      feature_size=100,
      dropout=0.5,
      classifier="softmax",
      optimizer=None,
  ):
      """
          Build a chunker/POS model
  
          Args:
              vocabulary_size (int): the size of the input vocabulary
              num_pos_labels (int): the size of of POS labels
              num_chunk_labels (int): the sie of chunk labels
              char_vocab_size (int, optional): character vocabulary size
              max_word_len (int, optional): max characters in a word
              feature_size (int, optional): feature size - determines the embedding/LSTM layer \
                  hidden state size
              dropout (float, optional): dropout rate
              classifier (str, optional): classifier layer, 'softmax' for softmax or 'crf' for \
                  conditional random fields classifier. default is 'softmax'.
              optimizer (tensorflow.python.training.optimizer.Optimizer, optional): optimizer, if \
                  None will use default SGD (paper setup)
          """
      self.vocabulary_size = vocabulary_size
      self.char_vocab_size = char_vocab_size
      self.num_pos_labels = num_pos_labels
      self.num_chunk_labels = num_chunk_labels
      self.max_word_len = max_word_len
      self.feature_size = feature_size
      self.dropout = dropout
      self.classifier = classifier
  
      word_emb_layer = tf.keras.layers.Embedding(
          self.vocabulary_size,
          self.feature_size,
          name="embedding",
          mask_zero=False,
      )
      word_input = tf.keras.layers.Input(shape=(None,))
      word_embedding = word_emb_layer(word_input)
      input_src = word_input
      features = word_embedding
  
      # add char input if present
      if self.char_vocab_size is not None:
          char_input = tf.keras.layers.Input(
              shape=(None, self.max_word_len)
          )
          char_emb_layer = tf.keras.layers.Embedding(
              self.char_vocab_size,
              30,
              name="char_embedding",
              mask_zero=False,
          )
          char_embedding = char_emb_layer(char_input)
          char_embedding = tf.keras.layers.TimeDistributed(
              tf.keras.layers.Conv1D(30, 3, padding="same")
          )(char_embedding)
          char_embedding = tf.keras.layers.TimeDistributed(
              tf.keras.layers.GlobalMaxPooling1D()
          )(char_embedding)
  
          input_src = [input_src, char_input]
          features = tf.keras.layers.concatenate(
              [word_embedding, char_embedding]
          )
  
      rnn_layer_1 = tf.keras.layers.Bidirectional(
          self._rnn_cell(return_sequences=True)
      )(features)
      rnn_layer_2 = tf.keras.layers.Bidirectional(
          self._rnn_cell(return_sequences=True)
      )(rnn_layer_1)
      rnn_layer_3 = tf.keras.layers.Bidirectional(
          self._rnn_cell(return_sequences=True)
      )(rnn_layer_2)
  
      # outputs
      pos_out = tf.keras.layers.Dense(
          self.num_pos_labels, activation="softmax", name="pos_output"
      )(rnn_layer_1)
      losses = {"pos_output": "categorical_crossentropy"}
      metrics = {"pos_output": "categorical_accuracy"}
  
      if "crf" in self.classifier:
          with tf.device("/cpu:0"):
              chunk_crf = CRF(self.num_chunk_labels, name="chunk_crf")
              rnn_layer_3_dense = tf.keras.layers.Dense(
                  self.num_chunk_labels
              )(tf.keras.layers.Dropout(self.dropout)(rnn_layer_3))
              chunks_out = chunk_crf(rnn_layer_3_dense)
              losses["chunk_crf"] = chunk_crf.loss
              metrics["chunk_crf"] = chunk_crf.viterbi_accuracy
      else:
          chunks_out = tf.keras.layers.TimeDistributed(
              tf.keras.layers.Dense(
                  self.num_chunk_labels, activation="softmax"
              ),
              name="chunk_out",
          )(rnn_layer_3)
          losses["chunk_out"] = "categorical_crossentropy"
          metrics["chunk_out"] = "categorical_accuracy"
  
      model = tf.keras.Model(input_src, [pos_out, chunks_out])
      if optimizer is None:
          self.optimizer = tf.keras.optimizers.Adam(0.001, clipnorm=5.0)
      else:
          self.optimizer = optimizer
      model.compile(
          optimizer=self.optimizer, loss=losses, metrics=metrics
      )
      self.model = model
  
file_path: nlp-architect/nlp_architect/models/chunker.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import tensorflow
  from nlp_architect.nn.tensorflow.python.keras.layers.crf import CRF
  from nlp_architect.nn.tensorflow.python.keras.utils import load_model, save_model
label_desc: Use image node_id 2 for calling the SequenceTagger obj's underlying member method code with example usage: obj.build(vocabulary_size, num_pos_labels, num_chunk_labels, char_vocab_size, max_word_len, feature_size, dropout, classifier, optimizer) without return types