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: Creates the hparams for each of the conv layers usable for
  :func:`texar.tf.core.layers.get_layer`.
docstr_tok: ["Creates","the","hparams","for","each","of","the","conv","layers","usable","for",":","func",":","`","texar.tf.core.layers.get_layer","`","."]
code: def _build_conv1d_hparams(self, pool_hparams):
      """Creates the hparams for each of the conv layers usable for
      :func:`texar.tf.core.layers.get_layer`.
      """
      nconv = self._hparams.num_conv_layers
      if len(pool_hparams) != nconv:
          raise ValueError(
              "`pool_hparams` must be of length %d" % nconv
          )
  
      filters = _to_list(self._hparams.filters, "filters", nconv)
  
      if nconv == 1:
          kernel_size = _to_list(self._hparams.kernel_size)
          if not isinstance(kernel_size[0], (list, tuple)):
              kernel_size = [kernel_size]
      elif nconv > 1:
          kernel_size = _to_list(
              self._hparams.kernel_size, "kernel_size", nconv
          )
          kernel_size = [_to_list(ks) for ks in kernel_size]
  
      other_kwargs = self._hparams.other_conv_kwargs or {}
      if isinstance(other_kwargs, HParams):
          other_kwargs = other_kwargs.todict()
      if not isinstance(other_kwargs, dict):
          raise ValueError(
              "hparams['other_conv_kwargs'] must be a dict."
          )
  
      conv_pool_hparams = []
      activation_fn = get_activation_fn(
          self._hparams.conv_activation,
          self._hparams.conv_activation_kwargs,
      )
      for i in range(nconv):
          hparams_i = []
          names = []
          for ks_ij in kernel_size[i]:
              name = uniquify_str("conv_%d" % (i + 1), names)
              names.append(name)
              conv_kwargs_ij = {
                  "filters": filters[i],
                  "kernel_size": ks_ij,
                  "activation": activation_fn,
                  "name": name,
              }
              conv_kwargs_ij.update(other_kwargs)
              hparams_i.append(
                  {"type": "Conv1D", "kwargs": conv_kwargs_ij}
              )
          if len(hparams_i) == 1:
              conv_pool_hparams.append([hparams_i[0], pool_hparams[i]])
          else:  # creates MergeLayer
              mrg_kwargs_layers = []
              for hparams_ij in hparams_i:
                  seq_kwargs_j = {
                      "layers": [hparams_ij, pool_hparams[i]]
                  }
                  mrg_kwargs_layers.append(
                      {
                          "type": "SequentialLayer",
                          "kwargs": seq_kwargs_j,
                      }
                  )
              mrg_hparams = {
                  "type": "MergeLayer",
                  "kwargs": {
                      "layers": mrg_kwargs_layers,
                      "name": "conv_pool_%d" % (i + 1),
                  },
              }
              conv_pool_hparams.append(mrg_hparams)
  
      return conv_pool_hparams
  
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 4 for calling the Conv1DNetwork obj's underlying member method code with example usage: obj._build_conv1d_hparams(pool_hparams) and returns: conv_pool_hparams