Skip to content

Commit

Permalink
More clearer data generation variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchieng committed Nov 6, 2018
1 parent 31ddcc3 commit 77d61db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions 02-space_stretching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "pytorch_latest",
"language": "python",
"name": "python3"
"name": "pytorch_latest"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -266,7 +266,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.5.6"
}
},
"nbformat": 4,
Expand Down
18 changes: 10 additions & 8 deletions 04-spiral_classification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,23 @@
"source": [
"X = torch.zeros(N * C, D)\n",
"y = torch.zeros(N * C, dtype=torch.long)\n",
"\n",
"for i in range(C):\n",
"for c in range(C):\n",
" index = 0\n",
" r = torch.linspace(0.2, 1, N)\n",
" r = torch.linspace(0, 1, N)\n",
" # When c = 0 and t = 0, 2 * pi (2 * 0 + 0) / 3 = 2 * pi / 3\n",
" # When c = 0 and t = 1, 2 * pi (2 * 1 + 0) / 3 = 2 * 2 * pi / 3\n",
" # Start of t linspace: t = 0, End of t linspace: t = 1s\n",
" t = torch.linspace(\n",
" i * 2 * math.pi / C,\n",
" (i + 2) * 2 * math.pi / C,\n",
" c * 2 * math.pi / C,\n",
" (c + 2) * 2 * math.pi / C,\n",
" N\n",
" ) + torch.randn(N) * 0.0\n",
" ) + torch.randn(N) * 0\n",
" \n",
" for ix in range(N * i, N * (i + 1)):\n",
" for ix in range(N * c, N * (c + 1)):\n",
" X[ix] = r[index] * torch.FloatTensor((\n",
" math.sin(t[index]), math.cos(t[index])\n",
" ))\n",
" y[ix] = i\n",
" y[ix] = c\n",
" index += 1\n",
"\n",
"print(\"Shapes:\")\n",
Expand Down

0 comments on commit 77d61db

Please sign in to comment.