class_docstr: Establish the network structure for a CNN.
  
  Adapted from the implementation used in [1]
  
  Parameters
  ----------
  kernel_size : int, default = 7
      specifying the length of the 1D convolution window
  avg_pool_size : int, default = 3
      size of the average pooling windows
  n_conv_layers : int, default = 2
      the number of convolutional plus average pooling layers
  filter_sizes : array of int, shape = (nb_conv_layers)
  activation : string, default = sigmoid
      keras activation function
  padding : string, default = "auto"
      Controls padding logic for the convolutional layers,
      i.e. whether ``'valid'`` and ``'same'`` are passed to the ``Conv1D`` layer.
      - "auto": as per original implementation, ``"sam"`` is passed if
        ``input_shape[0] < 60`` in the input layer, and ``"valid"`` otherwise.
      - "valid", "same", and other values are passed directly to ``Conv1D``
  random_state    : int, default = 0
      seed to any needed random actions
  
  Notes
  -----
  Adapted from source code
  https://github.com/hfawaz/dl-4-tsc/blob/master/classifiers/cnn.py
  
  References
  ----------
  .. [1] Zhao et al. Convolutional neural networks for time series classification,
  Journal of Systems Engineering and Electronics 28(1), 162--169, 2017
class_docstr_tok: ["Establish","the","network","structure","for","a","CNN",".","Adapted","from","the","implementation","used","in","[","1","]","Parameters","--","--","--","--","--","kernel_size",":","int",",","default","=","7","specifying","the","length","of","the","1D","convolution","window","avg_pool_size",":","int",",","default","=","3","size","of","the","average","pooling","windows","n_conv_layers",":","int",",","default","=","2","the","number","of","convolutional","plus","average","pooling","layers","filter_sizes",":","array","of","int",",","shape","=","(","nb_conv_layers",")","activation",":","string",",","default","=","sigmoid","keras","activation","function","padding",":","string",",","default","=","``","auto","''","Controls","padding","logic","for","the","convolutional","layers",",","i.e",".","whether","``","'valid","'","``","and","``","'same","'","``","are","passed","to","the","``","Conv1D","``","layer",".","-","``","auto","''",":","as","per","original","implementation",",","``","``","sam","''","``","is","passed","if","``","input_shape","[","0","]","<","60","``","in","the","input","layer",",","and","``","``","valid","''","``","otherwise",".","-","``","valid","''",",","``","same","''",",","and","other","values","are","passed","directly","to","``","Conv1D","``","random_state",":","int",",","default","=","0","seed","to","any","needed","random","actions","Notes","--","--","-","Adapted","from","source","code","https",":","\/\/github.com\/hfawaz\/dl-4-tsc\/blob\/master\/classifiers\/cnn.py","References","--","--","--","--","--","..","[","1","]","Zhao","et","al",".","Convolutional","neural","networks","for","time","series","classification",",","Journal","of","Systems","Engineering","and","Electronics","28","(","1",")",",","162","--","169",",","2017"]
docstr: Construct a network and return its input and output layers.
  
  Arguments
  ---------
  input_shape : tuple
      The shape of the data fed into the input layer
  
  Returns
  -------
  input_layer : a keras layer
  output_layer : a keras layer
docstr_tok: ["Construct","a","network","and","return","its","input","and","output","layers",".","Arguments","--","--","--","--","-","input_shape",":","tuple","The","shape","of","the","data","fed","into","the","input","layer","Returns","--","--","--","-","input_layer",":","a","keras","layer","output_layer",":","a","keras","layer"]
code: def build_network(self, input_shape, **kwargs):
      """Construct a network and return its input and output layers.
  
      Arguments
      ---------
      input_shape : tuple
          The shape of the data fed into the input layer
  
      Returns
      -------
      input_layer : a keras layer
      output_layer : a keras layer
      """
      from tensorflow import keras
  
      fs = self._filter_sizes
      nconv = self.n_conv_layers
      padding = self.padding
  
      # this is the condition from the original implementation
      if padding == "auto":
          if input_shape[0] < 60:
              padding = "same"
          else:
              padding = "valid"
  
      # Extends filter_sizes to match n_conv_layers length
      filter_sizes = fs[:nconv] + [fs[-1]] * max(0, nconv - len(fs))
  
      input_layer = keras.layers.Input(input_shape)
  
      conv = keras.layers.Conv1D(
          filters=filter_sizes[0],
          kernel_size=self.kernel_size,
          padding=padding,
          activation=self.activation,
      )(input_layer)
      conv = keras.layers.AveragePooling1D(
          pool_size=self.avg_pool_size
      )(conv)
  
      for i in range(1, self.n_conv_layers):
          conv = keras.layers.Conv1D(
              filters=filter_sizes[i],
              kernel_size=self.kernel_size,
              padding=padding,
              activation=self.activation,
          )(conv)
          conv = keras.layers.AveragePooling1D(
              pool_size=self.avg_pool_size
          )(conv)
  
      flatten_layer = keras.layers.Flatten()(conv)
  
      return input_layer, flatten_layer
  
imports: from sktime.networks.base import BaseDeepNetwork
  from sktime.utils.validation._dependencies import _check_dl_dependencies
label_desc: Use image node_id 2 for calling the CNNNetwork obj's underlying member method code with example usage: obj.build_network(input_shape) and returns: input_layer,  flatten_layer