diff --git a/nbs/common.base_auto.ipynb b/nbs/common.base_auto.ipynb index c2626191d..e4b95be7a 100644 --- a/nbs/common.base_auto.ipynb +++ b/nbs/common.base_auto.ipynb @@ -529,12 +529,6 @@ "outputs": [], "source": [ "#| hide\n", - "\n", - "#| hide\n", - "import os\n", - "os.environ[\"PYTORCH_ENABLE_MPS_FALLBACK\"] = \"1\"\n", - "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n", - "\n", "import optuna\n", "import pandas as pd\n", "from neuralforecast.models.mlp import MLP\n", @@ -647,7 +641,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ea77450f", + "id": "463d4dc0-b25a-4ce6-9172-5690dc979f0b", "metadata": {}, "outputs": [], "source": [ @@ -657,8 +651,18 @@ "from neuralforecast.models.mlp import MLP\n", "from neuralforecast.utils import AirPassengersDF as Y_df\n", "from neuralforecast.tsdataset import TimeSeriesDataset\n", - "from neuralforecast.losses.pytorch import MAE, MSE\n", - "\n", + "from neuralforecast.losses.pytorch import MAE, MSE" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "882c8331-440a-4758-a56c-07a78c0b1603", + "metadata": {}, + "outputs": [], + "source": [ + "#| hide\n", + "# Unit tests to guarantee that losses are correctly instantiated\n", "Y_train_df = Y_df[Y_df.ds<='1959-12-31'] # 132 train\n", "Y_test_df = Y_df[Y_df.ds>'1959-12-31'] # 12 test\n", "\n", diff --git a/nbs/common.base_windows.ipynb b/nbs/common.base_windows.ipynb index cab27b4df..0d8b4b3a2 100644 --- a/nbs/common.base_windows.ipynb +++ b/nbs/common.base_windows.ipynb @@ -817,16 +817,25 @@ { "cell_type": "code", "execution_count": null, - "id": "b2fd48a7", + "id": "8927f2e5-f376-4c99-bb8f-8cbb73efe01e", "metadata": {}, "outputs": [], "source": [ "#| hide\n", - "# add h=0,1 unit test for _parse_windows \n", "from neuralforecast.losses.pytorch import MAE\n", "from neuralforecast.utils import AirPassengersDF\n", - "from neuralforecast.tsdataset import TimeSeriesDataset, TimeSeriesDataModule\n", - "\n", + "from neuralforecast.tsdataset import TimeSeriesDataset, TimeSeriesDataModule" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "61490e69-f014-4087-83c5-540d5bd7d458", + "metadata": {}, + "outputs": [], + "source": [ + "#| hide\n", + "# add h=0,1 unit test for _parse_windows \n", "# Declare batch\n", "AirPassengersDF['x'] = np.array(len(AirPassengersDF))\n", "AirPassengersDF['x2'] = np.array(len(AirPassengersDF)) * 2\n", diff --git a/nbs/common.scalers.ipynb b/nbs/common.scalers.ipynb index 9d40327d2..dc177d735 100644 --- a/nbs/common.scalers.ipynb +++ b/nbs/common.scalers.ipynb @@ -40,19 +40,6 @@ "![Figure 1. Illustration of temporal normalization (left), layer normalization (center) and batch normalization (right). The entries in green show the components used to compute the normalizing statistics.](imgs_models/temporal_norm.png)" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "f5400f41", - "metadata": {}, - "outputs": [], - "source": [ - "#| hide\n", - "import os\n", - "os.environ[\"PYTORCH_ENABLE_MPS_FALLBACK\"] = \"1\"\n", - "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"" - ] - }, { "cell_type": "code", "execution_count": null, diff --git a/nbs/core.ipynb b/nbs/core.ipynb index 580e740b5..8fe799306 100644 --- a/nbs/core.ipynb +++ b/nbs/core.ipynb @@ -40,10 +40,6 @@ "outputs": [], "source": [ "#| hide\n", - "import os\n", - "os.environ[\"PYTORCH_ENABLE_MPS_FALLBACK\"] = \"1\"\n", - "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n", - "\n", "import shutil\n", "from fastcore.test import test_eq, test_fail\n", "from nbdev.showdoc import show_doc\n", @@ -907,13 +903,23 @@ { "cell_type": "code", "execution_count": null, - "id": "8898e349-8000-4668-a1c5-52c03c69e85a", + "id": "5d6ef366-daec-4ec6-a2ae-199c6ea39a51", "metadata": {}, "outputs": [], "source": [ "#| hide\n", "import logging\n", - "import warnings\n", + "import warnings" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0ac1aa65-40a4-4909-bdfb-1439c30439b8", + "metadata": {}, + "outputs": [], + "source": [ + "#| hide\n", "logging.getLogger(\"pytorch_lightning\").setLevel(logging.ERROR)\n", "warnings.filterwarnings(\"ignore\")" ] diff --git a/nbs/examples/Neuralforecast_Map.ipynb b/nbs/examples/Neuralforecast_Map.ipynb index c4482c319..efb83f54a 100644 --- a/nbs/examples/Neuralforecast_Map.ipynb +++ b/nbs/examples/Neuralforecast_Map.ipynb @@ -145,5 +145,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/nbs/losses.numpy.ipynb b/nbs/losses.numpy.ipynb index 926292ab3..4622df90c 100644 --- a/nbs/losses.numpy.ipynb +++ b/nbs/losses.numpy.ipynb @@ -49,6 +49,7 @@ "outputs": [], "source": [ "#| hide\n", + "from IPython.display import Image\n", "from nbdev.showdoc import show_doc" ] }, @@ -59,7 +60,6 @@ "outputs": [], "source": [ "#| hide\n", - "from IPython.display import Image\n", "WIDTH = 600\n", "HEIGHT = 300" ] diff --git a/nbs/models.hint.ipynb b/nbs/models.hint.ipynb index af885136b..029046dfb 100644 --- a/nbs/models.hint.ipynb +++ b/nbs/models.hint.ipynb @@ -47,10 +47,6 @@ "outputs": [], "source": [ "#| hide\n", - "import os\n", - "os.environ[\"PYTORCH_ENABLE_MPS_FALLBACK\"] = \"1\"\n", - "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n", - "\n", "from nbdev.showdoc import show_doc\n", "from neuralforecast.losses.pytorch import GMM\n", "from neuralforecast import NeuralForecast\n", diff --git a/nbs/models.ipynb b/nbs/models.ipynb index 5bfca82cb..8cf4d228f 100644 --- a/nbs/models.ipynb +++ b/nbs/models.ipynb @@ -22,19 +22,6 @@ "%autoreload 2" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "cd088010", - "metadata": {}, - "outputs": [], - "source": [ - "#| hide\n", - "import os\n", - "os.environ[\"PYTORCH_ENABLE_MPS_FALLBACK\"] = \"1\"\n", - "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"" - ] - }, { "cell_type": "code", "execution_count": null, @@ -2222,7 +2209,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fd3a085a", + "id": "db128f64-b311-479e-bf81-07c3bf9f1a5e", "metadata": {}, "outputs": [], "source": [ @@ -2232,8 +2219,17 @@ "import matplotlib.pyplot as plt\n", "\n", "from neuralforecast.tsdataset import TimeSeriesDataset\n", - "from neuralforecast.utils import AirPassengersDF as Y_df\n", - "\n", + "from neuralforecast.utils import AirPassengersDF as Y_df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1691fdcc-99e3-472b-ae26-03fb89847227", + "metadata": {}, + "outputs": [], + "source": [ + "#| hide\n", "# Split train/test and declare time series dataset\n", "Y_train_df = Y_df[Y_df.ds<='1959-12-31'] # 132 train\n", "Y_test_df = Y_df[Y_df.ds>'1959-12-31'] # 12 test\n", @@ -2285,15 +2281,24 @@ { "cell_type": "code", "execution_count": null, - "id": "56493784", + "id": "0bd1d011-aafb-4b7c-a0a0-0f190b529fa8", + "metadata": {}, + "outputs": [], + "source": [ + "#| hide\n", + "from neuralforecast.losses.pytorch import GMM, sCRPS" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7e471ca-a633-4868-be0b-3f2992b6cdc1", "metadata": {}, "outputs": [], "source": [ "#| hide\n", "## TODO: Add unit tests for interactions between loss/valid_loss types\n", "## TODO: Unit tests (2 types of networks x 2 types of loss x 2 types of valid loss)\n", - "from neuralforecast.losses.pytorch import GMM, sCRPS\n", - "\n", "## Checking if base recurrent methods run point valid_loss correctly\n", "tcn_config = {\n", " \"learning_rate\": tune.choice([1e-3]), # Initial Learning rate\n", diff --git a/nbs/models.nbeatsx.ipynb b/nbs/models.nbeatsx.ipynb index 7f1264ea3..10d59d948 100644 --- a/nbs/models.nbeatsx.ipynb +++ b/nbs/models.nbeatsx.ipynb @@ -57,9 +57,6 @@ "outputs": [], "source": [ "#| hide\n", - "import os\n", - "os.environ[\"PYTORCH_ENABLE_MPS_FALLBACK\"] = \"1\"\n", - "\n", "from fastcore.test import test_eq, test_fail\n", "from nbdev.showdoc import show_doc\n", "from neuralforecast.utils import generate_series" diff --git a/nbs/models.nhits.ipynb b/nbs/models.nhits.ipynb index 3aa9e18da..3d9dbba74 100644 --- a/nbs/models.nhits.ipynb +++ b/nbs/models.nhits.ipynb @@ -52,18 +52,6 @@ "![Figure 1. Neural Hierarchical Interpolation for Time Series (NHITS).](imgs_models/nhits.png)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#| hide\n", - "import os\n", - "os.environ[\"PYTORCH_ENABLE_MPS_FALLBACK\"] = \"1\"\n", - "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"" - ] - }, { "cell_type": "code", "execution_count": null,