prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [BUG] `CNNRegressor` missing essential initializing parameters
  **Describe the bug**
  <!--
  A clear and concise description of what the bug is.
  -->
  `CNNRegressor` misses parameters like `optimizer` in its constructor. There might be more things which don't coincide with `CNNClassifier` which should be added but since I'm not sure what all things might be missing, I'm opening this issue to bring it to notice.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sktime/regression/deep_learning/cnn.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 """Time Convolutional Neural Network (CNN) for regression."""
  3 
  4 __author__ = ["AurumnPegasus"]
  5 __all__ = ["CNNRegressor"]
  6 
  7 from sktime.networks.cnn import CNNNetwork
  8 from sktime.regression.deep_learning.base import BaseDeepRegressor
  9 from sktime.utils.validation._dependencies import _check_dl_dependencies
  10 
  11 _check_dl_dependencies(severity="warning")
  12 
  13 
  14 class CNNRegressor(BaseDeepRegressor):
  15     """Time Convolutional Neural Network (CNN), as described in [1].
  16 
  17     Parameters
  18     ----------
  19     should inherited fields be listed here?
  20     n_epochs       : int, default = 2000
  21         the number of epochs to train the model
  22     batch_size      : int, default = 16
  23         the number of samples per gradient update.
  24     kernel_size     : int, default = 7
  25         the length of the 1D convolution window
  26     avg_pool_size   : int, default = 3
  27         size of the average pooling windows
  28     n_conv_layers   : int, default = 2
  29         the number of convolutional plus average pooling layers
  30     filter_sizes    : array of shape (n_conv_layers) default = [6, 12]
  31     random_state    : int or None, default=None
  32         Seed for random number generation.
  33     verbose         : boolean, default = False
  34         whether to output extra information
  35     loss            : string, default="mean_squared_error"
  36         fit parameter for the keras model
  37     optimizer       : keras.optimizer, default=keras.optimizers.Adam(),
  38     metrics         : list of strings, default=["accuracy"],
  39 
  40     Notes
  41     -----
  42     .. [1] Zhao et. al, Convolutional neural networks for
  43     time series classification, Journal of
  44     Systems Engineering and Electronics, 28(1):2017.
  45 
  46     Adapted from the implementation from Fawaz et. al
  47     https://github.com/hfawaz/dl-4-tsc/blob/master/classifiers/cnn.py
  48     """
  49 
  50     def __init__(
  51         self,
  52         n_epochs=2000,
  53         batch_size=16,
  54         kernel_size=7,
  55         avg_pool_size=3,
  56         n_conv_layers=2,
  57         callbacks=None,
  58         verbose=False,
  59         loss="mean_squared_error",
  60         metrics=None,
  61         random_seed=0,
  62     ):
  63         _check_dl_dependencies(severity="error")
  64         super(CNNRegressor, self).__init__(
  65             batch_size=batch_size,
  66         )
  67         self.n_conv_layers = n_conv_layers
  68         self.avg_pool_size = avg_pool_size
  69         self.kernel_size = kernel_size
  70         self.callbacks = callbacks
  71         self.n_epochs = n_epochs
  72         self.batch_size = batch_size
  73         self.verbose = verbose
  74         self.loss = loss
  75         self.metrics = metrics
  76         self.random_seed = random_seed
  77         self._network = CNNNetwork()
  78 
  79     def build_model(self, input_shape, **kwargs):
  80         """Construct a compiled, un-trained, keras model that is ready for training.
  81 
  82         In sktime, time series are stored in numpy arrays of shape (d,m), where d
  83         is the number of dimensions, m is the series length. Keras/tensorflow assume
  84         data is in shape (m,d). This method also assumes (m,d). Transpose should
  85         happen in fit.
  86 
  87         Parameters
  88         ----------
  89         input_shape : tuple
  90             The shape of the data fed into the input layer, should be (m,d)
  91 
  92         Returns
  93         -------
  94         output : a compiled Keras Model
  95         """
  96         import tensorflow as tf
  97         from tensorflow import keras
  98 
  99         tf.random.set_seed(self.random_seed)
  100 
  101         if self.metrics is None:
  102             metrics = ["accuracy"]
  103         else:
  104             metrics = self.metrics
  105 
  106         input_layer, output_layer = self._network.build_network(input_shape, **kwargs)
  107 
  108         output_layer = keras.layers.Dense(units=1, activation="sigmoid")(output_layer)
  109 
  110         model = keras.models.Model(inputs=input_layer, outputs=output_layer)
  111 
  112         model.compile(
  113             loss=self.loss,
  114             optimizer=keras.optimizers.Adam(),
  115             metrics=metrics,
  116         )
  117         return model
  118 
  119     def _fit(self, X, y):
  120         """Fit the classifier on the training set (X, y).
  121 
  122         Parameters
  123         ----------
  124         X : np.ndarray of shape = (n_instances (n), n_dimensions (d), series_length (m))
  125             The training input samples.
  126         y : np.ndarray of shape n
  127             The training data class labels.
  128 
  129         Returns
  130         -------
  131         self : object
  132         """
  133         if self.callbacks is None:
  134             self._callbacks = []
  135 
  136         # Transpose to conform to Keras input style.
  137         X = X.transpose(0, 2, 1)
  138 
  139         self.input_shape = X.shape[1:]
  140         self.model_ = self.build_model(self.input_shape)
  141         if self.verbose:
  142             self.model.summary()
  143 
  144         self.history = self.model_.fit(
  145             X,
  146             y,
  147             batch_size=self.batch_size,
  148             epochs=self.n_epochs,
  149             verbose=self.verbose,
  150             callbacks=self._callbacks,
  151         )
  152         return self
  153
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sktime/regression/deep_learning/cnn.py b/sktime/regression/deep_learning/cnn.py
  --- a/sktime/regression/deep_learning/cnn.py
  +++ b/sktime/regression/deep_learning/cnn.py
  @@ -1,9 +1,11 @@
   # -*- coding: utf-8 -*-
   """Time Convolutional Neural Network (CNN) for regression."""
   
  -__author__ = ["AurumnPegasus"]
  +__author__ = ["AurumnPegasus", "achieveordie"]
   __all__ = ["CNNRegressor"]
   
  +from sklearn.utils import check_random_state
  +
   from sktime.networks.cnn import CNNNetwork
   from sktime.regression.deep_learning.base import BaseDeepRegressor
   from sktime.utils.validation._dependencies import _check_dl_dependencies
  @@ -34,7 +36,12 @@
           whether to output extra information
       loss            : string, default="mean_squared_error"
           fit parameter for the keras model
  -    optimizer       : keras.optimizer, default=keras.optimizers.Adam(),
  +    activation      : keras.activations or string, default `linear`
  +        function to use in the output layer.
  +    optimizer       : keras.optimizers or string, default `None`.
  +        when `None`, internally uses `keras.optimizers.Adam(0.01)`
  +    use_bias        : bool, default=True
  +        whether to use bias in the output layer.
       metrics         : list of strings, default=["accuracy"],
   
       Notes
  @@ -58,7 +65,10 @@
           verbose=False,
           loss="mean_squared_error",
           metrics=None,
  -        random_seed=0,
  +        random_state=0,
  +        activation="linear",
  +        use_bias=True,
  +        optimizer=None,
       ):
           _check_dl_dependencies(severity="error")
           super(CNNRegressor, self).__init__(
  @@ -73,7 +83,11 @@
           self.verbose = verbose
           self.loss = loss
           self.metrics = metrics
  -        self.random_seed = random_seed
  +        self.random_state = random_state
  +        self.activation = activation
  +        self.use_bias = use_bias
  +        self.optimizer = optimizer
  +        self.history = None
           self._network = CNNNetwork()
   
       def build_model(self, input_shape, **kwargs):
  @@ -96,7 +110,7 @@
           import tensorflow as tf
           from tensorflow import keras
   
  -        tf.random.set_seed(self.random_seed)
  +        tf.random.set_seed(self.random_state)
   
           if self.metrics is None:
               metrics = ["accuracy"]
  @@ -105,13 +119,23 @@
   
           input_layer, output_layer = self._network.build_network(input_shape, **kwargs)
   
  -        output_layer = keras.layers.Dense(units=1, activation="sigmoid")(output_layer)
  +        output_layer = keras.layers.Dense(
  +            units=1,
  +            activation=self.activation,
  +            use_bias=self.use_bias,
  +        )(output_layer)
  +
  +        self.optimizer_ = (
  +            keras.optimizers.Adam(learning_rate=0.01)
  +            if self.optimizer is None
  +            else self.optimizer
  +        )
   
           model = keras.models.Model(inputs=input_layer, outputs=output_layer)
   
           model.compile(
               loss=self.loss,
  -            optimizer=keras.optimizers.Adam(),
  +            optimizer=self.optimizer_,
               metrics=metrics,
           )
           return model
  @@ -136,6 +160,7 @@
           # Transpose to conform to Keras input style.
           X = X.transpose(0, 2, 1)
   
  +        check_random_state(self.random_state)
           self.input_shape = X.shape[1:]
           self.model_ = self.build_model(self.input_shape)
           if self.verbose:
  
verification_info: {"golden_diff": "diff --git a/sktime/regression/deep_learning/cnn.py b/sktime/regression/deep_learning/cnn.py\n--- a/sktime/regression/deep_learning/cnn.py\n+++ b/sktime/regression/deep_learning/cnn.py\n@@ -1,9 +1,11 @@\n # -*- coding: utf-8 -*-\n \"\"\"Time Convolutional Neural Network (CNN) for regression.\"\"\"\n \n-__author__ = [\"AurumnPegasus\"]\n+__author__ = [\"AurumnPegasus\", \"achieveordie\"]\n __all__ = [\"CNNRegressor\"]\n \n+from sklearn.utils import check_random_state\n+\n from sktime.networks.cnn import CNNNetwork\n from sktime.regression.deep_learning.base import BaseDeepRegressor\n from sktime.utils.validation._dependencies import _check_dl_dependencies\n@@ -34,7 +36,12 @@\n         whether to output extra information\n     loss            : string, default=\"mean_squared_error\"\n         fit parameter for the keras model\n-    optimizer       : keras.optimizer, default=keras.optimizers.Adam(),\n+    activation      : keras.activations or string, default `linear`\n+        function to use in the output layer.\n+    optimizer       : keras.optimizers or string, default `None`.\n+        when `None`, internally uses `keras.optimizers.Adam(0.01)`\n+    use_bias        : bool, default=True\n+        whether to use bias in the output layer.\n     metrics         : list of strings, default=[\"accuracy\"],\n \n     Notes\n@@ -58,7 +65,10 @@\n         verbose=False,\n         loss=\"mean_squared_error\",\n         metrics=None,\n-        random_seed=0,\n+        random_state=0,\n+        activation=\"linear\",\n+        use_bias=True,\n+        optimizer=None,\n     ):\n         _check_dl_dependencies(severity=\"error\")\n         super(CNNRegressor, self).__init__(\n@@ -73,7 +83,11 @@\n         self.verbose = verbose\n         self.loss = loss\n         self.metrics = metrics\n-        self.random_seed = random_seed\n+        self.random_state = random_state\n+        self.activation = activation\n+        self.use_bias = use_bias\n+        self.optimizer = optimizer\n+        self.history = None\n         self._network = CNNNetwork()\n \n     def build_model(self, input_shape, **kwargs):\n@@ -96,7 +110,7 @@\n         import tensorflow as tf\n         from tensorflow import keras\n \n-        tf.random.set_seed(self.random_seed)\n+        tf.random.set_seed(self.random_state)\n \n         if self.metrics is None:\n             metrics = [\"accuracy\"]\n@@ -105,13 +119,23 @@\n \n         input_layer, output_layer = self._network.build_network(input_shape, **kwargs)\n \n-        output_layer = keras.layers.Dense(units=1, activation=\"sigmoid\")(output_layer)\n+        output_layer = keras.layers.Dense(\n+            units=1,\n+            activation=self.activation,\n+            use_bias=self.use_bias,\n+        )(output_layer)\n+\n+        self.optimizer_ = (\n+            keras.optimizers.Adam(learning_rate=0.01)\n+            if self.optimizer is None\n+            else self.optimizer\n+        )\n \n         model = keras.models.Model(inputs=input_layer, outputs=output_layer)\n \n         model.compile(\n             loss=self.loss,\n-            optimizer=keras.optimizers.Adam(),\n+            optimizer=self.optimizer_,\n             metrics=metrics,\n         )\n         return model\n@@ -136,6 +160,7 @@\n         # Transpose to conform to Keras input style.\n         X = X.transpose(0, 2, 1)\n \n+        check_random_state(self.random_state)\n         self.input_shape = X.shape[1:]\n         self.model_ = self.build_model(self.input_shape)\n         if self.verbose:\n", "issue": "[BUG] `CNNRegressor` missing essential initializing parameters\n**Describe the bug**\r\n<!--\r\nA clear and concise description of what the bug is.\r\n-->\r\n`CNNRegressor` misses parameters like `optimizer` in its constructor. There might be more things which don't coincide with `CNNClassifier` which should be added but since I'm not sure what all things might be missing, I'm opening this issue to bring it to notice.\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Time Convolutional Neural Network (CNN) for regression.\"\"\"\n\n__author__ = [\"AurumnPegasus\"]\n__all__ = [\"CNNRegressor\"]\n\nfrom sktime.networks.cnn import CNNNetwork\nfrom sktime.regression.deep_learning.base import BaseDeepRegressor\nfrom sktime.utils.validation._dependencies import _check_dl_dependencies\n\n_check_dl_dependencies(severity=\"warning\")\n\n\nclass CNNRegressor(BaseDeepRegressor):\n    \"\"\"Time Convolutional Neural Network (CNN), as described in [1].\n\n    Parameters\n    ----------\n    should inherited fields be listed here?\n    n_epochs       : int, default = 2000\n        the number of epochs to train the model\n    batch_size      : int, default = 16\n        the number of samples per gradient update.\n    kernel_size     : int, default = 7\n        the length of the 1D convolution window\n    avg_pool_size   : int, default = 3\n        size of the average pooling windows\n    n_conv_layers   : int, default = 2\n        the number of convolutional plus average pooling layers\n    filter_sizes    : array of shape (n_conv_layers) default = [6, 12]\n    random_state    : int or None, default=None\n        Seed for random number generation.\n    verbose         : boolean, default = False\n        whether to output extra information\n    loss            : string, default=\"mean_squared_error\"\n        fit parameter for the keras model\n    optimizer       : keras.optimizer, default=keras.optimizers.Adam(),\n    metrics         : list of strings, default=[\"accuracy\"],\n\n    Notes\n    -----\n    .. [1] Zhao et. al, Convolutional neural networks for\n    time series classification, Journal of\n    Systems Engineering and Electronics, 28(1):2017.\n\n    Adapted from the implementation from Fawaz et. al\n    https://github.com/hfawaz/dl-4-tsc/blob/master/classifiers/cnn.py\n    \"\"\"\n\n    def __init__(\n        self,\n        n_epochs=2000,\n        batch_size=16,\n        kernel_size=7,\n        avg_pool_size=3,\n        n_conv_layers=2,\n        callbacks=None,\n        verbose=False,\n        loss=\"mean_squared_error\",\n        metrics=None,\n        random_seed=0,\n    ):\n        _check_dl_dependencies(severity=\"error\")\n        super(CNNRegressor, self).__init__(\n            batch_size=batch_size,\n        )\n        self.n_conv_layers = n_conv_layers\n        self.avg_pool_size = avg_pool_size\n        self.kernel_size = kernel_size\n        self.callbacks = callbacks\n        self.n_epochs = n_epochs\n        self.batch_size = batch_size\n        self.verbose = verbose\n        self.loss = loss\n        self.metrics = metrics\n        self.random_seed = random_seed\n        self._network = CNNNetwork()\n\n    def build_model(self, input_shape, **kwargs):\n        \"\"\"Construct a compiled, un-trained, keras model that is ready for training.\n\n        In sktime, time series are stored in numpy arrays of shape (d,m), where d\n        is the number of dimensions, m is the series length. Keras/tensorflow assume\n        data is in shape (m,d). This method also assumes (m,d). Transpose should\n        happen in fit.\n\n        Parameters\n        ----------\n        input_shape : tuple\n            The shape of the data fed into the input layer, should be (m,d)\n\n        Returns\n        -------\n        output : a compiled Keras Model\n        \"\"\"\n        import tensorflow as tf\n        from tensorflow import keras\n\n        tf.random.set_seed(self.random_seed)\n\n        if self.metrics is None:\n            metrics = [\"accuracy\"]\n        else:\n            metrics = self.metrics\n\n        input_layer, output_layer = self._network.build_network(input_shape, **kwargs)\n\n        output_layer = keras.layers.Dense(units=1, activation=\"sigmoid\")(output_layer)\n\n        model = keras.models.Model(inputs=input_layer, outputs=output_layer)\n\n        model.compile(\n            loss=self.loss,\n            optimizer=keras.optimizers.Adam(),\n            metrics=metrics,\n        )\n        return model\n\n    def _fit(self, X, y):\n        \"\"\"Fit the classifier on the training set (X, y).\n\n        Parameters\n        ----------\n        X : np.ndarray of shape = (n_instances (n), n_dimensions (d), series_length (m))\n            The training input samples.\n        y : np.ndarray of shape n\n            The training data class labels.\n\n        Returns\n        -------\n        self : object\n        \"\"\"\n        if self.callbacks is None:\n            self._callbacks = []\n\n        # Transpose to conform to Keras input style.\n        X = X.transpose(0, 2, 1)\n\n        self.input_shape = X.shape[1:]\n        self.model_ = self.build_model(self.input_shape)\n        if self.verbose:\n            self.model.summary()\n\n        self.history = self.model_.fit(\n            X,\n            y,\n            batch_size=self.batch_size,\n            epochs=self.n_epochs,\n            verbose=self.verbose,\n            callbacks=self._callbacks,\n        )\n        return self\n", "path": "sktime/regression/deep_learning/cnn.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Time Convolutional Neural Network (CNN) for regression.\"\"\"\n\n__author__ = [\"AurumnPegasus\", \"achieveordie\"]\n__all__ = [\"CNNRegressor\"]\n\nfrom sklearn.utils import check_random_state\n\nfrom sktime.networks.cnn import CNNNetwork\nfrom sktime.regression.deep_learning.base import BaseDeepRegressor\nfrom sktime.utils.validation._dependencies import _check_dl_dependencies\n\n_check_dl_dependencies(severity=\"warning\")\n\n\nclass CNNRegressor(BaseDeepRegressor):\n    \"\"\"Time Convolutional Neural Network (CNN), as described in [1].\n\n    Parameters\n    ----------\n    should inherited fields be listed here?\n    n_epochs       : int, default = 2000\n        the number of epochs to train the model\n    batch_size      : int, default = 16\n        the number of samples per gradient update.\n    kernel_size     : int, default = 7\n        the length of the 1D convolution window\n    avg_pool_size   : int, default = 3\n        size of the average pooling windows\n    n_conv_layers   : int, default = 2\n        the number of convolutional plus average pooling layers\n    filter_sizes    : array of shape (n_conv_layers) default = [6, 12]\n    random_state    : int or None, default=None\n        Seed for random number generation.\n    verbose         : boolean, default = False\n        whether to output extra information\n    loss            : string, default=\"mean_squared_error\"\n        fit parameter for the keras model\n    activation      : keras.activations or string, default `linear`\n        function to use in the output layer.\n    optimizer       : keras.optimizers or string, default `None`.\n        when `None`, internally uses `keras.optimizers.Adam(0.01)`\n    use_bias        : bool, default=True\n        whether to use bias in the output layer.\n    metrics         : list of strings, default=[\"accuracy\"],\n\n    Notes\n    -----\n    .. [1] Zhao et. al, Convolutional neural networks for\n    time series classification, Journal of\n    Systems Engineering and Electronics, 28(1):2017.\n\n    Adapted from the implementation from Fawaz et. al\n    https://github.com/hfawaz/dl-4-tsc/blob/master/classifiers/cnn.py\n    \"\"\"\n\n    def __init__(\n        self,\n        n_epochs=2000,\n        batch_size=16,\n        kernel_size=7,\n        avg_pool_size=3,\n        n_conv_layers=2,\n        callbacks=None,\n        verbose=False,\n        loss=\"mean_squared_error\",\n        metrics=None,\n        random_state=0,\n        activation=\"linear\",\n        use_bias=True,\n        optimizer=None,\n    ):\n        _check_dl_dependencies(severity=\"error\")\n        super(CNNRegressor, self).__init__(\n            batch_size=batch_size,\n        )\n        self.n_conv_layers = n_conv_layers\n        self.avg_pool_size = avg_pool_size\n        self.kernel_size = kernel_size\n        self.callbacks = callbacks\n        self.n_epochs = n_epochs\n        self.batch_size = batch_size\n        self.verbose = verbose\n        self.loss = loss\n        self.metrics = metrics\n        self.random_state = random_state\n        self.activation = activation\n        self.use_bias = use_bias\n        self.optimizer = optimizer\n        self.history = None\n        self._network = CNNNetwork()\n\n    def build_model(self, input_shape, **kwargs):\n        \"\"\"Construct a compiled, un-trained, keras model that is ready for training.\n\n        In sktime, time series are stored in numpy arrays of shape (d,m), where d\n        is the number of dimensions, m is the series length. Keras/tensorflow assume\n        data is in shape (m,d). This method also assumes (m,d). Transpose should\n        happen in fit.\n\n        Parameters\n        ----------\n        input_shape : tuple\n            The shape of the data fed into the input layer, should be (m,d)\n\n        Returns\n        -------\n        output : a compiled Keras Model\n        \"\"\"\n        import tensorflow as tf\n        from tensorflow import keras\n\n        tf.random.set_seed(self.random_state)\n\n        if self.metrics is None:\n            metrics = [\"accuracy\"]\n        else:\n            metrics = self.metrics\n\n        input_layer, output_layer = self._network.build_network(input_shape, **kwargs)\n\n        output_layer = keras.layers.Dense(\n            units=1,\n            activation=self.activation,\n            use_bias=self.use_bias,\n        )(output_layer)\n\n        self.optimizer_ = (\n            keras.optimizers.Adam(learning_rate=0.01)\n            if self.optimizer is None\n            else self.optimizer\n        )\n\n        model = keras.models.Model(inputs=input_layer, outputs=output_layer)\n\n        model.compile(\n            loss=self.loss,\n            optimizer=self.optimizer_,\n            metrics=metrics,\n        )\n        return model\n\n    def _fit(self, X, y):\n        \"\"\"Fit the classifier on the training set (X, y).\n\n        Parameters\n        ----------\n        X : np.ndarray of shape = (n_instances (n), n_dimensions (d), series_length (m))\n            The training input samples.\n        y : np.ndarray of shape n\n            The training data class labels.\n\n        Returns\n        -------\n        self : object\n        \"\"\"\n        if self.callbacks is None:\n            self._callbacks = []\n\n        # Transpose to conform to Keras input style.\n        X = X.transpose(0, 2, 1)\n\n        check_random_state(self.random_state)\n        self.input_shape = X.shape[1:]\n        self.model_ = self.build_model(self.input_shape)\n        if self.verbose:\n            self.model.summary()\n\n        self.history = self.model_.fit(\n            X,\n            y,\n            batch_size=self.batch_size,\n            epochs=self.n_epochs,\n            verbose=self.verbose,\n            callbacks=self._callbacks,\n        )\n        return self\n", "path": "sktime/regression/deep_learning/cnn.py"}]}