Skip to content

Commit

Permalink
Minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanhoy committed Sep 25, 2023
1 parent 2f801c5 commit e72fe9c
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions docs/00_dataset_tutorials/00_Sig53DatasetTutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"#### Generating\n",
"A Sig53-like dataset can be generated from scratch, on-the-fly, yielding a dataset with essentially inifinite number of unique exemplars (called samples in machine-learning circles) per class. The downside to generating things on-the-fly is that **training is slower.** \n",
"\n",
"Before we jump into generating the whole dataset, let's start with a basic example which uses the ```ModulationsDataset```, which is the underlying class used to generate ```Sig53Dataset```. The class has a number of parameters"
"Before we jump into generating the whole dataset, let's start with a basic example which uses the ```ModulationsDataset```, which is the underlying class used to generate ```Sig53``` Dataset. The class has a number of parameters"
]
},
{
Expand Down Expand Up @@ -152,7 +152,7 @@
"metadata": {},
"source": [
"#### Iterating Over the Dataset\n",
"Now the Sig53 dataset is a specific configuration of the ```ModulationsDataset``` class. To keep the configuration fixed, we implement classes with fixed parameters of type ```Sig53Conf```. We use the ```Sig53CleanTrianQAConfig```. In this configuration, the dataset ```label``` is actually a Python ```tuple``` which includes the estimated SNR of the produced sample. \n",
"Now the Sig53 dataset is a specific configuration of the ```ModulationsDataset``` class. To keep the configuration fixed, we implement classes with fixed parameters of type ```Sig53Conf```. We use the ```Sig53CleanTrainQAConfig```. In this configuration, the dataset ```label``` is actually a Python ```tuple``` which includes the estimated SNR of the produced sample. \n",
"\n",
"Using this example, you can choose one of the fixed configurations and generate a Sig53-like dataset on-the-fly as you iterate over it, and train an ML model, store it, or perform some analysis on it!"
]
Expand Down Expand Up @@ -180,8 +180,6 @@
")\n",
"\n",
"data, (modulation, snr) = ds[0]\n",
"print(data)\n",
"print(modulation, snr)\n",
"\n",
"# Plot it.\n",
"plt.subplot(3, 1, 1)\n",
Expand Down Expand Up @@ -253,7 +251,7 @@
"\n",
"# You can iterate through this in a similar way.\n",
"# The DataLoader produces a torch.Tensor\n",
"loader = DataLoader(ds, batch_size=16, num_workers=16)\n",
"loader = DataLoader(ds, batch_size=os.cpu_count() // 2, num_workers=os.cpu_count() // 2)\n",
"\n",
"if os.path.exists(\"data.fc32\"):\n",
" os.remove(\"data.fc32\")\n",
Expand All @@ -277,7 +275,7 @@
"metadata": {},
"source": [
"#### Reading a Static Dataset\n",
"We've chosen to write our data as raw binary. We can write a Dataset class that allows us to iterate over that stored data. A Dataset class only needs to implement ```__init__``` and ```__getitem__```. We talk more about creating a custom dataset in a different tutorial."
"We've chosen to write our data as raw binary. We can write a Dataset class that allows us to iterate over that stored data. A Dataset class only needs to implement ```__init__```, ```__getitem__```, and ```__len__```. We talk more about creating a custom dataset in a different tutorial."
]
},
{
Expand All @@ -304,6 +302,10 @@
" self.label_file = os.path.join(path, \"label.int8\")\n",
"\n",
" super().__init__(transform, target_transform, seed)\n",
" \n",
" def __len__(self) -> int:\n",
" # Each sample is 8 * 4096 * 2 bytes large.\n",
" return os.path.getsize(self.data_file) // 8 // 4092 // 2\n",
"\n",
" def __getitem__(self, index: int) -> Tuple:\n",
" # the sample at index is 8192 double-precision floating-point numbers long.\n",
Expand Down Expand Up @@ -448,7 +450,7 @@
"\n",
"# Plot it.\n",
"plt.subplot(3, 1, 1)\n",
"plt.title(\"Modulation Type = {}\".format(ModulationsDataset.default_classes[int(label)]))\n",
"plt.title(\"Modulation Type = {}\".format(ModulationsDataset.default_classes[int(mod)]))\n",
"plt.ylabel(\"Time Domain\")\n",
"plt.plot(data[:100].real, marker=\".\")\n",
"plt.plot(data[:100].imag, marker=\".\")\n",
Expand All @@ -475,14 +477,6 @@
"ax.set_xticks([])\n",
"ax.set_yticks([])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1fca0286",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit e72fe9c

Please sign in to comment.