class_docstr: One directional RNN classifier.
  This is a combination of the
  :class:`~texar.tf.modules.UnidirectionalRNNEncoder` with a classification
  layer. Both step-wise classification and sequence-level classification
  are supported, specified in :attr:`hparams`.
  
  Arguments are the same as in
  :class:`~texar.tf.modules.UnidirectionalRNNEncoder`.
  
  Args:
      cell: (RNNCell, optional) If not specified,
          a cell is created as specified in :attr:`hparams["rnn_cell"]`.
      cell_dropout_mode (optional): A Tensor taking value of
          :tf_main:`tf.estimator.ModeKeys <estimator/ModeKeys>`, which
          toggles dropout in the RNN cell (e.g., activates dropout in
          TRAIN mode). If `None`, :func:`~texar.tf.global_mode` is used.
          Ignored if :attr:`cell` is given.
      output_layer (optional): An instance of
          :tf_main:`tf.layers.Layer <layers/Layer>`. Applies to the RNN cell
          output of each step. If `None` (default), the output layer is
          created as specified in :attr:`hparams["output_layer"]`.
      hparams (dict or HParams, optional): Hyperparameters. Missing
          hyperparamerter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter sturcture and
          default values.
  
  .. document private functions
  .. automethod:: _build
class_docstr_tok: ["One","directional","RNN","classifier",".","This","is","a","combination","of","the",":","class",":","`","~texar.tf.modules.UnidirectionalRNNEncoder","`","with","a","classification","layer",".","Both","step-wise","classification","and","sequence-level","classification","are","supported",",","specified","in",":","attr",":","`","hparams","`",".","Arguments","are","the","same","as","in",":","class",":","`","~texar.tf.modules.UnidirectionalRNNEncoder","`",".","Args",":","cell",":","(","RNNCell",",","optional",")","If","not","specified",",","a","cell","is","created","as","specified","in",":","attr",":","`","hparams","[","``","rnn_cell","''","]","`",".","cell_dropout_mode","(","optional",")",":","A","Tensor","taking","value","of",":","tf_main",":","`","tf.estimator.ModeKeys","<","estimator\/ModeKeys",">","`",",","which","toggles","dropout","in","the","RNN","cell","(","e.g.",",","activates","dropout","in","TRAIN","mode",")",".","If","`","None","`",",",":","func",":","`","~texar.tf.global_mode","`","is","used",".","Ignored","if",":","attr",":","`","cell","`","is","given",".","output_layer","(","optional",")",":","An","instance","of",":","tf_main",":","`","tf.layers.Layer","<","layers\/Layer",">","`",".","Applies","to","the","RNN","cell","output","of","each","step",".","If","`","None","`","(","default",")",",","the","output","layer","is","created","as","specified","in",":","attr",":","`","hparams","[","``","output_layer","''","]","`",".","hparams","(","dict","or","HParams",",","optional",")",":","Hyperparameters",".","Missing","hyperparamerter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","sturcture","and","default","values",".","..","document","private","functions","..","automethod",":",":","_build"]
docstr: Returns a dictionary of hyperparameters with default values.
  
  .. code-block:: python
  
      {
          # (1) Same hyperparameters as in UnidirectionalRNNEncoder
          ...
  
          # (2) Additional hyperparameters
          "num_classes": 2,
          "logit_layer_kwargs": None,
          "clas_strategy": "final_time",
          "max_seq_length": None,
          "name": "unidirectional_rnn_classifier"
      }
  
  Here:
  
  1. Same hyperparameters as in
  :class:`~texar.tf.modules.UnidirectionalRNNEncoder`.
  See the :meth:`~texar.tf.modules.UnidirectionalRNNEncoder.default_hparams`.
  An instance of UnidirectionalRNNEncoder is created for feature
  extraction.
  
  2. Additional hyperparameters:
  
      "num_classes": int
          Number of classes:
  
          - If **`> 0`**, an additional :tf_main:`Dense <layers/Dense>`                 layer is appended to the encoder to compute the logits over                 classes.
          - If **`<= 0`**, no dense layer is appended. The number of                 classes is assumed to be the final dense layer size of the                 encoder.
  
      "logit_layer_kwargs": dict
          Keyword arguments for the logit Dense layer constructor,
          except for argument "units" which is set to "num_classes".
          Ignored if no extra logit layer is appended.
  
      "clas_strategy": str
          The classification strategy, one of:
  
          - **"final_time"**: Sequence-leve classification based on                 the output of the final time step. One sequence has one class.
          - **"all_time"**: Sequence-level classification based on                 the output of all time steps. One sequence has one class.
          - **"time_wise"**: Step-wise classfication, i.e., make                 classification for each time step based on its output.
  
      "max_seq_length": int, optional
          Maximum possible length of input sequences. Required if
          "clas_strategy" is "all_time".
  
      "name": str
          Name of the classifier.
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","..","code-block",":",":","python","{","#","(","1",")","Same","hyperparameters","as","in","UnidirectionalRNNEncoder","...","#","(","2",")","Additional","hyperparameters","``","num_classes","''",":","2",",","``","logit_layer_kwargs","''",":","None",",","``","clas_strategy","''",":","``","final_time","''",",","``","max_seq_length","''",":","None",",","``","name","''",":","``","unidirectional_rnn_classifier","''","}","Here",":","1",".","Same","hyperparameters","as","in",":","class",":","`","~texar.tf.modules.UnidirectionalRNNEncoder","`",".","See","the",":","meth",":","`","~texar.tf.modules.UnidirectionalRNNEncoder.default_hparams","`",".","An","instance","of","UnidirectionalRNNEncoder","is","created","for","feature","extraction",".","2",".","Additional","hyperparameters",":","``","num_classes","''",":","int","Number","of","classes",":","-","If","*","*","`",">","0","`","*","*",",","an","additional",":","tf_main",":","`","Dense","<","layers\/Dense",">","`","layer","is","appended","to","the","encoder","to","compute","the","logits","over","classes",".","-","If","*","*","`","<","=","0","`","*","*",",","no","dense","layer","is","appended",".","The","number","of","classes","is","assumed","to","be","the","final","dense","layer","size","of","the","encoder",".","``","logit_layer_kwargs","''",":","dict","Keyword","arguments","for","the","logit","Dense","layer","constructor",",","except","for","argument","``","units","''","which","is","set","to","``","num_classes","''",".","Ignored","if","no","extra","logit","layer","is","appended",".","``","clas_strategy","''",":","str","The","classification","strategy",",","one","of",":","-","*","*","''","final_time","''","*","*",":","Sequence-leve","classification","based","on","the","output","of","the","final","time","step",".","One","sequence","has","one","class",".","-","*","*","''","all_time","''","*","*",":","Sequence-level","classification","based","on","the","output","of","all","time","steps",".","One","sequence","has","one","class",".","-","*","*","''","time_wise","''","*","*",":","Step-wise","classfication",",","i.e.",",","make","classification","for","each","time","step","based","on","its","output",".","``","max_seq_length","''",":","int",",","optional","Maximum","possible","length","of","input","sequences",".","Required","if","``","clas_strategy","''","is","``","all_time","''",".","``","name","''",":","str","Name","of","the","classifier","."]
code: def default_hparams():
      """Returns a dictionary of hyperparameters with default values.
  
          .. code-block:: python
  
              {
                  # (1) Same hyperparameters as in UnidirectionalRNNEncoder
                  ...
  
                  # (2) Additional hyperparameters
                  "num_classes": 2,
                  "logit_layer_kwargs": None,
                  "clas_strategy": "final_time",
                  "max_seq_length": None,
                  "name": "unidirectional_rnn_classifier"
              }
  
          Here:
  
          1. Same hyperparameters as in
          :class:`~texar.tf.modules.UnidirectionalRNNEncoder`.
          See the :meth:`~texar.tf.modules.UnidirectionalRNNEncoder.default_hparams`.
          An instance of UnidirectionalRNNEncoder is created for feature
          extraction.
  
          2. Additional hyperparameters:
  
              "num_classes": int
                  Number of classes:
  
                  - If **`> 0`**, an additional :tf_main:`Dense <layers/Dense>` \
                  layer is appended to the encoder to compute the logits over \
                  classes.
                  - If **`<= 0`**, no dense layer is appended. The number of \
                  classes is assumed to be the final dense layer size of the \
                  encoder.
  
              "logit_layer_kwargs": dict
                  Keyword arguments for the logit Dense layer constructor,
                  except for argument "units" which is set to "num_classes".
                  Ignored if no extra logit layer is appended.
  
              "clas_strategy": str
                  The classification strategy, one of:
  
                  - **"final_time"**: Sequence-leve classification based on \
                  the output of the final time step. One sequence has one class.
                  - **"all_time"**: Sequence-level classification based on \
                  the output of all time steps. One sequence has one class.
                  - **"time_wise"**: Step-wise classfication, i.e., make \
                  classification for each time step based on its output.
  
              "max_seq_length": int, optional
                  Maximum possible length of input sequences. Required if
                  "clas_strategy" is "all_time".
  
              "name": str
                  Name of the classifier.
          """
      hparams = UnidirectionalRNNEncoder.default_hparams()
      hparams.update(
          {
              "num_classes": 2,
              "logit_layer_kwargs": None,
              "clas_strategy": "final_time",
              "max_seq_length": None,
              "name": "unidirectional_rnn_classifier",
          }
      )
      return hparams
  
file_path: texar/texar/tf/modules/classifiers/rnn_classifiers.py
imports: import numpy
  import tensorflow
  from tensorflow.contrib.framework import nest
  from texar.tf.modules.classifiers.classifier_base import ClassifierBase
  from texar.tf.modules.encoders.rnn_encoders import UnidirectionalRNNEncoder, _forward_single_output_layer
  from texar.tf.core import layers
  from texar.tf.utils import utils, shapes
  from texar.tf.hyperparams import HParams
label_desc: Use image node_id 2 for calling the UnidirectionalRNNClassifier obj's underlying member method code with example usage: obj.default_hparams() and returns: hparams