class_docstr: Simple Conv-1D network which consists of a sequence of conv layers
  followed with a sequence of dense layers.
  
  Args:
      hparams (dict, optional): Hyperparameters. Missing
          hyperparamerter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter sturcture and
          default values.
  
  See :meth:`_build` for the inputs and outputs. The inputs must be a
  3D Tensor of shape `[batch_size, length, channels]` (default), or
  `[batch_size, channels, length]` (if `data_format` is set to
  `'channels_last'` through :attr:`hparams`). For example, for sequence
  classification, `length` corresponds to time steps, and `channels`
  corresponds to embedding dim.
  
  Example:
  
      .. code-block:: python
  
          nn = Conv1DNetwork() # Use the default structure
  
          inputs = tf.random_uniform([64, 20, 256])
          outputs = nn(inputs)
          # outputs == Tensor of shape [64, 128], cuz the final dense layer
          # has size 128.
  
  .. document private functions
  .. automethod:: _build
class_docstr_tok: ["Simple","Conv-1D","network","which","consists","of","a","sequence","of","conv","layers","followed","with","a","sequence","of","dense","layers",".","Args",":","hparams","(","dict",",","optional",")",":","Hyperparameters",".","Missing","hyperparamerter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","sturcture","and","default","values",".","See",":","meth",":","`","_build","`","for","the","inputs","and","outputs",".","The","inputs","must","be","a","3D","Tensor","of","shape","`","[","batch_size",",","length",",","channels","]","`","(","default",")",",","or","`","[","batch_size",",","channels",",","length","]","`","(","if","`","data_format","`","is","set","to","`","'channels_last","'","`","through",":","attr",":","`","hparams","`",")",".","For","example",",","for","sequence","classification",",","`","length","`","corresponds","to","time","steps",",","and","`","channels","`","corresponds","to","embedding","dim",".","Example",":","..","code-block",":",":","python","nn","=","Conv1DNetwork","(",")","#","Use","the","default","structure","inputs","=","tf.random_uniform","(","[","64",",","20",",","256","]",")","outputs","=","nn","(","inputs",")","#","outputs","==","Tensor","of","shape","[","64",",","128","]",",","cuz","the","final","dense","layer","#","has","size","128",".","..","document","private","functions","..","automethod",":",":","_build"]
docstr: Returns a dictionary of hyperparameters with default values.
  
  .. code-block:: python
  
      {
          # (1) Conv layers
          "num_conv_layers": 1,
          "filters": 128,
          "kernel_size": [3, 4, 5],
          "conv_activation": "relu",
          "conv_activation_kwargs": None,
          "other_conv_kwargs": None,
          # (2) Pooling layers
          "pooling": "MaxPooling1D",
          "pool_size": None,
          "pool_strides": 1,
          "other_pool_kwargs": None,
          # (3) Dense layers
          "num_dense_layers": 1,
          "dense_size": 128,
          "dense_activation": "identity",
          "dense_activation_kwargs": None,
          "final_dense_activation": None,
          "final_dense_activation_kwargs": None,
          "other_dense_kwargs": None,
          # (4) Dropout
          "dropout_conv": [1],
          "dropout_dense": [],
          "dropout_rate": 0.75,
          # (5) Others
          "name": "conv1d_network",
      }
  
  Here:
  
  1. For **convolutional** layers:
  
      "num_conv_layers": int
          Number of convolutional layers.
  
      "filters": int or list
          The number of filters in the convolution, i.e., the
          dimensionality
          of the output space. If "num_conv_layers" > 1, "filters" must be
          a list of "num_conv_layers" integers.
  
      "kernel_size": int or list
          Lengths of 1D convolution windows.
  
          - If "num_conv_layers" == 1, this can be a list of arbitrary                 number                of `int` denoting different sized conv windows. The number of                 filters of each size is specified by "filters". For example,                the default values will create 3 sets of filters, each of which                has kernel size of 3, 4, and 5, respectively, and has filter                number 128.
          - If "num_conv_layers" > 1, this must be a list of length                 "num_conv_layers". Each element can be an `int` or a list                 of arbitrary number of `int` denoting the kernel size of                 respective layer.
  
      "conv_activation": str or callable
          Activation function applied to the output of the convolutional
          layers. Set to "indentity" to maintain a linear activation.
          See :func:`~texar.tf.core.get_activation_fn` for more details.
  
      "conv_activation_kwargs": dict, optional
          Keyword arguments for conv layer activation functions.
          See :func:`~texar.tf.core.get_activation_fn` for more details.
  
      "other_conv_kwargs": dict, optional
          Other keyword arguments for
          :tf_main:`tf.layers.Conv1D <layers/Conv1d>` constructor, e.g.,
          "data_format", "padding", etc.
  
  2. For **pooling** layers:
  
      "pooling": str or class or instance
          Pooling layer after each of the convolutional layer(s). Can
          a pooling layer class, its name or module path, or a class
          instance.
  
      "pool_size": int or list, optional
          Size of the pooling window. If an `int`, all pooling layer
          will have the same pool size. If a list, the list length must
          equal "num_conv_layers". If `None` and the pooling type
          is either
          :tf_main:`MaxPooling <layers/MaxPooling1D>` or
          :tf_main:`AveragePooling <layers/AveragePooling1D>`, the
          pool size will be set to input size. That is, the output of
          the pooling layer is a single unit.
  
      "pool_strides": int or list, optional
          Strides of the pooling operation. If an `int`, all pooling layer
          will have the same stride. If a list, the list length must
          equal "num_conv_layers".
  
      "other_pool_kwargs": dict, optional
          Other keyword arguments for pooling layer class constructor.
  
  3. For **dense** layers (note that here dense layers always follow conv
     and pooling layers):
  
      "num_dense_layers": int
          Number of dense layers.
  
      "dense_size": int or list
          Number of units of each dense layers. If an `int`, all dense
          layers will have the same size. If a list of `int`, the list
          length must equal "num_dense_layers".
  
      "dense_activation": str or callable
          Activation function applied to the output of the dense
          layers **except** the last dense layer output . Set to
          "indentity" to maintain a linear activation.
          See :func:`~texar.tf.core.get_activation_fn` for more details.
  
      "dense_activation_kwargs": dict, optional
          Keyword arguments for dense layer activation functions before
          the last dense layer.
          See :func:`~texar.tf.core.get_activation_fn` for more details.
  
      "final_dense_activation": str or callable
          Activation function applied to the output of the **last** dense
          layer. Set to `None` or
          "indentity" to maintain a linear activation.
          See :func:`~texar.tf.core.get_activation_fn` for more details.
  
      "final_dense_activation_kwargs": dict, optional
          Keyword arguments for the activation function of last
          dense layer.
          See :func:`~texar.tf.core.get_activation_fn` for more details.
  
      "other_dense_kwargs": dict, optional
          Other keyword arguments for
          :tf_main:`Dense <layers/Dense>`
          layer class constructor.
  
  4. For **dropouts**:
  
      "dropout_conv": int or list
          The indexes of conv layers (starting from `0`) whose **inputs**
          are applied with dropout. The index = :attr:`num_conv_layers`
          means dropout applies to the final conv layer output. E.g.,
  
          .. code-block:: python
  
              {
                  "num_conv_layers": 2,
                  "dropout_conv": [0, 2]
              }
  
          will leads to a series of layers as
          `-dropout-conv0-conv1-dropout-`.
  
          The dropout mode (training or not) is controlled
          by the :attr:`mode` argument of :meth:`_build`.
  
      "dropout_dense": int or list
          Same as "dropout_conv" but applied to dense layers (index
          starting from `0`).
  
      "dropout_rate": float
          The dropout rate, between 0 and 1. E.g.,
          `"dropout_rate": 0.1` would drop out 10% of elements.
  
  5. Others:
  
      "name": str
          Name of the network.
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","..","code-block",":",":","python","{","#","(","1",")","Conv","layers","``","num_conv_layers","''",":","1",",","``","filters","''",":","128",",","``","kernel_size","''",":","[","3",",","4",",","5","]",",","``","conv_activation","''",":","``","relu","''",",","``","conv_activation_kwargs","''",":","None",",","``","other_conv_kwargs","''",":","None",",","#","(","2",")","Pooling","layers","``","pooling","''",":","``","MaxPooling1D","''",",","``","pool_size","''",":","None",",","``","pool_strides","''",":","1",",","``","other_pool_kwargs","''",":","None",",","#","(","3",")","Dense","layers","``","num_dense_layers","''",":","1",",","``","dense_size","''",":","128",",","``","dense_activation","''",":","``","identity","''",",","``","dense_activation_kwargs","''",":","None",",","``","final_dense_activation","''",":","None",",","``","final_dense_activation_kwargs","''",":","None",",","``","other_dense_kwargs","''",":","None",",","#","(","4",")","Dropout","``","dropout_conv","''",":","[","1","]",",","``","dropout_dense","''",":","[","]",",","``","dropout_rate","''",":","0.75",",","#","(","5",")","Others","``","name","''",":","``","conv1d_network","''",",","}","Here",":","1",".","For","*","*","convolutional","*","*","layers",":","``","num_conv_layers","''",":","int","Number","of","convolutional","layers",".","``","filters","''",":","int","or","list","The","number","of","filters","in","the","convolution",",","i.e.",",","the","dimensionality","of","the","output","space",".","If","``","num_conv_layers","''",">","1",",","``","filters","''","must","be","a","list","of","``","num_conv_layers","''","integers",".","``","kernel_size","''",":","int","or","list","Lengths","of","1D","convolution","windows",".","-","If","``","num_conv_layers","''","==","1",",","this","can","be","a","list","of","arbitrary","number","of","`","int","`","denoting","different","sized","conv","windows",".","The","number","of","filters","of","each","size","is","specified","by","``","filters","''",".","For","example",",","the","default","values","will","create","3","sets","of","filters",",","each","of","which","has","kernel","size","of","3",",","4",",","and","5",",","respectively",",","and","has","filter","number","128",".","-","If","``","num_conv_layers","''",">","1",",","this","must","be","a","list","of","length","``","num_conv_layers","''",".","Each","element","can","be","an","`","int","`","or","a","list","of","arbitrary","number","of","`","int","`","denoting","the","kernel","size","of","respective","layer",".","``","conv_activation","''",":","str","or","callable","Activation","function","applied","to","the","output","of","the","convolutional","layers",".","Set","to","``","indentity","''","to","maintain","a","linear","activation",".","See",":","func",":","`","~texar.tf.core.get_activation_fn","`","for","more","details",".","``","conv_activation_kwargs","''",":","dict",",","optional","Keyword","arguments","for","conv","layer","activation","functions",".","See",":","func",":","`","~texar.tf.core.get_activation_fn","`","for","more","details",".","``","other_conv_kwargs","''",":","dict",",","optional","Other","keyword","arguments","for",":","tf_main",":","`","tf.layers.Conv1D","<","layers\/Conv1d",">","`","constructor",",","e.g.",",","``","data_format","''",",","``","padding","''",",","etc",".","2",".","For","*","*","pooling","*","*","layers",":","``","pooling","''",":","str","or","class","or","instance","Pooling","layer","after","each","of","the","convolutional","layer","(","s",")",".","Can","a","pooling","layer","class",",","its","name","or","module","path",",","or","a","class","instance",".","``","pool_size","''",":","int","or","list",",","optional","Size","of","the","pooling","window",".","If","an","`","int","`",",","all","pooling","layer","will","have","the","same","pool","size",".","If","a","list",",","the","list","length","must","equal","``","num_conv_layers","''",".","If","`","None","`","and","the","pooling","type","is","either",":","tf_main",":","`","MaxPooling","<","layers\/MaxPooling1D",">","`","or",":","tf_main",":","`","AveragePooling","<","layers\/AveragePooling1D",">","`",",","the","pool","size","will","be","set","to","input","size",".","That","is",",","the","output","of","the","pooling","layer","is","a","single","unit",".","``","pool_strides","''",":","int","or","list",",","optional","Strides","of","the","pooling","operation",".","If","an","`","int","`",",","all","pooling","layer","will","have","the","same","stride",".","If","a","list",",","the","list","length","must","equal","``","num_conv_layers","''",".","``","other_pool_kwargs","''",":","dict",",","optional","Other","keyword","arguments","for","pooling","layer","class","constructor",".","3",".","For","*","*","dense","*","*","layers","(","note","that","here","dense","layers","always","follow","conv","and","pooling","layers",")",":","``","num_dense_layers","''",":","int","Number","of","dense","layers",".","``","dense_size","''",":","int","or","list","Number","of","units","of","each","dense","layers",".","If","an","`","int","`",",","all","dense","layers","will","have","the","same","size",".","If","a","list","of","`","int","`",",","the","list","length","must","equal","``","num_dense_layers","''",".","``","dense_activation","''",":","str","or","callable","Activation","function","applied","to","the","output","of","the","dense","layers","*","*","except","*","*","the","last","dense","layer","output",".","Set","to","``","indentity","''","to","maintain","a","linear","activation",".","See",":","func",":","`","~texar.tf.core.get_activation_fn","`","for","more","details",".","``","dense_activation_kwargs","''",":","dict",",","optional","Keyword","arguments","for","dense","layer","activation","functions","before","the","last","dense","layer",".","See",":","func",":","`","~texar.tf.core.get_activation_fn","`","for","more","details",".","``","final_dense_activation","''",":","str","or","callable","Activation","function","applied","to","the","output","of","the","*","*","last","*","*","dense","layer",".","Set","to","`","None","`","or","``","indentity","''","to","maintain","a","linear","activation",".","See",":","func",":","`","~texar.tf.core.get_activation_fn","`","for","more","details",".","``","final_dense_activation_kwargs","''",":","dict",",","optional","Keyword","arguments","for","the","activation","function","of","last","dense","layer",".","See",":","func",":","`","~texar.tf.core.get_activation_fn","`","for","more","details",".","``","other_dense_kwargs","''",":","dict",",","optional","Other","keyword","arguments","for",":","tf_main",":","`","Dense","<","layers\/Dense",">","`","layer","class","constructor",".","4",".","For","*","*","dropouts","*","*",":","``","dropout_conv","''",":","int","or","list","The","indexes","of","conv","layers","(","starting","from","`","0","`",")","whose","*","*","inputs","*","*","are","applied","with","dropout",".","The","index","=",":","attr",":","`","num_conv_layers","`","means","dropout","applies","to","the","final","conv","layer","output",".","E.g.",",","..","code-block",":",":","python","{","``","num_conv_layers","''",":","2",",","``","dropout_conv","''",":","[","0",",","2","]","}","will","leads","to","a","series","of","layers","as","`","-dropout-conv0-conv1-dropout-","`",".","The","dropout","mode","(","training","or","not",")","is","controlled","by","the",":","attr",":","`","mode","`","argument","of",":","meth",":","`","_build","`",".","``","dropout_dense","''",":","int","or","list","Same","as","``","dropout_conv","''","but","applied","to","dense","layers","(","index","starting","from","`","0","`",")",".","``","dropout_rate","''",":","float","The","dropout","rate",",","between","0","and","1",".","E.g.",",","`","``","dropout_rate","''",":","0.1","`","would","drop","out","10","%","of","elements",".","5",".","Others",":","``","name","''",":","str","Name","of","the","network","."]
code: def default_hparams():
      """Returns a dictionary of hyperparameters with default values.
  
          .. code-block:: python
  
              {
                  # (1) Conv layers
                  "num_conv_layers": 1,
                  "filters": 128,
                  "kernel_size": [3, 4, 5],
                  "conv_activation": "relu",
                  "conv_activation_kwargs": None,
                  "other_conv_kwargs": None,
                  # (2) Pooling layers
                  "pooling": "MaxPooling1D",
                  "pool_size": None,
                  "pool_strides": 1,
                  "other_pool_kwargs": None,
                  # (3) Dense layers
                  "num_dense_layers": 1,
                  "dense_size": 128,
                  "dense_activation": "identity",
                  "dense_activation_kwargs": None,
                  "final_dense_activation": None,
                  "final_dense_activation_kwargs": None,
                  "other_dense_kwargs": None,
                  # (4) Dropout
                  "dropout_conv": [1],
                  "dropout_dense": [],
                  "dropout_rate": 0.75,
                  # (5) Others
                  "name": "conv1d_network",
              }
  
          Here:
  
          1. For **convolutional** layers:
  
              "num_conv_layers": int
                  Number of convolutional layers.
  
              "filters": int or list
                  The number of filters in the convolution, i.e., the
                  dimensionality
                  of the output space. If "num_conv_layers" > 1, "filters" must be
                  a list of "num_conv_layers" integers.
  
              "kernel_size": int or list
                  Lengths of 1D convolution windows.
  
                  - If "num_conv_layers" == 1, this can be a list of arbitrary \
                  number\
                  of `int` denoting different sized conv windows. The number of \
                  filters of each size is specified by "filters". For example,\
                  the default values will create 3 sets of filters, each of which\
                  has kernel size of 3, 4, and 5, respectively, and has filter\
                  number 128.
                  - If "num_conv_layers" > 1, this must be a list of length \
                  "num_conv_layers". Each element can be an `int` or a list \
                  of arbitrary number of `int` denoting the kernel size of \
                  respective layer.
  
              "conv_activation": str or callable
                  Activation function applied to the output of the convolutional
                  layers. Set to "indentity" to maintain a linear activation.
                  See :func:`~texar.tf.core.get_activation_fn` for more details.
  
              "conv_activation_kwargs": dict, optional
                  Keyword arguments for conv layer activation functions.
                  See :func:`~texar.tf.core.get_activation_fn` for more details.
  
              "other_conv_kwargs": dict, optional
                  Other keyword arguments for
                  :tf_main:`tf.layers.Conv1D <layers/Conv1d>` constructor, e.g.,
                  "data_format", "padding", etc.
  
          2. For **pooling** layers:
  
              "pooling": str or class or instance
                  Pooling layer after each of the convolutional layer(s). Can
                  a pooling layer class, its name or module path, or a class
                  instance.
  
              "pool_size": int or list, optional
                  Size of the pooling window. If an `int`, all pooling layer
                  will have the same pool size. If a list, the list length must
                  equal "num_conv_layers". If `None` and the pooling type
                  is either
                  :tf_main:`MaxPooling <layers/MaxPooling1D>` or
                  :tf_main:`AveragePooling <layers/AveragePooling1D>`, the
                  pool size will be set to input size. That is, the output of
                  the pooling layer is a single unit.
  
              "pool_strides": int or list, optional
                  Strides of the pooling operation. If an `int`, all pooling layer
                  will have the same stride. If a list, the list length must
                  equal "num_conv_layers".
  
              "other_pool_kwargs": dict, optional
                  Other keyword arguments for pooling layer class constructor.
  
          3. For **dense** layers (note that here dense layers always follow conv
             and pooling layers):
  
              "num_dense_layers": int
                  Number of dense layers.
  
              "dense_size": int or list
                  Number of units of each dense layers. If an `int`, all dense
                  layers will have the same size. If a list of `int`, the list
                  length must equal "num_dense_layers".
  
              "dense_activation": str or callable
                  Activation function applied to the output of the dense
                  layers **except** the last dense layer output . Set to
                  "indentity" to maintain a linear activation.
                  See :func:`~texar.tf.core.get_activation_fn` for more details.
  
              "dense_activation_kwargs": dict, optional
                  Keyword arguments for dense layer activation functions before
                  the last dense layer.
                  See :func:`~texar.tf.core.get_activation_fn` for more details.
  
              "final_dense_activation": str or callable
                  Activation function applied to the output of the **last** dense
                  layer. Set to `None` or
                  "indentity" to maintain a linear activation.
                  See :func:`~texar.tf.core.get_activation_fn` for more details.
  
              "final_dense_activation_kwargs": dict, optional
                  Keyword arguments for the activation function of last
                  dense layer.
                  See :func:`~texar.tf.core.get_activation_fn` for more details.
  
              "other_dense_kwargs": dict, optional
                  Other keyword arguments for
                  :tf_main:`Dense <layers/Dense>`
                  layer class constructor.
  
          4. For **dropouts**:
  
              "dropout_conv": int or list
                  The indexes of conv layers (starting from `0`) whose **inputs**
                  are applied with dropout. The index = :attr:`num_conv_layers`
                  means dropout applies to the final conv layer output. E.g.,
  
                  .. code-block:: python
  
                      {
                          "num_conv_layers": 2,
                          "dropout_conv": [0, 2]
                      }
  
                  will leads to a series of layers as
                  `-dropout-conv0-conv1-dropout-`.
  
                  The dropout mode (training or not) is controlled
                  by the :attr:`mode` argument of :meth:`_build`.
  
              "dropout_dense": int or list
                  Same as "dropout_conv" but applied to dense layers (index
                  starting from `0`).
  
              "dropout_rate": float
                  The dropout rate, between 0 and 1. E.g.,
                  `"dropout_rate": 0.1` would drop out 10% of elements.
  
          5. Others:
  
              "name": str
                  Name of the network.
          """
      return {
          # Conv layers
          "num_conv_layers": 1,
          "filters": 128,
          "kernel_size": [3, 4, 5],
          "conv_activation": "relu",
          "conv_activation_kwargs": None,
          "other_conv_kwargs": None,
          # Pooling layers
          "pooling": "MaxPooling1D",
          "pool_size": None,
          "pool_strides": 1,
          "other_pool_kwargs": None,
          # Dense layers
          "num_dense_layers": 1,
          "dense_size": 128,
          "dense_activation": "identity",
          "dense_activation_kwargs": None,
          "final_dense_activation": None,
          "final_dense_activation_kwargs": None,
          "other_dense_kwargs": None,
          # Dropout
          "dropout_conv": [1],
          "dropout_dense": [],
          "dropout_rate": 0.75,
          # Others
          "name": "conv1d_network",
          "@no_typecheck": [
              "filters",
              "kernel_size",
              "conv_activation",
              "pool_size",
              "pool_strides",
              "dense_size",
              "dense_activation",
              "dropout_conv",
              "dropout_dense",
          ],
      }
  
file_path: texar/texar/tf/modules/networks/conv_networks.py
imports: import tensorflow
  from texar.tf.modules.networks.network_base import FeedForwardNetworkBase
  from texar.tf.modules.networks.network_base import _build_layers
  from texar.tf.core.layers import get_pooling_layer_hparams, get_activation_fn
  from texar.tf.utils.utils import uniquify_str
  from texar.tf.utils.shapes import mask_sequences
  from texar.tf.hyperparams import HParams
label_desc: Use image node_id 2 for calling the Conv1DNetwork obj's underlying member method code with example usage: obj.default_hparams() and returns: dict