diff --git a/PyPOTS_Imputation.ipynb b/PyPOTS_Imputation.ipynb index cad76ad..54e73c9 100644 --- a/PyPOTS_Imputation.ipynb +++ b/PyPOTS_Imputation.ipynb @@ -16,21 +16,21 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:30:38 [INFO]: Have set the random seed as 16 for numpy and pytorch.\n", - "2024-03-17 22:30:38 [INFO]: Loading the dataset physionet_2012 with TSDB (https://github.com/WenjieDu/Time_Series_Data_Beans)...\n", - "2024-03-17 22:30:38 [INFO]: Starting preprocessing physionet_2012...\n", - "2024-03-17 22:30:38 [INFO]: You're using dataset physionet_2012, please cite it properly in your work. You can find its reference information at the below link: \n", + "2024-05-21 12:32:00 [INFO]: Have set the random seed as 16 for numpy and pytorch.\n", + "2024-05-21 12:32:00 [INFO]: Loading the dataset physionet_2012 with TSDB (https://github.com/WenjieDu/Time_Series_Data_Beans)...\n", + "2024-05-21 12:32:00 [INFO]: Starting preprocessing physionet_2012...\n", + "2024-05-21 12:32:00 [INFO]: You're using dataset physionet_2012, please cite it properly in your work. You can find its reference information at the below link: \n", "https://github.com/WenjieDu/TSDB/tree/main/dataset_profiles/physionet_2012\n", - "2024-03-17 22:30:38 [INFO]: Dataset physionet_2012 has already been downloaded. Processing directly...\n", - "2024-03-17 22:30:38 [INFO]: Dataset physionet_2012 has already been cached. Loading from cache directly...\n", - "2024-03-17 22:30:39 [INFO]: Loaded successfully!\n" + "2024-05-21 12:32:00 [INFO]: Dataset physionet_2012 has already been downloaded. Processing directly...\n", + "2024-05-21 12:32:00 [INFO]: Dataset physionet_2012 has already been cached. Loading from cache directly...\n", + "2024-05-21 12:32:00 [INFO]: Loaded successfully!\n" ] }, { @@ -58,7 +58,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -87,17 +87,17 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:30:56 [INFO]: Using the given device: cuda\n", - "2024-03-17 22:30:56 [INFO]: Model files will be saved to tutorial_results/imputation/saits/20240317_T223056\n", - "2024-03-17 22:30:56 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/saits/20240317_T223056/tensorboard\n", - "2024-03-17 22:30:56 [INFO]: SAITS initialized with the given hyperparameters, the number of trainable parameters: 1,378,358\n" + "2024-05-21 12:32:19 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 12:32:19 [INFO]: Model files will be saved to tutorial_results/imputation/saits/20240521_T123219\n", + "2024-05-21 12:32:19 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/saits/20240521_T123219/tensorboard\n", + "2024-05-21 12:32:19 [INFO]: SAITS initialized with the given hyperparameters, the number of trainable parameters: 1,378,358\n" ] } ], @@ -111,7 +111,7 @@ " n_features=physionet2012_dataset['n_features'],\n", " n_layers=2,\n", " d_model=256,\n", - " d_inner=128,\n", + " d_ffn=128,\n", " n_heads=4,\n", " d_k=64,\n", " d_v=64,\n", @@ -147,25 +147,25 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:31:04 [INFO]: Epoch 001 - training loss: 0.7161, validating loss: 0.3840\n", - "2024-03-17 22:31:11 [INFO]: Epoch 002 - training loss: 0.5172, validating loss: 0.3559\n", - "2024-03-17 22:31:18 [INFO]: Epoch 003 - training loss: 0.4633, validating loss: 0.3153\n", - "2024-03-17 22:31:25 [INFO]: Epoch 004 - training loss: 0.4269, validating loss: 0.3069\n", - "2024-03-17 22:31:33 [INFO]: Epoch 005 - training loss: 0.3975, validating loss: 0.2906\n", - "2024-03-17 22:31:40 [INFO]: Epoch 006 - training loss: 0.3745, validating loss: 0.2811\n", - "2024-03-17 22:31:47 [INFO]: Epoch 007 - training loss: 0.3600, validating loss: 0.2766\n", - "2024-03-17 22:31:54 [INFO]: Epoch 008 - training loss: 0.3526, validating loss: 0.2721\n", - "2024-03-17 22:32:00 [INFO]: Epoch 009 - training loss: 0.3424, validating loss: 0.2675\n", - "2024-03-17 22:32:06 [INFO]: Epoch 010 - training loss: 0.3361, validating loss: 0.2696\n", - "2024-03-17 22:32:06 [INFO]: Finished training.\n", - "2024-03-17 22:32:06 [INFO]: Saved the model to tutorial_results/imputation/saits/20240317_T223056/SAITS.pypots\n" + "2024-05-21 12:32:29 [INFO]: Epoch 001 - training loss: 0.7362, validation loss: 0.3747\n", + "2024-05-21 12:32:36 [INFO]: Epoch 002 - training loss: 0.5380, validation loss: 0.3397\n", + "2024-05-21 12:32:43 [INFO]: Epoch 003 - training loss: 0.4889, validation loss: 0.3128\n", + "2024-05-21 12:32:50 [INFO]: Epoch 004 - training loss: 0.4549, validation loss: 0.2992\n", + "2024-05-21 12:32:57 [INFO]: Epoch 005 - training loss: 0.4289, validation loss: 0.2792\n", + "2024-05-21 12:33:04 [INFO]: Epoch 006 - training loss: 0.4057, validation loss: 0.2748\n", + "2024-05-21 12:33:11 [INFO]: Epoch 007 - training loss: 0.3908, validation loss: 0.2692\n", + "2024-05-21 12:33:18 [INFO]: Epoch 008 - training loss: 0.3803, validation loss: 0.2641\n", + "2024-05-21 12:33:25 [INFO]: Epoch 009 - training loss: 0.3724, validation loss: 0.2628\n", + "2024-05-21 12:33:32 [INFO]: Epoch 010 - training loss: 0.3660, validation loss: 0.2613\n", + "2024-05-21 12:33:32 [INFO]: Finished training. The best model is from epoch#10.\n", + "2024-05-21 12:33:32 [INFO]: Saved the model to tutorial_results/imputation/saits/20240521_T123219/SAITS.pypots\n" ] } ], @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -187,14 +187,14 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.2312\n" + "Testing mean absolute error: 0.2372\n" ] } ], @@ -221,17 +221,17 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:32:07 [INFO]: Using the given device: cuda\n", - "2024-03-17 22:32:07 [INFO]: Model files will be saved to tutorial_results/imputation/transformer/20240317_T223207\n", - "2024-03-17 22:32:07 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/transformer/20240317_T223207/tensorboard\n", - "2024-03-17 22:32:07 [INFO]: Transformer initialized with the given hyperparameters, the number of trainable parameters: 7,938,597\n" + "2024-05-21 12:33:33 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 12:33:33 [INFO]: Model files will be saved to tutorial_results/imputation/transformer/20240521_T123333\n", + "2024-05-21 12:33:33 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/transformer/20240521_T123333/tensorboard\n", + "2024-05-21 12:33:33 [INFO]: Transformer initialized with the given hyperparameters, the number of trainable parameters: 7,938,597\n" ] } ], @@ -245,7 +245,7 @@ " n_features=physionet2012_dataset['n_features'],\n", " n_layers=6,\n", " d_model=512,\n", - " d_inner=256,\n", + " d_ffn=256,\n", " n_heads=4,\n", " d_k=128,\n", " d_v=128,\n", @@ -280,26 +280,25 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:32:14 [INFO]: Epoch 001 - training loss: 1.4377, validating loss: 1.0124\n", - "2024-03-17 22:32:22 [INFO]: Epoch 002 - training loss: 1.3912, validating loss: 0.9928\n", - "2024-03-17 22:32:29 [INFO]: Epoch 003 - training loss: 1.3825, validating loss: 0.9913\n", - "2024-03-17 22:32:37 [INFO]: Epoch 004 - training loss: 1.3709, validating loss: 0.9883\n", - "2024-03-17 22:32:44 [INFO]: Epoch 005 - training loss: 1.3676, validating loss: 0.9881\n", - "2024-03-17 22:32:52 [INFO]: Epoch 006 - training loss: 1.3662, validating loss: 0.9919\n", - "2024-03-17 22:33:00 [INFO]: Epoch 007 - training loss: 1.3650, validating loss: 0.9865\n", - "2024-03-17 22:33:07 [INFO]: Epoch 008 - training loss: 1.3643, validating loss: 0.9902\n", - "2024-03-17 22:33:15 [INFO]: Epoch 009 - training loss: 1.3643, validating loss: 0.9955\n", - "2024-03-17 22:33:22 [INFO]: Epoch 010 - training loss: 1.3632, validating loss: 0.9996\n", - "2024-03-17 22:33:22 [INFO]: Exceeded the training patience. Terminating the training procedure...\n", - "2024-03-17 22:33:22 [INFO]: Finished training.\n", - "2024-03-17 22:33:22 [INFO]: Saved the model to tutorial_results/imputation/transformer/20240317_T223207/Transformer.pypots\n" + "2024-05-21 12:33:41 [INFO]: Epoch 001 - training loss: 1.4364, validation loss: 1.0100\n", + "2024-05-21 12:33:48 [INFO]: Epoch 002 - training loss: 1.3903, validation loss: 0.9911\n", + "2024-05-21 12:33:55 [INFO]: Epoch 003 - training loss: 1.3806, validation loss: 0.9910\n", + "2024-05-21 12:34:03 [INFO]: Epoch 004 - training loss: 1.3697, validation loss: 0.9919\n", + "2024-05-21 12:34:10 [INFO]: Epoch 005 - training loss: 1.3679, validation loss: 0.9864\n", + "2024-05-21 12:34:18 [INFO]: Epoch 006 - training loss: 1.3655, validation loss: 0.9801\n", + "2024-05-21 12:34:25 [INFO]: Epoch 007 - training loss: 1.3645, validation loss: 0.9849\n", + "2024-05-21 12:34:32 [INFO]: Epoch 008 - training loss: 1.3643, validation loss: 0.9886\n", + "2024-05-21 12:34:40 [INFO]: Epoch 009 - training loss: 1.3642, validation loss: 0.9945\n", + "2024-05-21 12:34:40 [INFO]: Exceeded the training patience. Terminating the training procedure...\n", + "2024-05-21 12:34:40 [INFO]: Finished training. The best model is from epoch#6.\n", + "2024-05-21 12:34:40 [INFO]: Saved the model to tutorial_results/imputation/transformer/20240521_T123333/Transformer.pypots\n" ] } ], @@ -310,7 +309,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -321,7 +320,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": { "scrolled": true }, @@ -330,7 +329,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.6858\n" + "Testing mean absolute error: 0.6862\n" ] } ], @@ -355,17 +354,17 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:33:22 [INFO]: Using the given device: cuda\n", - "2024-03-17 22:33:22 [INFO]: Model files will be saved to tutorial_results/imputation/timesnet/20240317_T223322\n", - "2024-03-17 22:33:22 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/timesnet/20240317_T223322/tensorboard\n", - "2024-03-17 22:33:23 [INFO]: TimesNet initialized with the given hyperparameters, the number of trainable parameters: 21,649,317\n" + "2024-05-21 12:34:40 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 12:34:40 [INFO]: Model files will be saved to tutorial_results/imputation/timesnet/20240521_T123440\n", + "2024-05-21 12:34:40 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/timesnet/20240521_T123440/tensorboard\n", + "2024-05-21 12:34:41 [INFO]: TimesNet initialized with the given hyperparameters, the number of trainable parameters: 21,649,573\n" ] } ], @@ -399,7 +398,7 @@ " num_workers=0,\n", " # just leave it to default as None, PyPOTS will automatically assign the best device for you.\n", " # Set it as 'cpu' if you don't have CUDA devices. You can also set it to 'cuda:0' or 'cuda:1' if you have multiple CUDA devices, even parallelly on ['cuda:0', 'cuda:1']\n", - " device=None, \n", + " device=None,\n", " # set the path for saving tensorboard and trained model files \n", " saving_path=\"tutorial_results/imputation/timesnet\",\n", " # only save the best model after training finished.\n", @@ -410,25 +409,25 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:33:29 [INFO]: Epoch 001 - training loss: 0.4754, validating loss: 0.3634\n", - "2024-03-17 22:33:34 [INFO]: Epoch 002 - training loss: 0.4249, validating loss: 0.3489\n", - "2024-03-17 22:33:39 [INFO]: Epoch 003 - training loss: 0.4562, validating loss: 0.3402\n", - "2024-03-17 22:33:45 [INFO]: Epoch 004 - training loss: 0.4208, validating loss: 0.3371\n", - "2024-03-17 22:33:50 [INFO]: Epoch 005 - training loss: 0.4197, validating loss: 0.3344\n", - "2024-03-17 22:33:55 [INFO]: Epoch 006 - training loss: 0.4246, validating loss: 0.3308\n", - "2024-03-17 22:34:00 [INFO]: Epoch 007 - training loss: 0.4657, validating loss: 0.3287\n", - "2024-03-17 22:34:05 [INFO]: Epoch 008 - training loss: 0.3869, validating loss: 0.3204\n", - "2024-03-17 22:34:10 [INFO]: Epoch 009 - training loss: 0.3711, validating loss: 0.3170\n", - "2024-03-17 22:34:15 [INFO]: Epoch 010 - training loss: 0.3610, validating loss: 0.3175\n", - "2024-03-17 22:34:15 [INFO]: Finished training.\n", - "2024-03-17 22:34:15 [INFO]: Saved the model to tutorial_results/imputation/timesnet/20240317_T223322/TimesNet.pypots\n" + "2024-05-21 12:34:48 [INFO]: Epoch 001 - training loss: 0.4796, validation loss: 0.3719\n", + "2024-05-21 12:34:52 [INFO]: Epoch 002 - training loss: 0.4039, validation loss: 0.3458\n", + "2024-05-21 12:34:55 [INFO]: Epoch 003 - training loss: 0.4087, validation loss: 0.3382\n", + "2024-05-21 12:34:59 [INFO]: Epoch 004 - training loss: 0.4472, validation loss: 0.3351\n", + "2024-05-21 12:35:02 [INFO]: Epoch 005 - training loss: 0.4144, validation loss: 0.3300\n", + "2024-05-21 12:35:06 [INFO]: Epoch 006 - training loss: 0.4142, validation loss: 0.3274\n", + "2024-05-21 12:35:09 [INFO]: Epoch 007 - training loss: 0.4203, validation loss: 0.3257\n", + "2024-05-21 12:35:13 [INFO]: Epoch 008 - training loss: 0.4631, validation loss: 0.3249\n", + "2024-05-21 12:35:16 [INFO]: Epoch 009 - training loss: 0.3840, validation loss: 0.3172\n", + "2024-05-21 12:35:20 [INFO]: Epoch 010 - training loss: 0.3685, validation loss: 0.3151\n", + "2024-05-21 12:35:20 [INFO]: Finished training. The best model is from epoch#10.\n", + "2024-05-21 12:35:20 [INFO]: Saved the model to tutorial_results/imputation/timesnet/20240521_T123440/TimesNet.pypots\n" ] } ], @@ -439,7 +438,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -450,7 +449,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": { "scrolled": true }, @@ -459,7 +458,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.3291\n" + "Testing mean absolute error: 0.3243\n" ] } ], @@ -484,19 +483,19 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:34:15 [INFO]: Using the given device: cuda:1\n", - "2024-03-17 22:34:15 [INFO]: Model files will be saved to tutorial_results/imputation/csdi/20240317_T223415\n", - "2024-03-17 22:34:15 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/csdi/20240317_T223415/tensorboard\n", - "/home/wdudu/.conda/envs/ml/lib/python3.10/site-packages/torch/nn/modules/transformer.py:286: UserWarning: enable_nested_tensor is True, but self.use_nested_tensor is False because encoder_layer.self_attn.batch_first was not True(use batch_first for better inference performance)\n", + "2024-05-21 12:35:21 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 12:35:21 [INFO]: Model files will be saved to tutorial_results/imputation/csdi/20240521_T123521\n", + "2024-05-21 12:35:21 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/csdi/20240521_T123521/tensorboard\n", + "/home/linglong/data/linglong/.conda/envs/pypots-dev/lib/python3.11/site-packages/torch/nn/modules/transformer.py:286: UserWarning: enable_nested_tensor is True, but self.use_nested_tensor is False because encoder_layer.self_attn.batch_first was not True(use batch_first for better inference performance)\n", " warnings.warn(f\"enable_nested_tensor is True, but self.use_nested_tensor is False because {why_not_sparsity_fast_path}\")\n", - "2024-03-17 22:34:15 [INFO]: CSDI initialized with the given hyperparameters, the number of trainable parameters: 1,694,753\n" + "2024-05-21 12:35:21 [INFO]: CSDI initialized with the given hyperparameters, the number of trainable parameters: 1,694,753\n" ] } ], @@ -506,6 +505,7 @@ "\n", "# initialize the model\n", "csdi = CSDI(\n", + " n_steps=physionet2012_dataset['n_steps'],\n", " n_features=physionet2012_dataset['n_features'],\n", " n_layers=6,\n", " n_heads=2,\n", @@ -530,7 +530,7 @@ " num_workers=0,\n", " # just leave it to default as None, PyPOTS will automatically assign the best device for you.\n", " # Set it as 'cpu' if you don't have CUDA devices. You can also set it to 'cuda:0' or 'cuda:1' if you have multiple CUDA devices, even parallelly on ['cuda:0', 'cuda:1']\n", - " device='cuda:1',\n", + " device=None,\n", " # set the path for saving tensorboard and trained model files \n", " saving_path=\"tutorial_results/imputation/csdi\",\n", " # only save the best model after training finished.\n", @@ -541,25 +541,25 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:36:03 [INFO]: Epoch 001 - training loss: 0.3336, validating loss: 0.2451\n", - "2024-03-17 22:37:50 [INFO]: Epoch 002 - training loss: 0.2654, validating loss: 0.2087\n", - "2024-03-17 22:39:37 [INFO]: Epoch 003 - training loss: 0.2497, validating loss: 0.2071\n", - "2024-03-17 22:41:23 [INFO]: Epoch 004 - training loss: 0.2442, validating loss: 0.1966\n", - "2024-03-17 22:43:09 [INFO]: Epoch 005 - training loss: 0.2317, validating loss: 0.1922\n", - "2024-03-17 22:44:55 [INFO]: Epoch 006 - training loss: 0.2231, validating loss: 0.1884\n", - "2024-03-17 22:46:41 [INFO]: Epoch 007 - training loss: 0.2322, validating loss: 0.1922\n", - "2024-03-17 22:48:29 [INFO]: Epoch 008 - training loss: 0.2357, validating loss: 0.1889\n", - "2024-03-17 22:50:15 [INFO]: Epoch 009 - training loss: 0.2298, validating loss: 0.1825\n", - "2024-03-17 22:52:05 [INFO]: Epoch 010 - training loss: 0.2251, validating loss: 0.1968\n", - "2024-03-17 22:52:05 [INFO]: Finished training.\n", - "2024-03-17 22:52:05 [INFO]: Saved the model to tutorial_results/imputation/csdi/20240317_T223415/CSDI.pypots\n" + "2024-05-21 12:37:43 [INFO]: Epoch 001 - training loss: 0.3379, validation loss: 0.2506\n", + "2024-05-21 12:40:08 [INFO]: Epoch 002 - training loss: 0.2575, validation loss: 0.2083\n", + "2024-05-21 12:42:31 [INFO]: Epoch 003 - training loss: 0.2406, validation loss: 0.1998\n", + "2024-05-21 12:44:56 [INFO]: Epoch 004 - training loss: 0.2389, validation loss: 0.1978\n", + "2024-05-21 12:47:20 [INFO]: Epoch 005 - training loss: 0.2343, validation loss: 0.1984\n", + "2024-05-21 12:49:44 [INFO]: Epoch 006 - training loss: 0.2272, validation loss: 0.1907\n", + "2024-05-21 12:52:07 [INFO]: Epoch 007 - training loss: 0.2298, validation loss: 0.1924\n", + "2024-05-21 12:54:32 [INFO]: Epoch 008 - training loss: 0.2208, validation loss: 0.1882\n", + "2024-05-21 12:56:56 [INFO]: Epoch 009 - training loss: 0.2267, validation loss: 0.1827\n", + "2024-05-21 12:59:20 [INFO]: Epoch 010 - training loss: 0.2188, validation loss: 0.1845\n", + "2024-05-21 12:59:20 [INFO]: Finished training. The best model is from epoch#9.\n", + "2024-05-21 12:59:20 [INFO]: Saved the model to tutorial_results/imputation/csdi/20240521_T123521/CSDI.pypots\n" ] } ], @@ -605,7 +605,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.2976\n" + "Testing mean absolute error: 0.2781\n" ] } ], @@ -639,10 +639,10 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 22:59:38 [INFO]: Using the given device: cuda\n", - "2024-03-17 22:59:38 [INFO]: Model files will be saved to tutorial_results/imputation/us_gan/20240317_T225938\n", - "2024-03-17 22:59:38 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/us_gan/20240317_T225938/tensorboard\n", - "2024-03-17 22:59:38 [INFO]: USGAN initialized with the given hyperparameters, the number of trainable parameters: 1,258,517\n" + "2024-05-21 13:04:08 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 13:04:08 [INFO]: Model files will be saved to tutorial_results/imputation/us_gan/20240521_T130408\n", + "2024-05-21 13:04:08 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/us_gan/20240521_T130408/tensorboard\n", + "2024-05-21 13:04:08 [INFO]: USGAN initialized with the given hyperparameters, the number of trainable parameters: 1,258,517\n" ] } ], @@ -693,19 +693,18 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:02:11 [INFO]: Epoch 001 - generator training loss: 4.0480, discriminator training loss: 0.1877, validating loss: 0.3738\n", - "2024-03-17 23:05:01 [INFO]: Epoch 002 - generator training loss: 4.8115, discriminator training loss: 0.1211, validating loss: 0.3330\n", - "2024-03-17 23:07:45 [INFO]: Epoch 003 - generator training loss: 5.2930, discriminator training loss: 0.0932, validating loss: 0.3181\n", - "2024-03-17 23:10:28 [INFO]: Epoch 004 - generator training loss: 5.6615, discriminator training loss: 0.0778, validating loss: 0.3131\n", - "2024-03-17 23:12:48 [INFO]: Epoch 005 - generator training loss: 5.9637, discriminator training loss: 0.0678, validating loss: 0.3101\n", - "2024-03-17 23:14:55 [INFO]: Epoch 006 - generator training loss: 6.2180, discriminator training loss: 0.0607, validating loss: 0.3069\n", - "2024-03-17 23:17:00 [INFO]: Epoch 007 - generator training loss: 6.4427, discriminator training loss: 0.0554, validating loss: 0.3068\n", - "2024-03-17 23:19:03 [INFO]: Epoch 008 - generator training loss: 6.6421, discriminator training loss: 0.0511, validating loss: 0.3078\n", - "2024-03-17 23:21:07 [INFO]: Epoch 009 - generator training loss: 6.8218, discriminator training loss: 0.0476, validating loss: 0.3112\n", - "2024-03-17 23:22:50 [INFO]: Epoch 010 - generator training loss: 6.9874, discriminator training loss: 0.0447, validating loss: 0.3103\n", - "2024-03-17 23:22:50 [INFO]: Exceeded the training patience. Terminating the training procedure...\n", - "2024-03-17 23:22:50 [INFO]: Finished training.\n", - "2024-03-17 23:22:50 [INFO]: Saved the model to tutorial_results/imputation/us_gan/20240317_T225938/USGAN.pypots\n" + "2024-05-21 13:06:21 [INFO]: Epoch 001 - generator training loss: 0.4250, discriminator training loss: 0.1838, validation loss: 0.3584\n", + "2024-05-21 13:08:16 [INFO]: Epoch 002 - generator training loss: 0.3517, discriminator training loss: 0.0526, validation loss: 0.3129\n", + "2024-05-21 13:10:10 [INFO]: Epoch 003 - generator training loss: 0.3263, discriminator training loss: 0.0367, validation loss: 0.2942\n", + "2024-05-21 13:12:00 [INFO]: Epoch 004 - generator training loss: 0.3103, discriminator training loss: 0.0310, validation loss: 0.2862\n", + "2024-05-21 13:13:53 [INFO]: Epoch 005 - generator training loss: 0.3010, discriminator training loss: 0.0281, validation loss: 0.2839\n", + "2024-05-21 13:15:47 [INFO]: Epoch 006 - generator training loss: 0.2950, discriminator training loss: 0.0281, validation loss: 0.2732\n", + "2024-05-21 13:17:40 [INFO]: Epoch 007 - generator training loss: 0.2836, discriminator training loss: 0.0258, validation loss: 0.2791\n", + "2024-05-21 13:19:37 [INFO]: Epoch 008 - generator training loss: 0.2760, discriminator training loss: 0.0243, validation loss: 0.2653\n", + "2024-05-21 13:21:33 [INFO]: Epoch 009 - generator training loss: 0.2683, discriminator training loss: 0.0233, validation loss: 0.2699\n", + "2024-05-21 13:23:29 [INFO]: Epoch 010 - generator training loss: 0.2678, discriminator training loss: 0.0227, validation loss: 0.2701\n", + "2024-05-21 13:23:29 [INFO]: Finished training. The best model is from epoch#8.\n", + "2024-05-21 13:23:29 [INFO]: Saved the model to tutorial_results/imputation/us_gan/20240521_T130408/USGAN.pypots\n" ] } ], @@ -734,7 +733,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.2526\n" + "Testing mean absolute error: 0.2805\n" ] } ], @@ -768,10 +767,10 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:23:01 [INFO]: Using the given device: cuda\n", - "2024-03-17 23:23:01 [INFO]: Model files will be saved to tutorial_results/imputation/gp_vae/20240317_T232301\n", - "2024-03-17 23:23:01 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/gp_vae/20240317_T232301/tensorboard\n", - "2024-03-17 23:23:01 [INFO]: GPVAE initialized with the given hyperparameters, the number of trainable parameters: 229,652\n" + "2024-05-21 13:23:43 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 13:23:43 [INFO]: Model files will be saved to tutorial_results/imputation/gp_vae/20240521_T132343\n", + "2024-05-21 13:23:43 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/gp_vae/20240521_T132343/tensorboard\n", + "2024-05-21 13:23:43 [INFO]: GPVAE initialized with the given hyperparameters, the number of trainable parameters: 229,652\n" ] } ], @@ -809,7 +808,7 @@ " num_workers=0,\n", " # just leave it to default as None, PyPOTS will automatically assign the best device for you.\n", " # Set it as 'cpu' if you don't have CUDA devices. You can also set it to 'cuda:0' or 'cuda:1' if you have multiple CUDA devices, even parallelly on ['cuda:0', 'cuda:1']\n", - " device=None, \n", + " device=None,\n", " # set the path for saving tensorboard and trained model files \n", " saving_path=\"tutorial_results/imputation/gp_vae\",\n", " # only save the best model after training finished.\n", @@ -827,18 +826,18 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:23:10 [INFO]: Epoch 001 - training loss: 25965.8314, validating loss: 0.6320\n", - "2024-03-17 23:23:19 [INFO]: Epoch 002 - training loss: 22875.1126, validating loss: 0.5981\n", - "2024-03-17 23:23:27 [INFO]: Epoch 003 - training loss: 22840.8942, validating loss: 0.5821\n", - "2024-03-17 23:23:36 [INFO]: Epoch 004 - training loss: 22833.0289, validating loss: 0.5662\n", - "2024-03-17 23:23:44 [INFO]: Epoch 005 - training loss: 22829.6722, validating loss: 0.5608\n", - "2024-03-17 23:23:52 [INFO]: Epoch 006 - training loss: 22818.5064, validating loss: 0.5363\n", - "2024-03-17 23:24:00 [INFO]: Epoch 007 - training loss: 22818.0259, validating loss: 0.5461\n", - "2024-03-17 23:24:08 [INFO]: Epoch 008 - training loss: 22822.0127, validating loss: 0.5420\n", - "2024-03-17 23:24:15 [INFO]: Epoch 009 - training loss: 22811.4080, validating loss: 0.5116\n", - "2024-03-17 23:24:23 [INFO]: Epoch 010 - training loss: 22806.8758, validating loss: 0.5019\n", - "2024-03-17 23:24:23 [INFO]: Finished training.\n", - "2024-03-17 23:24:23 [INFO]: Saved the model to tutorial_results/imputation/gp_vae/20240317_T232301/GPVAE.pypots\n" + "2024-05-21 13:23:47 [INFO]: Epoch 001 - training loss: 26022.2357, validation loss: 0.6172\n", + "2024-05-21 13:23:51 [INFO]: Epoch 002 - training loss: 22874.5681, validation loss: 0.5858\n", + "2024-05-21 13:23:55 [INFO]: Epoch 003 - training loss: 22840.0816, validation loss: 0.5715\n", + "2024-05-21 13:23:59 [INFO]: Epoch 004 - training loss: 22828.3269, validation loss: 0.5638\n", + "2024-05-21 13:24:03 [INFO]: Epoch 005 - training loss: 22821.9063, validation loss: 0.5509\n", + "2024-05-21 13:24:06 [INFO]: Epoch 006 - training loss: 22817.8396, validation loss: 0.5411\n", + "2024-05-21 13:24:10 [INFO]: Epoch 007 - training loss: 22816.0375, validation loss: 0.5412\n", + "2024-05-21 13:24:15 [INFO]: Epoch 008 - training loss: 22813.3457, validation loss: 0.5447\n", + "2024-05-21 13:24:19 [INFO]: Epoch 009 - training loss: 22812.1050, validation loss: 0.5212\n", + "2024-05-21 13:24:23 [INFO]: Epoch 010 - training loss: 22809.5779, validation loss: 0.5380\n", + "2024-05-21 13:24:23 [INFO]: Finished training. The best model is from epoch#9.\n", + "2024-05-21 13:24:23 [INFO]: Saved the model to tutorial_results/imputation/gp_vae/20240521_T132343/GPVAE.pypots\n" ] } ], @@ -882,7 +881,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.4546\n" + "Testing mean absolute error: 0.4822\n" ] } ], @@ -914,10 +913,10 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:24:24 [INFO]: Using the given device: cuda\n", - "2024-03-17 23:24:24 [INFO]: Model files will be saved to tutorial_results/imputation/brits/20240317_T232424\n", - "2024-03-17 23:24:24 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/brits/20240317_T232424/tensorboard\n", - "2024-03-17 23:24:24 [INFO]: BRITS initialized with the given hyperparameters, the number of trainable parameters: 239,344\n" + "2024-05-21 13:24:24 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 13:24:24 [INFO]: Model files will be saved to tutorial_results/imputation/brits/20240521_T132424\n", + "2024-05-21 13:24:24 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/brits/20240521_T132424/tensorboard\n", + "2024-05-21 13:24:24 [INFO]: BRITS initialized with the given hyperparameters, the number of trainable parameters: 239,344\n" ] } ], @@ -963,18 +962,19 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:25:39 [INFO]: Epoch 001 - training loss: 0.9376, validating loss: 0.3887\n", - "2024-03-17 23:26:47 [INFO]: Epoch 002 - training loss: 0.7274, validating loss: 0.3412\n", - "2024-03-17 23:28:08 [INFO]: Epoch 003 - training loss: 0.6775, validating loss: 0.3270\n", - "2024-03-17 23:29:30 [INFO]: Epoch 004 - training loss: 0.6541, validating loss: 0.3195\n", - "2024-03-17 23:30:51 [INFO]: Epoch 005 - training loss: 0.6397, validating loss: 0.3167\n", - "2024-03-17 23:32:12 [INFO]: Epoch 006 - training loss: 0.6287, validating loss: 0.3151\n", - "2024-03-17 23:33:33 [INFO]: Epoch 007 - training loss: 0.6197, validating loss: 0.3157\n", - "2024-03-17 23:34:56 [INFO]: Epoch 008 - training loss: 0.6122, validating loss: 0.3143\n", - "2024-03-17 23:36:18 [INFO]: Epoch 009 - training loss: 0.6060, validating loss: 0.3165\n", - "2024-03-17 23:37:41 [INFO]: Epoch 010 - training loss: 0.6007, validating loss: 0.3184\n", - "2024-03-17 23:37:41 [INFO]: Finished training.\n", - "2024-03-17 23:37:41 [INFO]: Saved the model to tutorial_results/imputation/brits/20240317_T232424/BRITS.pypots\n" + "2024-05-21 13:26:06 [INFO]: Epoch 001 - training loss: 0.9522, validation loss: 0.3980\n", + "2024-05-21 13:27:26 [INFO]: Epoch 002 - training loss: 0.7375, validation loss: 0.3423\n", + "2024-05-21 13:28:49 [INFO]: Epoch 003 - training loss: 0.6834, validation loss: 0.3278\n", + "2024-05-21 13:30:15 [INFO]: Epoch 004 - training loss: 0.6578, validation loss: 0.3228\n", + "2024-05-21 13:31:40 [INFO]: Epoch 005 - training loss: 0.6421, validation loss: 0.3166\n", + "2024-05-21 13:33:01 [INFO]: Epoch 006 - training loss: 0.6305, validation loss: 0.3149\n", + "2024-05-21 13:34:25 [INFO]: Epoch 007 - training loss: 0.6216, validation loss: 0.3136\n", + "2024-05-21 13:35:48 [INFO]: Epoch 008 - training loss: 0.6142, validation loss: 0.3158\n", + "2024-05-21 13:37:11 [INFO]: Epoch 009 - training loss: 0.6074, validation loss: 0.3169\n", + "2024-05-21 13:38:31 [INFO]: Epoch 010 - training loss: 0.6020, validation loss: 0.3166\n", + "2024-05-21 13:38:31 [INFO]: Exceeded the training patience. Terminating the training procedure...\n", + "2024-05-21 13:38:31 [INFO]: Finished training. The best model is from epoch#7.\n", + "2024-05-21 13:38:31 [INFO]: Saved the model to tutorial_results/imputation/brits/20240521_T132424/BRITS.pypots\n" ] } ], @@ -1003,7 +1003,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.2580\n" + "Testing mean absolute error: 0.2583\n" ] } ], @@ -1028,7 +1028,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 33, "metadata": { "collapsed": false }, @@ -1037,17 +1037,17 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:37:57 [INFO]: No given device, using default device: cuda\n", - "2024-03-17 23:37:57 [INFO]: Model files will be saved to tutorial_results/imputation/mrnn/20240317_T233757\n", - "2024-03-17 23:37:57 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/mrnn/20240317_T233757/tensorboard\n", - "2024-03-17 23:37:57 [INFO]: MRNN initialized with the given hyperparameters, the number of trainable parameters: 107,951\n" + "2024-05-21 14:09:50 [INFO]: Using the given device: cuda:0\n", + "2024-05-21 14:09:50 [INFO]: Model files will be saved to tutorial_results/imputation/mrnn/20240521_T140950\n", + "2024-05-21 14:09:50 [INFO]: Tensorboard file will be saved to tutorial_results/imputation/mrnn/20240521_T140950/tensorboard\n", + "2024-05-21 14:09:50 [INFO]: MRNN initialized with the given hyperparameters, the number of trainable parameters: 107,951\n" ] } ], "source": [ "from pypots.optim import Adam\n", "from pypots.imputation import MRNN\n", - "from pypots.utils.metrics import cal_mae\n", + "from pypots.utils.metrics import calc_mae\n", "\n", "# initialize the model\n", "# initialize the model\n", @@ -1081,7 +1081,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "metadata": { "collapsed": false }, @@ -1090,17 +1090,18 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:38:30 [INFO]: Epoch 001 - training loss: 0.7285, validating loss: 0.9317\n", - "2024-03-17 23:38:48 [INFO]: Epoch 002 - training loss: 0.5254, validating loss: 0.8918\n", - "2024-03-17 23:39:04 [INFO]: Epoch 003 - training loss: 0.4947, validating loss: 0.8756\n", - "2024-03-17 23:39:25 [INFO]: Epoch 004 - training loss: 0.4621, validating loss: 0.8681\n", - "2024-03-17 23:39:43 [INFO]: Epoch 005 - training loss: 0.4602, validating loss: 0.8628\n", - "2024-03-17 23:40:04 [INFO]: Epoch 006 - training loss: 0.4483, validating loss: 0.8644\n", - "2024-03-17 23:40:23 [INFO]: Epoch 007 - training loss: 0.4413, validating loss: 0.8632\n", - "2024-03-17 23:40:43 [INFO]: Epoch 008 - training loss: 0.4290, validating loss: 0.8687\n", - "2024-03-17 23:40:43 [INFO]: Exceeded the training patience. Terminating the training procedure...\n", - "2024-03-17 23:40:43 [INFO]: Finished training.\n", - "2024-03-17 23:40:43 [INFO]: Saved the model to tutorial_results/imputation/mrnn/20240317_T233757/MRNN.pypots\n" + "2024-05-21 14:10:33 [INFO]: Epoch 001 - training loss: 0.7347, validation loss: 0.9286\n", + "2024-05-21 14:10:57 [INFO]: Epoch 002 - training loss: 0.5278, validation loss: 0.8844\n", + "2024-05-21 14:11:18 [INFO]: Epoch 003 - training loss: 0.4864, validation loss: 0.8717\n", + "2024-05-21 14:11:42 [INFO]: Epoch 004 - training loss: 0.4697, validation loss: 0.8623\n", + "2024-05-21 14:12:12 [INFO]: Epoch 005 - training loss: 0.4615, validation loss: 0.8596\n", + "2024-05-21 14:12:41 [INFO]: Epoch 006 - training loss: 0.4405, validation loss: 0.8583\n", + "2024-05-21 14:13:01 [INFO]: Epoch 007 - training loss: 0.4361, validation loss: 0.8600\n", + "2024-05-21 14:13:23 [INFO]: Epoch 008 - training loss: 0.4315, validation loss: 0.8633\n", + "2024-05-21 14:13:45 [INFO]: Epoch 009 - training loss: 0.4296, validation loss: 0.8660\n", + "2024-05-21 14:13:45 [INFO]: Exceeded the training patience. Terminating the training procedure...\n", + "2024-05-21 14:13:45 [INFO]: Finished training. The best model is from epoch#6.\n", + "2024-05-21 14:13:45 [INFO]: Saved the model to tutorial_results/imputation/mrnn/20240521_T140950/MRNN.pypots\n" ] } ], @@ -1111,7 +1112,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "metadata": { "collapsed": false }, @@ -1124,7 +1125,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 36, "metadata": { "collapsed": false }, @@ -1133,7 +1134,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Testing mean absolute error: 0.6825\n" + "Testing mean absolute error: 0.6776\n" ] } ], @@ -1158,14 +1159,14 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-17 23:40:47 [INFO]: No given device, using default device: cuda\n" + "2024-05-21 14:13:51 [INFO]: No given device, using default device: cuda\n" ] } ], @@ -1178,14 +1179,14 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/home/wdudu/.conda/envs/ml/lib/python3.10/site-packages/pypots/imputation/locf/model.py:67: UserWarning: LOCF (Last Observed Carried Forward) imputation class has no parameter to train. Please run func `predict()` directly.\n", + "/home/linglong/data/linglong/.conda/envs/pypots-dev/lib/python3.11/site-packages/pypots/imputation/locf/model.py:67: UserWarning: LOCF (Last Observed Carried Forward) imputation class has no parameter to train. Please run func `predict()` directly.\n", " warnings.warn(\n" ] } @@ -1198,7 +1199,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ @@ -1209,7 +1210,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 40, "metadata": {}, "outputs": [ { @@ -1231,6 +1232,41 @@ ")\n", "print(f\"Testing mean absolute error: {testing_mae:.4f}\")\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -1249,7 +1285,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4,