diff --git a/dev/articles/callbacks.html b/dev/articles/callbacks.html index 9fd157cb..b5bbb3ef 100644 --- a/dev/articles/callbacks.html +++ b/dev/articles/callbacks.html @@ -225,7 +225,7 @@
torch
Primerinput = torch_randn(2, 3)
input
#> torch_tensor
-#> -0.6687 -2.4004 -1.4578
-#> 0.9376 -0.9994 -0.3993
+#> 0.4430 -1.7493 0.3801
+#> 2.5443 0.4085 -0.4808
#> [ CPUFloatType{2,3} ]
A nn_module
is constructed from a
nn_module_generator
. nn_linear
is one of the
@@ -117,8 +117,8 @@
torch
Primeroutput = module_1(input)
output
#> torch_tensor
-#> 0.0980 0.3119 -1.4607 -0.4350
-#> 0.2679 0.8104 0.1816 0.0485
+#> 0.6725 0.3022 -0.3800 0.3413
+#> -0.8161 0.3485 0.3559 -1.3795
#> [ CPUFloatType{2,4} ][ grad_fn = <AddmmBackward0> ]
A neural network with one (4-unit) hidden layer and two outputs needs the following ingredients
@@ -134,8 +134,8 @@torch
Primeroutput = softmax(output)
output
#> torch_tensor
-#> 0.2918 0.1502 0.5579
-#> 0.2890 0.1217 0.5893
+#> 0.2155 0.3400 0.4445
+#> 0.1626 0.3668 0.4706
#> [ CPUFloatType{2,3} ][ grad_fn = <SoftmaxBackward0> ]
We will now continue with showing how such a neural network can be
represented in mlr3torch
.
Note we only use the $train()
, since torch modules do
not have anything that maps to the state
(it is filled by
@@ -196,8 +196,8 @@
While this object allows to easily perform a forward pass, it does
not inherit from nn_module
, which is useful for various
@@ -245,8 +245,8 @@
graph_module(input)
#> torch_tensor
-#> 0.2918 0.1502 0.5579
-#> 0.2890 0.1217 0.5893
+#> 0.2155 0.3400 0.4445
+#> 0.1626 0.3668 0.4706
#> [ CPUFloatType{2,3} ][ grad_fn = <SoftmaxBackward0> ]
ModelDescriptor
to
small_module(batch$x[[1]])
#> torch_tensor
-#> -0.9548 2.4764 1.7547 -0.4855
-#> -1.1006 2.1895 1.5184 -0.5936
-#> -0.8588 2.2540 1.5650 -0.4339
+#> 0.3122 -4.8047 0.3374 4.3038
+#> 0.4304 -4.4378 0.4278 3.9666
+#> 0.3240 -4.4393 0.2842 3.9762
#> [ CPUFloatType{3,4} ][ grad_fn = <AddmmBackward0> ]The first linear layer that takes “Sepal” input
("linear1"
) creates a 2x4 tensor (batch size 2, 4 units),
@@ -689,14 +689,14 @@
We observe that the po("nn_merge_cat")
concatenates
these, as expected:
The printed output of the data descriptor informs us about:
What happens during materialize(lt[1])
is the
following:
We see that the $graph
has a new pipeop with id
"poly.x"
and the output pointer
points to
poly.x
. Also we see that the shape of the tensor is now
diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml
index e3bde776..510fc9da 100644
--- a/dev/pkgdown.yml
+++ b/dev/pkgdown.yml
@@ -7,7 +7,7 @@ articles:
articles/internals_pipeop_torch: internals_pipeop_torch.html
articles/lazy_tensor: lazy_tensor.html
articles/pipeop_torch: pipeop_torch.html
-last_built: 2024-11-26T10:52Z
+last_built: 2024-12-02T20:30Z
urls:
reference: https://mlr3torch.mlr-org.com/reference
article: https://mlr3torch.mlr-org.com/articles
diff --git a/dev/reference/DataDescriptor.html b/dev/reference/DataDescriptor.html
index 0b6c3171..483f81a1 100644
--- a/dev/reference/DataDescriptor.html
+++ b/dev/reference/DataDescriptor.html
@@ -263,14 +263,14 @@
lt1 = as_lazy_tensor(torch_randn(10, 3))
materialize(lt1, rbind = TRUE)
#> torch_tensor
-#> 0.7209 -0.7791 -0.1200
-#> -0.8322 -0.3782 -1.4658
-#> 2.9278 0.1341 -2.9706
-#> 0.4715 0.3795 2.1664
-#> 0.3711 -1.0344 -0.5415
-#> 1.6425 -0.0933 1.2480
-#> 0.0744 0.1560 -0.1901
-#> 1.9826 -1.4531 -0.8456
-#> 0.5194 0.4390 -0.9260
-#> 0.2598 0.4431 -0.5103
+#> 0.1876 0.0088 1.4593
+#> -0.1544 -1.7849 -0.9684
+#> -0.4133 0.4283 1.5972
+#> -1.1213 1.9914 0.4018
+#> 1.4719 -0.4199 -0.5979
+#> 1.1147 1.8712 0.3224
+#> -0.2409 1.8200 -0.1913
+#> -1.0128 1.6925 -0.1613
+#> 0.0527 -0.0583 1.5428
+#> 0.3041 0.7279 0.2507
#> [ CPUFloatType{10,3} ]
materialize(lt1, rbind = FALSE)
#> [[1]]
#> torch_tensor
-#> 0.7209
-#> -0.7791
-#> -0.1200
+#> 0.1876
+#> 0.0088
+#> 1.4593
#> [ CPUFloatType{3} ]
#>
#> [[2]]
#> torch_tensor
-#> -0.8322
-#> -0.3782
-#> -1.4658
+#> -0.1544
+#> -1.7849
+#> -0.9684
#> [ CPUFloatType{3} ]
#>
#> [[3]]
#> torch_tensor
-#> 2.9278
-#> 0.1341
-#> -2.9706
+#> -0.4133
+#> 0.4283
+#> 1.5972
#> [ CPUFloatType{3} ]
#>
#> [[4]]
#> torch_tensor
-#> 0.4715
-#> 0.3795
-#> 2.1664
+#> -1.1213
+#> 1.9914
+#> 0.4018
#> [ CPUFloatType{3} ]
#>
#> [[5]]
#> torch_tensor
-#> 0.3711
-#> -1.0344
-#> -0.5415
+#> 1.4719
+#> -0.4199
+#> -0.5979
#> [ CPUFloatType{3} ]
#>
#> [[6]]
#> torch_tensor
-#> 1.6425
-#> -0.0933
-#> 1.2480
+#> 1.1147
+#> 1.8712
+#> 0.3224
#> [ CPUFloatType{3} ]
#>
#> [[7]]
#> torch_tensor
-#> 0.0744
-#> 0.1560
-#> -0.1901
+#> -0.2409
+#> 1.8200
+#> -0.1913
#> [ CPUFloatType{3} ]
#>
#> [[8]]
#> torch_tensor
-#> 1.9826
-#> -1.4531
-#> -0.8456
+#> -1.0128
+#> 1.6925
+#> -0.1613
#> [ CPUFloatType{3} ]
#>
#> [[9]]
#> torch_tensor
-#> 0.5194
-#> 0.4390
-#> -0.9260
+#> 0.0527
+#> -0.0583
+#> 1.5428
#> [ CPUFloatType{3} ]
#>
#> [[10]]
#> torch_tensor
-#> 0.2598
-#> 0.4431
-#> -0.5103
+#> 0.3041
+#> 0.7279
+#> 0.2507
#> [ CPUFloatType{3} ]
#>
lt2 = as_lazy_tensor(torch_randn(10, 4))
@@ -219,184 +219,184 @@ Examplesmaterialize(d, rbind = TRUE)
#> $lt1
#> torch_tensor
-#> 0.7209 -0.7791 -0.1200
-#> -0.8322 -0.3782 -1.4658
-#> 2.9278 0.1341 -2.9706
-#> 0.4715 0.3795 2.1664
-#> 0.3711 -1.0344 -0.5415
-#> 1.6425 -0.0933 1.2480
-#> 0.0744 0.1560 -0.1901
-#> 1.9826 -1.4531 -0.8456
-#> 0.5194 0.4390 -0.9260
-#> 0.2598 0.4431 -0.5103
+#> 0.1876 0.0088 1.4593
+#> -0.1544 -1.7849 -0.9684
+#> -0.4133 0.4283 1.5972
+#> -1.1213 1.9914 0.4018
+#> 1.4719 -0.4199 -0.5979
+#> 1.1147 1.8712 0.3224
+#> -0.2409 1.8200 -0.1913
+#> -1.0128 1.6925 -0.1613
+#> 0.0527 -0.0583 1.5428
+#> 0.3041 0.7279 0.2507
#> [ CPUFloatType{10,3} ]
#>
#> $lt2
#> torch_tensor
-#> -0.9499 1.2267 0.3966 -0.1104
-#> -1.7213 0.0694 0.6292 0.4429
-#> 0.1034 -0.2247 -1.0382 -0.8711
-#> 1.3446 -0.7110 -0.2305 1.1702
-#> -0.4673 -1.1430 0.0230 0.2525
-#> -0.2598 0.9152 -1.4227 -0.0557
-#> -2.2192 2.6817 1.2324 0.2709
-#> -1.2812 -0.9407 0.8546 1.1632
-#> 0.8758 -1.2456 -1.4916 0.2601
-#> -0.5359 -0.7665 0.9438 0.1353
+#> 0.5711 -0.6314 -0.7923 0.0621
+#> 0.9379 0.8469 -0.1051 0.7225
+#> -0.2402 -0.9588 -0.8237 -0.3911
+#> -0.2728 -0.8515 -1.2257 0.1618
+#> -0.5972 1.4824 0.8495 1.8945
+#> -0.9398 -0.5522 -1.4726 0.3737
+#> -0.6116 -0.5517 0.6216 -2.0019
+#> -0.4594 -1.2072 0.9961 -0.5702
+#> -0.0091 0.3094 -0.0514 -1.8272
+#> -0.9225 0.5034 0.1760 -1.4413
#> [ CPUFloatType{10,4} ]
#>
materialize(d, rbind = FALSE)
#> $lt1
#> $lt1[[1]]
#> torch_tensor
-#> 0.7209
-#> -0.7791
-#> -0.1200
+#> 0.1876
+#> 0.0088
+#> 1.4593
#> [ CPUFloatType{3} ]
#>
#> $lt1[[2]]
#> torch_tensor
-#> -0.8322
-#> -0.3782
-#> -1.4658
+#> -0.1544
+#> -1.7849
+#> -0.9684
#> [ CPUFloatType{3} ]
#>
#> $lt1[[3]]
#> torch_tensor
-#> 2.9278
-#> 0.1341
-#> -2.9706
+#> -0.4133
+#> 0.4283
+#> 1.5972
#> [ CPUFloatType{3} ]
#>
#> $lt1[[4]]
#> torch_tensor
-#> 0.4715
-#> 0.3795
-#> 2.1664
+#> -1.1213
+#> 1.9914
+#> 0.4018
#> [ CPUFloatType{3} ]
#>
#> $lt1[[5]]
#> torch_tensor
-#> 0.3711
-#> -1.0344
-#> -0.5415
+#> 1.4719
+#> -0.4199
+#> -0.5979
#> [ CPUFloatType{3} ]
#>
#> $lt1[[6]]
#> torch_tensor
-#> 1.6425
-#> -0.0933
-#> 1.2480
+#> 1.1147
+#> 1.8712
+#> 0.3224
#> [ CPUFloatType{3} ]
#>
#> $lt1[[7]]
#> torch_tensor
-#> 0.0744
-#> 0.1560
-#> -0.1901
+#> -0.2409
+#> 1.8200
+#> -0.1913
#> [ CPUFloatType{3} ]
#>
#> $lt1[[8]]
#> torch_tensor
-#> 1.9826
-#> -1.4531
-#> -0.8456
+#> -1.0128
+#> 1.6925
+#> -0.1613
#> [ CPUFloatType{3} ]
#>
#> $lt1[[9]]
#> torch_tensor
-#> 0.5194
-#> 0.4390
-#> -0.9260
+#> 0.0527
+#> -0.0583
+#> 1.5428
#> [ CPUFloatType{3} ]
#>
#> $lt1[[10]]
#> torch_tensor
-#> 0.2598
-#> 0.4431
-#> -0.5103
+#> 0.3041
+#> 0.7279
+#> 0.2507
#> [ CPUFloatType{3} ]
#>
#>
#> $lt2
#> $lt2[[1]]
#> torch_tensor
-#> -0.9499
-#> 1.2267
-#> 0.3966
-#> -0.1104
+#> 0.5711
+#> -0.6314
+#> -0.7923
+#> 0.0621
#> [ CPUFloatType{4} ]
#>
#> $lt2[[2]]
#> torch_tensor
-#> -1.7213
-#> 0.0694
-#> 0.6292
-#> 0.4429
+#> 0.9379
+#> 0.8469
+#> -0.1051
+#> 0.7225
#> [ CPUFloatType{4} ]
#>
#> $lt2[[3]]
#> torch_tensor
-#> 0.1034
-#> -0.2247
-#> -1.0382
-#> -0.8711
+#> -0.2402
+#> -0.9588
+#> -0.8237
+#> -0.3911
#> [ CPUFloatType{4} ]
#>
#> $lt2[[4]]
#> torch_tensor
-#> 1.3446
-#> -0.7110
-#> -0.2305
-#> 1.1702
+#> -0.2728
+#> -0.8515
+#> -1.2257
+#> 0.1618
#> [ CPUFloatType{4} ]
#>
#> $lt2[[5]]
#> torch_tensor
-#> -0.4673
-#> -1.1430
-#> 0.0230
-#> 0.2525
+#> -0.5972
+#> 1.4824
+#> 0.8495
+#> 1.8945
#> [ CPUFloatType{4} ]
#>
#> $lt2[[6]]
#> torch_tensor
-#> -0.2598
-#> 0.9152
-#> -1.4227
-#> -0.0557
+#> -0.9398
+#> -0.5522
+#> -1.4726
+#> 0.3737
#> [ CPUFloatType{4} ]
#>
#> $lt2[[7]]
#> torch_tensor
-#> -2.2192
-#> 2.6817
-#> 1.2324
-#> 0.2709
+#> -0.6116
+#> -0.5517
+#> 0.6216
+#> -2.0019
#> [ CPUFloatType{4} ]
#>
#> $lt2[[8]]
#> torch_tensor
-#> -1.2812
-#> -0.9407
-#> 0.8546
-#> 1.1632
+#> -0.4594
+#> -1.2072
+#> 0.9961
+#> -0.5702
#> [ CPUFloatType{4} ]
#>
#> $lt2[[9]]
#> torch_tensor
-#> 0.8758
-#> -1.2456
-#> -1.4916
-#> 0.2601
+#> -0.0091
+#> 0.3094
+#> -0.0514
+#> -1.8272
#> [ CPUFloatType{4} ]
#>
#> $lt2[[10]]
#> torch_tensor
-#> -0.5359
-#> -0.7665
-#> 0.9438
-#> 0.1353
+#> -0.9225
+#> 0.5034
+#> 0.1760
+#> -1.4413
#> [ CPUFloatType{4} ]
#>
#>
diff --git a/dev/reference/mlr_pipeops_torch_ingress_ltnsr.html b/dev/reference/mlr_pipeops_torch_ingress_ltnsr.html
index 3959006d..4059f1e7 100644
--- a/dev/reference/mlr_pipeops_torch_ingress_ltnsr.html
+++ b/dev/reference/mlr_pipeops_torch_ingress_ltnsr.html
@@ -274,35 +274,35 @@ Examplesx_batch2
#> torch_tensor
#> (1,1,.,.) =
-#> 0.5945 -1.0047 0.0898 0.4695 -0.2213 0.0279
-#> 1.0332 -1.4109 0.8082 -0.1438 0.1753 -1.1941
-#> 0.3561 -0.5219 -0.0985 -0.4688 -0.4243 -0.1469
-#> -0.4475 -0.5437 -0.2712 0.1507 0.7601 -2.2758
-#> -0.0112 -0.6460 -0.5519 0.0411 1.0907 0.7192
-#> 0.3734 -1.7688 0.9091 -0.0721 0.1462 -0.0802
+#> -0.3536 0.5422 -0.5122 -0.4266 -0.0916 -0.4592
+#> 0.8402 1.3915 -0.7842 0.3108 0.4223 -0.6371
+#> 0.7064 -1.1143 -1.0290 -1.5323 -0.1813 0.2049
+#> 0.0286 -0.4911 -0.4830 -0.1494 -0.5065 -0.0469
+#> -0.6232 -0.3729 0.1369 1.1254 -0.5872 0.6150
+#> 0.0530 -0.7461 1.2229 0.3075 0.2254 -0.2231
#>
#> (2,1,.,.) =
-#> -0.7234 0.1754 -1.0752 -1.2271 -0.0561 0.6646
-#> -0.6509 0.3914 -0.5936 0.3779 -0.6972 0.0340
-#> 0.1612 1.0706 0.4121 -0.3568 -0.2576 0.6846
-#> -0.6529 0.0693 -0.8919 1.0970 -0.4039 0.6887
-#> -1.3010 -0.1821 0.6225 1.1529 -0.2668 -0.5625
-#> -1.1438 0.1229 -0.4223 0.5343 -0.4232 0.5311
+#> -0.5584 -0.6006 0.0852 0.1745 -0.4200 -0.5432
+#> -0.3563 0.6179 -0.4114 0.0964 -0.3026 -0.0497
+#> -0.2654 0.0973 -0.1497 -0.0353 1.1315 0.6398
+#> -0.6037 -0.6516 -0.8290 -1.4187 -0.7332 -1.3848
+#> -0.3522 0.2617 -0.8548 0.1738 0.1908 0.1583
+#> -0.1979 -1.1566 -0.4095 0.3285 1.1347 -0.8909
#>
#> (1,2,.,.) =
-#> 1.1896 -0.4246 -0.9544 0.0690 -1.6374 0.4171
-#> 1.0969 -0.5784 -0.3845 0.3485 0.8230 1.1430
-#> 0.0990 1.2661 0.0993 -0.4821 -1.1926 0.2399
-#> -0.9176 0.1813 -0.0787 0.4138 1.5121 0.4998
-#> 1.0572 -0.2697 -0.0084 -0.7172 0.1109 0.5671
-#> 0.0192 -0.3271 -0.6918 0.7929 0.9149 0.5626
+#> -0.8666 0.1124 -0.3811 -0.3970 -0.4885 -0.9129
+#> -1.1868 -1.8638 0.2943 0.8698 0.6637 -0.0425
+#> 0.3130 0.8464 -0.3372 0.3382 0.7500 0.0065
+#> -0.1226 -1.1815 0.6687 0.8796 -0.1691 0.4671
+#> 0.0456 1.0095 0.9920 -1.1715 -1.3439 0.0340
+#> 0.5361 0.2356 -1.7181 0.9764 -1.5450 -0.0521
#>
#> (2,2,.,.) =
-#> -0.7294 -0.2803 -0.5699 0.5159 -0.0475 0.2107
-#> 0.3567 0.9719 -0.7477 -0.4505 0.5632 0.7329
-#> 0.1405 -0.0291 -0.3008 -0.4238 0.2812 0.9680
-#> 1.1327 0.6031 0.2286 -0.0610 -0.5833 -0.8078
-#> -0.0608 0.2079 1.1355 0.2255 -0.2593 0.5523
+#> 1.1174 0.1390 0.5125 -0.4994 -0.1428 -0.2354
+#> -0.1027 0.6353 0.7274 -0.5460 -1.0755 -0.5056
+#> 0.4653 -0.2932 0.7616 0.9773 -0.1486 -0.0574
+#> 0.3783 -0.3556 1.6875 1.2363 0.1012 -0.2989
+#> 0.8542 0.3894 0.9231 0.8197 -0.3083 0.0473
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{2,3,6,6} ]
diff --git a/dev/reference/mlr_pipeops_torch_model_classif.html b/dev/reference/mlr_pipeops_torch_model_classif.html
index f190ca42..1989ad21 100644
--- a/dev/reference/mlr_pipeops_torch_model_classif.html
+++ b/dev/reference/mlr_pipeops_torch_model_classif.html
@@ -274,17 +274,17 @@