Skip to content

Commit

Permalink
add colab versions of tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderVNikitin committed Jun 15, 2024
1 parent 3b09e33 commit ae58487
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ result = gan.generate(100)

## :anchor: Tutorials

- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1l2VB6eUwvrxyu8iB30faGiQM5AKthc82?usp=sharing) Introductory Tutorial "[Getting started with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/GANs/cGAN.ipynb)"
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1Vw9t4TlI1Nek_t6bMPyKcPPPqCiXfOK3?usp=sharing) Tutorial on using [Time Series Augmentations](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/augmentations.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hubtddSX94KyLzuCTwmU6pAFBgBeiEB-?usp=sharing) Tutorial on [Evaluation of Synthetic Time Series Data](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/evaluation.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1wpf9WeNVj5TkUcPF6EavVx-hUCOfyvUd?usp=sharing) Tutorial on using [Multiple GPUs or TPU with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/Using%20Multiple%20GPUs%20or%20TPU.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1l2VB6eUwvrxyu8iB30faGiQM5AKthc82?usp=sharing) Introductory Tutorial [Getting started with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/GANs/cGAN.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1frSnJQSsuPS3asgIkmcrNtX4Y7TIQI56?usp=sharing) Tutorial [Datasets in TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/Datasets.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1Vw9t4TlI1Nek_t6bMPyKcPPPqCiXfOK3?usp=sharing) Tutorial [Time Series Augmentations](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/augmentations.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1_jpGrPcwoSpB8eii8XW-spaikczdPqIQ?usp=sharing) Tutorial [Time Series Generation with VAEs](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/VAEs/VAE.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1rcN3pr8uglBEEOo4bTa1fvXgSMx1vKq9?usp=sharing) Tutorial [Conditional Time Series Generation with GANs](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/GANs/cGAN.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hubtddSX94KyLzuCTwmU6pAFBgBeiEB-?usp=sharing) Tutorial [Evaluation of Synthetic Time Series Data](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/evaluation.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1SKD9hRi-ic27Wts9Qzkssjfe1z7o1NU4?usp=sharing) Tutorial [Model Selection](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/Model%20Selection.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1wpf9WeNVj5TkUcPF6EavVx-hUCOfyvUd?usp=sharing) Tutorial [Multiple GPUs or TPU with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/Using%20Multiple%20GPUs%20or%20TPU.ipynb)

For more examples, see [our tutorials](./tutorials).

Expand Down
37 changes: 19 additions & 18 deletions tutorials/GANs/cGAN.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "fd5a3eaf",
"metadata": {},
"source": [
"# Conditional Time Series Generation with GANs\n",
"This tutorial covers the generation of a temporal dataset where each time series has a class label assigned."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -12,16 +21,8 @@
"\n",
"import numpy as np\n",
"\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10e3e196",
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"from tensorflow import keras\n",
"from tensorflow.keras import layers\n",
"\n",
Expand All @@ -35,12 +36,12 @@
"id": "843de5f0",
"metadata": {},
"source": [
"We want to generate a temporal dataset where each time series belongs to one of two classes. Let's go step by step through the solution.\n",
"We aim to generate a temporal dataset where each time series belongs to one of two classes. Let's go through the solution step by step.\n",
"\n",
"#### 1. Define parameters of GAN:\n",
"First, we are defining the parameters of GAN, and the training algorithm.\n",
"- `latent_dim` is the size of input noise in GAN,\n",
"- `output_dim` is the number of classes, which, mentioned above is two,\n",
"First, we need to define the parameters for the Generative Adversarial Network (GAN) and its training algorithm:\n",
"- `latent_dim` is the size of the input noise in GAN,\n",
"- `output_dim` is the number of output classes, which in this case is two.,\n",
"- `feature_dim` is the number of time series features,\n",
"- `seq_len` is the length of the time series."
]
Expand Down Expand Up @@ -69,7 +70,7 @@
"metadata": {},
"source": [
"#### 2. Load data:\n",
"We are working with a toy dataset, and use `tsgm` utility called `tsgm.utils.gen_sine_vs_const_dataset` to generate the data. Next, we featurewise scale the dataset so that each feature is in $[-1, 1]$, using `tsgm.utils.TSFeatureWiseScaler`."
"We will generate a toy dataset, and use `tsgm` utility called `tsgm.utils.gen_sine_vs_const_dataset` to generate the data. After generating the data, we will scale each feature to be within the range of $[-1, 1]$, using `tsgm.utils.TSFeatureWiseScaler`."
]
},
{
Expand Down Expand Up @@ -98,7 +99,7 @@
"metadata": {},
"source": [
"#### 3. Visually explore the dataset.\n",
"There are many tools for convenient visualizations of temporal datasets. Here, we use `tsgm.utils.visualize_ts_lineplot`, which is convenient for TS classification datasets."
"There are many tools for convenient visualizations of temporal datasets in `tsgm,utils`. Here, we use `tsgm.utils.visualize_ts_lineplot`, which is convenient for TS classification datasets."
]
},
{
Expand All @@ -119,7 +120,7 @@
"metadata": {},
"source": [
"#### 4. Choose architecture.\n",
"Here, you can either use one of the architectures presented in `tsgm.models.architectures`, or define custom discriminator and generator architectures as `tf` models."
"Here, one can either use one of the architectures presented in `tsgm.models.architectures`, or define custom discriminator and generator architectures as `keras` models."
]
},
{
Expand All @@ -141,7 +142,7 @@
"metadata": {},
"source": [
"#### 5. Define model and train it.\n",
"We define conditional GAN model (`tsgm.models.cgan.ConditionalGAN`), compile it (here, you can choose different optimizers for discriminator and generator), and train using `.fit` model. Additionally, we use `tsgm.models.monitors.GANMonitor` to track training process."
"We define a conditional GAN model (`tsgm.models.cgan.ConditionalGAN`), compile it (here, one can choose different optimizers for discriminator and generator), and train using `.fit` model. Additionally, we employ `tsgm.models.monitors.GANMonitor` to monitor and track the training process, ensuring we can observe the model's progress and performance."
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions tutorials/VAEs/VAE.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "60611bed",
"metadata": {},
"source": [
"## Time series generation using VAEs.\n",
"# Time series generation using VAEs\n",
"This is a minimal example of unsupervised time series generation using VAEs."
]
},
Expand Down Expand Up @@ -36,7 +36,7 @@
"metadata": {},
"source": [
"#### 1. Choose architecture of encoder and decoder.\n",
"Here, you can either use one of the architectures presented in `tsgm.models.architectures`, or define custom discriminator and generator architectures as `tf` models."
"Here, you can either use one of the architectures presented in `tsgm.models.architectures`, or define custom discriminator and generator architectures as `keras` models."
]
},
{
Expand All @@ -56,7 +56,7 @@
"metadata": {},
"source": [
"#### 2. Load data:\n",
"We are working with a toy dataset, and use `tsgm` utility called `tsgm.utils.gen_sine_dataset` to generate the data. Next, we featurewise scale the dataset so that each feature is in $[0, 1]$, using `tsgm.utils.TSFeatureWiseScaler`."
"We are working with a toy dataset, and use `tsgm` utility called `tsgm.utils.gen_sine_dataset` to generate the data. Next, we feature-wise scale the dataset so that each feature is in $[0, 1]$, using `tsgm.utils.TSFeatureWiseScaler`."
]
},
{
Expand All @@ -77,7 +77,7 @@
"metadata": {},
"source": [
"#### 3. Define model and train it.\n",
"We define conditional GAN model (`tsgm.models.cvae.BetaVAE`), compile it, and train using `.fit` model. Additionally, we use `tsgm.models.monitors.GANMonitor` to track training process."
"We define a conditional GAN model (`tsgm.models.cvae.BetaVAE`), compile it, and train using `.fit` model."
]
},
{
Expand All @@ -99,7 +99,7 @@
"metadata": {},
"source": [
"#### 4. Check reconstruction of the data.\n",
"We reconstruct data using `vae.predict(scaled_data)`. For validating that VAE works, we check that original and reconstructed datasets are visually similar using `tsgm.utils.visualize_original_and_reconst_ts`."
"We reconstruct data using `vae.predict(scaled_data)`. For validating that VAE works, we check that the original and reconstructed datasets are visually similar using `tsgm.utils.visualize_original_and_reconst_ts`."
]
},
{
Expand Down

0 comments on commit ae58487

Please sign in to comment.