|
140 | 140 | "outputs": [],
|
141 | 141 | "source": [
|
142 | 142 | "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" |
149 | 149 | ]
|
150 | 150 | },
|
151 | 151 | {
|
|
156 | 156 | {
|
157 | 157 | "data": {
|
158 | 158 | "text/plain": [
|
159 |
| - "tensor([1., 4., 2., 1., 3., 5.])" |
| 159 | + "tensor([4., 1., 5., 3., 2., 1.])" |
160 | 160 | ]
|
161 | 161 | },
|
162 | 162 | "execution_count": 9,
|
|
165 | 165 | }
|
166 | 166 | ],
|
167 | 167 | "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", |
169 | 169 | "points"
|
170 | 170 | ]
|
171 | 171 | },
|
|
177 | 177 | {
|
178 | 178 | "data": {
|
179 | 179 | "text/plain": [
|
180 |
| - "(1.0, 4.0)" |
| 180 | + "(4.0, 1.0)" |
181 | 181 | ]
|
182 | 182 | },
|
183 | 183 | "execution_count": 10,
|
|
197 | 197 | {
|
198 | 198 | "data": {
|
199 | 199 | "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.]])" |
203 | 203 | ]
|
204 | 204 | },
|
205 | 205 | "execution_count": 11,
|
|
208 | 208 | }
|
209 | 209 | ],
|
210 | 210 | "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", |
212 | 212 | "points"
|
213 | 213 | ]
|
214 | 214 | },
|
|
263 | 263 | {
|
264 | 264 | "data": {
|
265 | 265 | "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.]])" |
269 | 269 | ]
|
270 | 270 | },
|
271 | 271 | "execution_count": 14,
|
|
274 | 274 | }
|
275 | 275 | ],
|
276 | 276 | "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", |
278 | 278 | "points"
|
279 | 279 | ]
|
280 | 280 | },
|
|
286 | 286 | {
|
287 | 287 | "data": {
|
288 | 288 | "text/plain": [
|
289 |
| - "tensor(4.)" |
| 289 | + "tensor(1.)" |
290 | 290 | ]
|
291 | 291 | },
|
292 | 292 | "execution_count": 15,
|
|
306 | 306 | {
|
307 | 307 | "data": {
|
308 | 308 | "text/plain": [
|
309 |
| - "tensor([1., 4.])" |
| 309 | + "tensor([4., 1.])" |
310 | 310 | ]
|
311 | 311 | },
|
312 | 312 | "execution_count": 16,
|
|
326 | 326 | {
|
327 | 327 | "data": {
|
328 | 328 | "text/plain": [
|
329 |
| - " 1.0\n", |
330 | 329 | " 4.0\n",
|
331 |
| - " 2.0\n", |
332 | 330 | " 1.0\n",
|
333 |
| - " 3.0\n", |
334 | 331 | " 5.0\n",
|
| 332 | + " 3.0\n", |
| 333 | + " 2.0\n", |
| 334 | + " 1.0\n", |
335 | 335 | "[torch.FloatStorage of size 6]"
|
336 | 336 | ]
|
337 | 337 | },
|
|
341 | 341 | }
|
342 | 342 | ],
|
343 | 343 | "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", |
345 | 345 | "points.storage()"
|
346 | 346 | ]
|
347 | 347 | },
|
|
353 | 353 | {
|
354 | 354 | "data": {
|
355 | 355 | "text/plain": [
|
356 |
| - "1.0" |
| 356 | + "4.0" |
357 | 357 | ]
|
358 | 358 | },
|
359 | 359 | "execution_count": 18,
|
|
374 | 374 | {
|
375 | 375 | "data": {
|
376 | 376 | "text/plain": [
|
377 |
| - "4.0" |
| 377 | + "1.0" |
378 | 378 | ]
|
379 | 379 | },
|
380 | 380 | "execution_count": 19,
|
|
394 | 394 | {
|
395 | 395 | "data": {
|
396 | 396 | "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.]])" |
400 | 400 | ]
|
401 | 401 | },
|
402 | 402 | "execution_count": 20,
|
|
405 | 405 | }
|
406 | 406 | ],
|
407 | 407 | "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", |
409 | 409 | "points_storage = points.storage()\n",
|
410 | 410 | "points_storage[0] = 2.0\n",
|
411 | 411 | "points"
|
|
428 | 428 | }
|
429 | 429 | ],
|
430 | 430 | "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", |
432 | 432 | "second_point = points[1]\n",
|
433 | 433 | "second_point.storage_offset()"
|
434 | 434 | ]
|
|
510 | 510 | }
|
511 | 511 | ],
|
512 | 512 | "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", |
514 | 514 | "second_point = points[1]\n",
|
515 | 515 | "second_point.size()"
|
516 | 516 | ]
|
|
563 | 563 | {
|
564 | 564 | "data": {
|
565 | 565 | "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.]])" |
569 | 569 | ]
|
570 | 570 | },
|
571 | 571 | "execution_count": 28,
|
|
574 | 574 | }
|
575 | 575 | ],
|
576 | 576 | "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", |
578 | 578 | "second_point = points[1]\n",
|
579 | 579 | "second_point[0] = 10.0\n",
|
580 | 580 | "points"
|
|
588 | 588 | {
|
589 | 589 | "data": {
|
590 | 590 | "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.]])" |
594 | 594 | ]
|
595 | 595 | },
|
596 | 596 | "execution_count": 29,
|
|
599 | 599 | }
|
600 | 600 | ],
|
601 | 601 | "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", |
603 | 603 | "second_point = points[1].clone()\n",
|
604 | 604 | "second_point[0] = 10.0\n",
|
605 | 605 | "points"
|
|
613 | 613 | {
|
614 | 614 | "data": {
|
615 | 615 | "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.]])" |
619 | 619 | ]
|
620 | 620 | },
|
621 | 621 | "execution_count": 30,
|
|
624 | 624 | }
|
625 | 625 | ],
|
626 | 626 | "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", |
628 | 628 | "points"
|
629 | 629 | ]
|
630 | 630 | },
|
|
636 | 636 | {
|
637 | 637 | "data": {
|
638 | 638 | "text/plain": [
|
639 |
| - "tensor([[1., 2., 3.],\n", |
640 |
| - " [4., 1., 5.]])" |
| 639 | + "tensor([[4., 5., 2.],\n", |
| 640 | + " [1., 3., 1.]])" |
641 | 641 | ]
|
642 | 642 | },
|
643 | 643 | "execution_count": 31,
|
|
840 | 840 | {
|
841 | 841 | "data": {
|
842 | 842 | "text/plain": [
|
843 |
| - "tensor([[1., 2., 3.],\n", |
844 |
| - " [4., 1., 5.]])" |
| 843 | + "tensor([[4., 5., 2.],\n", |
| 844 | + " [1., 3., 1.]])" |
845 | 845 | ]
|
846 | 846 | },
|
847 | 847 | "execution_count": 41,
|
|
850 | 850 | }
|
851 | 851 | ],
|
852 | 852 | "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", |
854 | 854 | "points_t = points.t()\n",
|
855 | 855 | "points_t"
|
856 | 856 | ]
|
|
863 | 863 | {
|
864 | 864 | "data": {
|
865 | 865 | "text/plain": [
|
866 |
| - " 1.0\n", |
867 | 866 | " 4.0\n",
|
868 |
| - " 2.0\n", |
869 | 867 | " 1.0\n",
|
870 |
| - " 3.0\n", |
871 | 868 | " 5.0\n",
|
| 869 | + " 3.0\n", |
| 870 | + " 2.0\n", |
| 871 | + " 1.0\n", |
872 | 872 | "[torch.FloatStorage of size 6]"
|
873 | 873 | ]
|
874 | 874 | },
|
|
909 | 909 | {
|
910 | 910 | "data": {
|
911 | 911 | "text/plain": [
|
912 |
| - "tensor([[1., 2., 3.],\n", |
913 |
| - " [4., 1., 5.]])" |
| 912 | + "tensor([[4., 5., 2.],\n", |
| 913 | + " [1., 3., 1.]])" |
914 | 914 | ]
|
915 | 915 | },
|
916 | 916 | "execution_count": 44,
|
|
951 | 951 | {
|
952 | 952 | "data": {
|
953 | 953 | "text/plain": [
|
954 |
| - " 1.0\n", |
| 954 | + " 4.0\n", |
| 955 | + " 5.0\n", |
955 | 956 | " 2.0\n",
|
| 957 | + " 1.0\n", |
956 | 958 | " 3.0\n",
|
957 |
| - " 4.0\n", |
958 | 959 | " 1.0\n",
|
959 |
| - " 5.0\n", |
960 | 960 | "[torch.FloatStorage of size 6]"
|
961 | 961 | ]
|
962 | 962 | },
|
|
1036 | 1036 | "outputs": [],
|
1037 | 1037 | "source": [
|
1038 | 1038 | "# 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]])" |
1040 | 1040 | ]
|
1041 | 1041 | },
|
1042 | 1042 | {
|
|
1073 | 1073 | {
|
1074 | 1074 | "data": {
|
1075 | 1075 | "text/plain": [
|
1076 |
| - "tensor([2., 3.])" |
| 1076 | + "tensor([5., 2.])" |
1077 | 1077 | ]
|
1078 | 1078 | },
|
1079 | 1079 | "execution_count": 54,
|
|
1198 | 1198 | "metadata": {},
|
1199 | 1199 | "outputs": [],
|
1200 | 1200 | "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')" |
1202 | 1202 | ]
|
1203 | 1203 | },
|
1204 | 1204 | {
|
|
0 commit comments