diff --git a/dev/articles/callbacks.html b/dev/articles/callbacks.html index 274d8aea..a65089da 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.9070 -2.7058 0.9525
-#> -0.6046 -0.8117 -0.4933
+#> 0.1291 2.0222 -1.2980
+#> -1.6010 -0.5313 -0.2308
#> [ 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.2788 1.2324 -0.4626 -0.5106
-#> 0.5439 0.4810 0.3413 -0.0922
+#> 0.0974 0.3486 0.5000 -0.0451
+#> -0.0646 -0.3571 -0.4350 -0.1996
#> [ 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.5970 0.2588 0.1442
-#> 0.5811 0.2891 0.1298
+#> 0.2069 0.4379 0.3552
+#> 0.2262 0.4446 0.3292
#> [ 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.5970 0.2588 0.1442
-#> 0.5811 0.2891 0.1298
+#> 0.2069 0.4379 0.3552
+#> 0.2262 0.4446 0.3292
#> [ CPUFloatType{2,3} ][ grad_fn = <SoftmaxBackward0> ]
ModelDescriptor
to
small_module(batch$x[[1]])
#> torch_tensor
-#> -2.7629 0.9494 -0.5337 -0.3909
-#> -2.4095 0.8402 -0.4640 -0.1927
-#> -2.4897 0.8274 -0.5014 -0.3388
+#> -3.3067 2.0636 2.0882 -2.1895
+#> -3.1507 1.8299 1.9559 -1.9313
+#> -3.0589 1.8823 1.9405 -2.0448
#> [ 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 5c8b5fb9..9f1c02b7 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-12-06T17:46Z
+last_built: 2024-12-06T17:52Z
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 e43a2407..a2dea936 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.7162 -1.5608 -0.0387
-#> -1.7247 -1.4741 1.3326
-#> 0.4829 0.6899 0.9543
-#> -0.2733 0.1417 0.6729
-#> 0.4039 -0.1466 0.0637
-#> -0.0182 -0.4875 0.1285
-#> -0.2003 0.0778 -0.6773
-#> 0.1149 -1.0739 0.5195
-#> 1.2412 0.2692 -1.2110
-#> 1.0595 0.8234 -0.4103
+#> 0.9445 -0.7692 0.4527
+#> -0.7881 -1.0951 0.3957
+#> 0.0749 0.6307 1.2702
+#> -0.2261 1.2681 2.0863
+#> 0.1060 1.2717 0.8891
+#> 0.7280 -1.0982 0.0943
+#> 1.5875 0.4822 -0.6711
+#> -1.1751 -0.4825 -1.4821
+#> 0.1992 0.6579 1.0917
+#> -0.1451 2.1062 1.5747
#> [ CPUFloatType{10,3} ]
materialize(lt1, rbind = FALSE)
#> [[1]]
#> torch_tensor
-#> -0.7162
-#> -1.5608
-#> -0.0387
+#> 0.9445
+#> -0.7692
+#> 0.4527
#> [ CPUFloatType{3} ]
#>
#> [[2]]
#> torch_tensor
-#> -1.7247
-#> -1.4741
-#> 1.3326
+#> -0.7881
+#> -1.0951
+#> 0.3957
#> [ CPUFloatType{3} ]
#>
#> [[3]]
#> torch_tensor
-#> 0.4829
-#> 0.6899
-#> 0.9543
+#> 0.0749
+#> 0.6307
+#> 1.2702
#> [ CPUFloatType{3} ]
#>
#> [[4]]
#> torch_tensor
-#> -0.2733
-#> 0.1417
-#> 0.6729
+#> -0.2261
+#> 1.2681
+#> 2.0863
#> [ CPUFloatType{3} ]
#>
#> [[5]]
#> torch_tensor
-#> 0.4039
-#> -0.1466
-#> 0.0637
+#> 0.1060
+#> 1.2717
+#> 0.8891
#> [ CPUFloatType{3} ]
#>
#> [[6]]
#> torch_tensor
-#> -0.0182
-#> -0.4875
-#> 0.1285
+#> 0.7280
+#> -1.0982
+#> 0.0943
#> [ CPUFloatType{3} ]
#>
#> [[7]]
#> torch_tensor
-#> -0.2003
-#> 0.0778
-#> -0.6773
+#> 1.5875
+#> 0.4822
+#> -0.6711
#> [ CPUFloatType{3} ]
#>
#> [[8]]
#> torch_tensor
-#> 0.1149
-#> -1.0739
-#> 0.5195
+#> -1.1751
+#> -0.4825
+#> -1.4821
#> [ CPUFloatType{3} ]
#>
#> [[9]]
#> torch_tensor
-#> 1.2412
-#> 0.2692
-#> -1.2110
+#> 0.1992
+#> 0.6579
+#> 1.0917
#> [ CPUFloatType{3} ]
#>
#> [[10]]
#> torch_tensor
-#> 1.0595
-#> 0.8234
-#> -0.4103
+#> -0.1451
+#> 2.1062
+#> 1.5747
#> [ CPUFloatType{3} ]
#>
lt2 = as_lazy_tensor(torch_randn(10, 4))
@@ -219,184 +219,184 @@ Examplesmaterialize(d, rbind = TRUE)
#> $lt1
#> torch_tensor
-#> -0.7162 -1.5608 -0.0387
-#> -1.7247 -1.4741 1.3326
-#> 0.4829 0.6899 0.9543
-#> -0.2733 0.1417 0.6729
-#> 0.4039 -0.1466 0.0637
-#> -0.0182 -0.4875 0.1285
-#> -0.2003 0.0778 -0.6773
-#> 0.1149 -1.0739 0.5195
-#> 1.2412 0.2692 -1.2110
-#> 1.0595 0.8234 -0.4103
+#> 0.9445 -0.7692 0.4527
+#> -0.7881 -1.0951 0.3957
+#> 0.0749 0.6307 1.2702
+#> -0.2261 1.2681 2.0863
+#> 0.1060 1.2717 0.8891
+#> 0.7280 -1.0982 0.0943
+#> 1.5875 0.4822 -0.6711
+#> -1.1751 -0.4825 -1.4821
+#> 0.1992 0.6579 1.0917
+#> -0.1451 2.1062 1.5747
#> [ CPUFloatType{10,3} ]
#>
#> $lt2
#> torch_tensor
-#> 0.3112 2.5506 -0.6576 -1.2956
-#> -0.3208 -0.4852 -0.1543 -0.8971
-#> 0.8473 0.4315 -0.5415 1.6736
-#> 0.8951 -1.0780 0.0980 -2.4735
-#> 0.2695 -0.4690 0.5026 1.1351
-#> 0.2739 1.1301 0.6285 0.0885
-#> -0.9818 -0.1536 0.7535 1.0964
-#> -1.2323 1.3288 -0.0503 -1.1760
-#> 1.4108 -1.3069 0.1260 -0.0153
-#> 0.1052 0.9547 0.1382 0.8248
+#> 0.9996 -0.0941 1.0242 0.1875
+#> -0.3421 1.2876 -2.0939 1.5108
+#> -1.4972 -0.9203 -2.2337 0.8897
+#> -0.6230 0.2173 0.8846 -1.0036
+#> -0.7433 0.0299 0.4034 2.5011
+#> 0.0609 0.2256 1.5222 -1.1435
+#> 0.8190 1.0849 -0.4827 -0.6810
+#> 0.9715 0.6090 -0.8145 -1.0940
+#> 0.2021 -0.4888 0.7531 -1.7744
+#> 1.1634 -1.3271 -1.3252 0.1179
#> [ CPUFloatType{10,4} ]
#>
materialize(d, rbind = FALSE)
#> $lt1
#> $lt1[[1]]
#> torch_tensor
-#> -0.7162
-#> -1.5608
-#> -0.0387
+#> 0.9445
+#> -0.7692
+#> 0.4527
#> [ CPUFloatType{3} ]
#>
#> $lt1[[2]]
#> torch_tensor
-#> -1.7247
-#> -1.4741
-#> 1.3326
+#> -0.7881
+#> -1.0951
+#> 0.3957
#> [ CPUFloatType{3} ]
#>
#> $lt1[[3]]
#> torch_tensor
-#> 0.4829
-#> 0.6899
-#> 0.9543
+#> 0.0749
+#> 0.6307
+#> 1.2702
#> [ CPUFloatType{3} ]
#>
#> $lt1[[4]]
#> torch_tensor
-#> -0.2733
-#> 0.1417
-#> 0.6729
+#> -0.2261
+#> 1.2681
+#> 2.0863
#> [ CPUFloatType{3} ]
#>
#> $lt1[[5]]
#> torch_tensor
-#> 0.4039
-#> -0.1466
-#> 0.0637
+#> 0.1060
+#> 1.2717
+#> 0.8891
#> [ CPUFloatType{3} ]
#>
#> $lt1[[6]]
#> torch_tensor
-#> -0.0182
-#> -0.4875
-#> 0.1285
+#> 0.7280
+#> -1.0982
+#> 0.0943
#> [ CPUFloatType{3} ]
#>
#> $lt1[[7]]
#> torch_tensor
-#> -0.2003
-#> 0.0778
-#> -0.6773
+#> 1.5875
+#> 0.4822
+#> -0.6711
#> [ CPUFloatType{3} ]
#>
#> $lt1[[8]]
#> torch_tensor
-#> 0.1149
-#> -1.0739
-#> 0.5195
+#> -1.1751
+#> -0.4825
+#> -1.4821
#> [ CPUFloatType{3} ]
#>
#> $lt1[[9]]
#> torch_tensor
-#> 1.2412
-#> 0.2692
-#> -1.2110
+#> 0.1992
+#> 0.6579
+#> 1.0917
#> [ CPUFloatType{3} ]
#>
#> $lt1[[10]]
#> torch_tensor
-#> 1.0595
-#> 0.8234
-#> -0.4103
+#> -0.1451
+#> 2.1062
+#> 1.5747
#> [ CPUFloatType{3} ]
#>
#>
#> $lt2
#> $lt2[[1]]
#> torch_tensor
-#> 0.3112
-#> 2.5506
-#> -0.6576
-#> -1.2956
+#> 0.9996
+#> -0.0941
+#> 1.0242
+#> 0.1875
#> [ CPUFloatType{4} ]
#>
#> $lt2[[2]]
#> torch_tensor
-#> -0.3208
-#> -0.4852
-#> -0.1543
-#> -0.8971
+#> -0.3421
+#> 1.2876
+#> -2.0939
+#> 1.5108
#> [ CPUFloatType{4} ]
#>
#> $lt2[[3]]
#> torch_tensor
-#> 0.8473
-#> 0.4315
-#> -0.5415
-#> 1.6736
+#> -1.4972
+#> -0.9203
+#> -2.2337
+#> 0.8897
#> [ CPUFloatType{4} ]
#>
#> $lt2[[4]]
#> torch_tensor
-#> 0.8951
-#> -1.0780
-#> 0.0980
-#> -2.4735
+#> -0.6230
+#> 0.2173
+#> 0.8846
+#> -1.0036
#> [ CPUFloatType{4} ]
#>
#> $lt2[[5]]
#> torch_tensor
-#> 0.2695
-#> -0.4690
-#> 0.5026
-#> 1.1351
+#> -0.7433
+#> 0.0299
+#> 0.4034
+#> 2.5011
#> [ CPUFloatType{4} ]
#>
#> $lt2[[6]]
#> torch_tensor
-#> 0.2739
-#> 1.1301
-#> 0.6285
-#> 0.0885
+#> 0.0609
+#> 0.2256
+#> 1.5222
+#> -1.1435
#> [ CPUFloatType{4} ]
#>
#> $lt2[[7]]
#> torch_tensor
-#> -0.9818
-#> -0.1536
-#> 0.7535
-#> 1.0964
+#> 0.8190
+#> 1.0849
+#> -0.4827
+#> -0.6810
#> [ CPUFloatType{4} ]
#>
#> $lt2[[8]]
#> torch_tensor
-#> -1.2323
-#> 1.3288
-#> -0.0503
-#> -1.1760
+#> 0.9715
+#> 0.6090
+#> -0.8145
+#> -1.0940
#> [ CPUFloatType{4} ]
#>
#> $lt2[[9]]
#> torch_tensor
-#> 1.4108
-#> -1.3069
-#> 0.1260
-#> -0.0153
+#> 0.2021
+#> -0.4888
+#> 0.7531
+#> -1.7744
#> [ CPUFloatType{4} ]
#>
#> $lt2[[10]]
#> torch_tensor
-#> 0.1052
-#> 0.9547
-#> 0.1382
-#> 0.8248
+#> 1.1634
+#> -1.3271
+#> -1.3252
+#> 0.1179
#> [ CPUFloatType{4} ]
#>
#>
diff --git a/dev/reference/mlr_learners_torch_model.html b/dev/reference/mlr_learners_torch_model.html
index ce5f0ecf..5ef6b1ec 100644
--- a/dev/reference/mlr_learners_torch_model.html
+++ b/dev/reference/mlr_learners_torch_model.html
@@ -243,14 +243,14 @@ Exampleslearner$train(task, ids$train)
learner$predict(task, ids$test)
#> <PredictionClassif> for 50 observations:
-#> row_ids truth response
-#> 3 setosa virginica
-#> 9 setosa virginica
-#> 10 setosa virginica
-#> --- --- ---
-#> 147 virginica virginica
-#> 149 virginica virginica
-#> 150 virginica virginica
+#> row_ids truth response
+#> 3 setosa versicolor
+#> 9 setosa versicolor
+#> 10 setosa versicolor
+#> --- --- ---
+#> 147 virginica versicolor
+#> 149 virginica versicolor
+#> 150 virginica versicolor