Skip to content

Commit f5d199c

Browse files
committed
Update for final review. p2ch12 code might get further tweaks.
1 parent 79c57ab commit f5d199c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6414
-476
lines changed

data/p1ch3/ourpoints.hdf5

0 Bytes
Binary file not shown.

data/p1ch3/ourpoints.t

0 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.cs.toronto.edu/~kriz/cifar.html">
Binary file not shown.
Binary file not shown.

p1ch3/1_tensors.ipynb

+59-59
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@
140140
"outputs": [],
141141
"source": [
142142
"points = torch.zeros(6) # <1>\n",
143-
"points[0] = 1.0 # <2>\n",
144-
"points[1] = 4.0\n",
145-
"points[2] = 2.0\n",
146-
"points[3] = 1.0\n",
147-
"points[4] = 3.0\n",
148-
"points[5] = 5.0"
143+
"points[0] = 4.0 # <2>\n",
144+
"points[1] = 1.0\n",
145+
"points[2] = 5.0\n",
146+
"points[3] = 3.0\n",
147+
"points[4] = 2.0\n",
148+
"points[5] = 1.0"
149149
]
150150
},
151151
{
@@ -156,7 +156,7 @@
156156
{
157157
"data": {
158158
"text/plain": [
159-
"tensor([1., 4., 2., 1., 3., 5.])"
159+
"tensor([4., 1., 5., 3., 2., 1.])"
160160
]
161161
},
162162
"execution_count": 9,
@@ -165,7 +165,7 @@
165165
}
166166
],
167167
"source": [
168-
"points = torch.tensor([1.0, 4.0, 2.0, 1.0, 3.0, 5.0])\n",
168+
"points = torch.tensor([4.0, 1.0, 5.0, 3.0, 2.0, 1.0])\n",
169169
"points"
170170
]
171171
},
@@ -177,7 +177,7 @@
177177
{
178178
"data": {
179179
"text/plain": [
180-
"(1.0, 4.0)"
180+
"(4.0, 1.0)"
181181
]
182182
},
183183
"execution_count": 10,
@@ -197,9 +197,9 @@
197197
{
198198
"data": {
199199
"text/plain": [
200-
"tensor([[1., 4.],\n",
201-
" [2., 1.],\n",
202-
" [3., 5.]])"
200+
"tensor([[4., 1.],\n",
201+
" [5., 3.],\n",
202+
" [2., 1.]])"
203203
]
204204
},
205205
"execution_count": 11,
@@ -208,7 +208,7 @@
208208
}
209209
],
210210
"source": [
211-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
211+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
212212
"points"
213213
]
214214
},
@@ -263,9 +263,9 @@
263263
{
264264
"data": {
265265
"text/plain": [
266-
"tensor([[1., 4.],\n",
267-
" [2., 1.],\n",
268-
" [3., 5.]])"
266+
"tensor([[4., 1.],\n",
267+
" [5., 3.],\n",
268+
" [2., 1.]])"
269269
]
270270
},
271271
"execution_count": 14,
@@ -274,7 +274,7 @@
274274
}
275275
],
276276
"source": [
277-
"points = torch.FloatTensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
277+
"points = torch.FloatTensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
278278
"points"
279279
]
280280
},
@@ -286,7 +286,7 @@
286286
{
287287
"data": {
288288
"text/plain": [
289-
"tensor(4.)"
289+
"tensor(1.)"
290290
]
291291
},
292292
"execution_count": 15,
@@ -306,7 +306,7 @@
306306
{
307307
"data": {
308308
"text/plain": [
309-
"tensor([1., 4.])"
309+
"tensor([4., 1.])"
310310
]
311311
},
312312
"execution_count": 16,
@@ -326,12 +326,12 @@
326326
{
327327
"data": {
328328
"text/plain": [
329-
" 1.0\n",
330329
" 4.0\n",
331-
" 2.0\n",
332330
" 1.0\n",
333-
" 3.0\n",
334331
" 5.0\n",
332+
" 3.0\n",
333+
" 2.0\n",
334+
" 1.0\n",
335335
"[torch.FloatStorage of size 6]"
336336
]
337337
},
@@ -341,7 +341,7 @@
341341
}
342342
],
343343
"source": [
344-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
344+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
345345
"points.storage()"
346346
]
347347
},
@@ -353,7 +353,7 @@
353353
{
354354
"data": {
355355
"text/plain": [
356-
"1.0"
356+
"4.0"
357357
]
358358
},
359359
"execution_count": 18,
@@ -374,7 +374,7 @@
374374
{
375375
"data": {
376376
"text/plain": [
377-
"4.0"
377+
"1.0"
378378
]
379379
},
380380
"execution_count": 19,
@@ -394,9 +394,9 @@
394394
{
395395
"data": {
396396
"text/plain": [
397-
"tensor([[2., 4.],\n",
398-
" [2., 1.],\n",
399-
" [3., 5.]])"
397+
"tensor([[2., 1.],\n",
398+
" [5., 3.],\n",
399+
" [2., 1.]])"
400400
]
401401
},
402402
"execution_count": 20,
@@ -405,7 +405,7 @@
405405
}
406406
],
407407
"source": [
408-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
408+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
409409
"points_storage = points.storage()\n",
410410
"points_storage[0] = 2.0\n",
411411
"points"
@@ -428,7 +428,7 @@
428428
}
429429
],
430430
"source": [
431-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
431+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
432432
"second_point = points[1]\n",
433433
"second_point.storage_offset()"
434434
]
@@ -510,7 +510,7 @@
510510
}
511511
],
512512
"source": [
513-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
513+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
514514
"second_point = points[1]\n",
515515
"second_point.size()"
516516
]
@@ -563,9 +563,9 @@
563563
{
564564
"data": {
565565
"text/plain": [
566-
"tensor([[ 1., 4.],\n",
567-
" [10., 1.],\n",
568-
" [ 3., 5.]])"
566+
"tensor([[ 4., 1.],\n",
567+
" [10., 3.],\n",
568+
" [ 2., 1.]])"
569569
]
570570
},
571571
"execution_count": 28,
@@ -574,7 +574,7 @@
574574
}
575575
],
576576
"source": [
577-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
577+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
578578
"second_point = points[1]\n",
579579
"second_point[0] = 10.0\n",
580580
"points"
@@ -588,9 +588,9 @@
588588
{
589589
"data": {
590590
"text/plain": [
591-
"tensor([[1., 4.],\n",
592-
" [2., 1.],\n",
593-
" [3., 5.]])"
591+
"tensor([[4., 1.],\n",
592+
" [5., 3.],\n",
593+
" [2., 1.]])"
594594
]
595595
},
596596
"execution_count": 29,
@@ -599,7 +599,7 @@
599599
}
600600
],
601601
"source": [
602-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
602+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
603603
"second_point = points[1].clone()\n",
604604
"second_point[0] = 10.0\n",
605605
"points"
@@ -613,9 +613,9 @@
613613
{
614614
"data": {
615615
"text/plain": [
616-
"tensor([[1., 4.],\n",
617-
" [2., 1.],\n",
618-
" [3., 5.]])"
616+
"tensor([[4., 1.],\n",
617+
" [5., 3.],\n",
618+
" [2., 1.]])"
619619
]
620620
},
621621
"execution_count": 30,
@@ -624,7 +624,7 @@
624624
}
625625
],
626626
"source": [
627-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
627+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
628628
"points"
629629
]
630630
},
@@ -636,8 +636,8 @@
636636
{
637637
"data": {
638638
"text/plain": [
639-
"tensor([[1., 2., 3.],\n",
640-
" [4., 1., 5.]])"
639+
"tensor([[4., 5., 2.],\n",
640+
" [1., 3., 1.]])"
641641
]
642642
},
643643
"execution_count": 31,
@@ -840,8 +840,8 @@
840840
{
841841
"data": {
842842
"text/plain": [
843-
"tensor([[1., 2., 3.],\n",
844-
" [4., 1., 5.]])"
843+
"tensor([[4., 5., 2.],\n",
844+
" [1., 3., 1.]])"
845845
]
846846
},
847847
"execution_count": 41,
@@ -850,7 +850,7 @@
850850
}
851851
],
852852
"source": [
853-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 5.0]])\n",
853+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])\n",
854854
"points_t = points.t()\n",
855855
"points_t"
856856
]
@@ -863,12 +863,12 @@
863863
{
864864
"data": {
865865
"text/plain": [
866-
" 1.0\n",
867866
" 4.0\n",
868-
" 2.0\n",
869867
" 1.0\n",
870-
" 3.0\n",
871868
" 5.0\n",
869+
" 3.0\n",
870+
" 2.0\n",
871+
" 1.0\n",
872872
"[torch.FloatStorage of size 6]"
873873
]
874874
},
@@ -909,8 +909,8 @@
909909
{
910910
"data": {
911911
"text/plain": [
912-
"tensor([[1., 2., 3.],\n",
913-
" [4., 1., 5.]])"
912+
"tensor([[4., 5., 2.],\n",
913+
" [1., 3., 1.]])"
914914
]
915915
},
916916
"execution_count": 44,
@@ -951,12 +951,12 @@
951951
{
952952
"data": {
953953
"text/plain": [
954-
" 1.0\n",
954+
" 4.0\n",
955+
" 5.0\n",
955956
" 2.0\n",
957+
" 1.0\n",
956958
" 3.0\n",
957-
" 4.0\n",
958959
" 1.0\n",
959-
" 5.0\n",
960960
"[torch.FloatStorage of size 6]"
961961
]
962962
},
@@ -1036,7 +1036,7 @@
10361036
"outputs": [],
10371037
"source": [
10381038
"# reset points back to original value\n",
1039-
"points = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 4.0]])"
1039+
"points = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]])"
10401040
]
10411041
},
10421042
{
@@ -1073,7 +1073,7 @@
10731073
{
10741074
"data": {
10751075
"text/plain": [
1076-
"tensor([2., 3.])"
1076+
"tensor([5., 2.])"
10771077
]
10781078
},
10791079
"execution_count": 54,
@@ -1198,7 +1198,7 @@
11981198
"metadata": {},
11991199
"outputs": [],
12001200
"source": [
1201-
"points_gpu = torch.tensor([[1.0, 4.0], [2.0, 1.0], [3.0, 4.0]], device='cuda')"
1201+
"points_gpu = torch.tensor([[4.0, 1.0], [5.0, 3.0], [2.0, 1.0]], device='cuda')"
12021202
]
12031203
},
12041204
{

0 commit comments

Comments
 (0)