diff --git a/dev/articles/callbacks.html b/dev/articles/callbacks.html index 9035fd49..184f09b5 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.3523 -1.2318 0.3239
-#> 0.7956 0.8281 -1.7749
+#> 0.6886 1.5234 -0.4646
+#> -0.2283 -0.4859 1.8830
#> [ 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.2760 -0.9127 0.6610 -0.1370
-#> 0.8999 0.5818 -0.5390 -1.4131
+#> -0.5194 -0.5348 -0.6050 1.0497
+#> 0.9937 0.5747 0.5523 -0.8098
#> [ 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.2606 0.3220 0.4174
-#> 0.3031 0.3645 0.3324
+#> 0.3351 0.3104 0.3545
+#> 0.3483 0.2008 0.4510
#> [ 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.2606 0.3220 0.4174
-#> 0.3031 0.3645 0.3324
+#> 0.3351 0.3104 0.3545
+#> 0.3483 0.2008 0.4510
#> [ CPUFloatType{2,3} ][ grad_fn = <SoftmaxBackward0> ]
ModelDescriptor
to
small_module(batch$x[[1]])
#> torch_tensor
-#> -2.2059 -0.9033 2.7936 3.0107
-#> -2.0079 -1.0007 2.6154 2.7973
-#> -2.0381 -0.8644 2.5998 2.7272
+#> -0.9670 0.3528 1.9821 0.5473
+#> -0.7823 0.3230 1.8976 0.7231
+#> -0.8980 0.2995 1.8627 0.5497
#> [ 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 44e9d9aa..a1bbe7fe 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-08-16T11:27Z
+last_built: 2024-08-16T14:09Z
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 69eaddf0..8c769371 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.2102 -1.0118 0.1966
-#> 1.5111 1.8772 -1.5038
-#> -0.7771 -0.7559 -0.9180
-#> -0.8596 2.5035 -0.4579
-#> -0.7924 0.1992 1.7554
-#> -0.6679 0.3848 -0.0669
-#> 0.8603 -1.6431 -0.2236
-#> 1.3194 -1.4633 0.3026
-#> 0.2601 0.1893 -0.1636
-#> -0.1530 -0.4149 0.1363
+#> -1.7313 -0.7450 0.0750
+#> -0.4517 0.3896 0.3660
+#> -0.3594 -0.5318 1.5231
+#> 1.7082 0.8961 -0.9832
+#> -1.8722 -0.0556 -0.0277
+#> 1.7278 -0.2025 0.0699
+#> -1.5121 0.9003 0.1712
+#> -1.3465 0.8367 0.3196
+#> -0.4214 1.7066 2.3341
+#> -1.0550 1.6865 -0.5905
#> [ CPUFloatType{10,3} ]
materialize(lt1, rbind = FALSE)
#> [[1]]
#> torch_tensor
-#> 0.2102
-#> -1.0118
-#> 0.1966
+#> -1.7313
+#> -0.7450
+#> 0.0750
#> [ CPUFloatType{3} ]
#>
#> [[2]]
#> torch_tensor
-#> 1.5111
-#> 1.8772
-#> -1.5038
+#> -0.4517
+#> 0.3896
+#> 0.3660
#> [ CPUFloatType{3} ]
#>
#> [[3]]
#> torch_tensor
-#> -0.7771
-#> -0.7559
-#> -0.9180
+#> -0.3594
+#> -0.5318
+#> 1.5231
#> [ CPUFloatType{3} ]
#>
#> [[4]]
#> torch_tensor
-#> -0.8596
-#> 2.5035
-#> -0.4579
+#> 1.7082
+#> 0.8961
+#> -0.9832
#> [ CPUFloatType{3} ]
#>
#> [[5]]
#> torch_tensor
-#> -0.7924
-#> 0.1992
-#> 1.7554
+#> -1.8722
+#> -0.0556
+#> -0.0277
#> [ CPUFloatType{3} ]
#>
#> [[6]]
#> torch_tensor
-#> -0.6679
-#> 0.3848
-#> -0.0669
+#> 1.7278
+#> -0.2025
+#> 0.0699
#> [ CPUFloatType{3} ]
#>
#> [[7]]
#> torch_tensor
-#> 0.8603
-#> -1.6431
-#> -0.2236
+#> -1.5121
+#> 0.9003
+#> 0.1712
#> [ CPUFloatType{3} ]
#>
#> [[8]]
#> torch_tensor
-#> 1.3194
-#> -1.4633
-#> 0.3026
+#> -1.3465
+#> 0.8367
+#> 0.3196
#> [ CPUFloatType{3} ]
#>
#> [[9]]
#> torch_tensor
-#> 0.2601
-#> 0.1893
-#> -0.1636
+#> -0.4214
+#> 1.7066
+#> 2.3341
#> [ CPUFloatType{3} ]
#>
#> [[10]]
#> torch_tensor
-#> -0.1530
-#> -0.4149
-#> 0.1363
+#> -1.0550
+#> 1.6865
+#> -0.5905
#> [ CPUFloatType{3} ]
#>
lt2 = as_lazy_tensor(torch_randn(10, 4))
@@ -219,184 +219,184 @@ Examplesmaterialize(d, rbind = TRUE)
#> $lt1
#> torch_tensor
-#> 0.2102 -1.0118 0.1966
-#> 1.5111 1.8772 -1.5038
-#> -0.7771 -0.7559 -0.9180
-#> -0.8596 2.5035 -0.4579
-#> -0.7924 0.1992 1.7554
-#> -0.6679 0.3848 -0.0669
-#> 0.8603 -1.6431 -0.2236
-#> 1.3194 -1.4633 0.3026
-#> 0.2601 0.1893 -0.1636
-#> -0.1530 -0.4149 0.1363
+#> -1.7313 -0.7450 0.0750
+#> -0.4517 0.3896 0.3660
+#> -0.3594 -0.5318 1.5231
+#> 1.7082 0.8961 -0.9832
+#> -1.8722 -0.0556 -0.0277
+#> 1.7278 -0.2025 0.0699
+#> -1.5121 0.9003 0.1712
+#> -1.3465 0.8367 0.3196
+#> -0.4214 1.7066 2.3341
+#> -1.0550 1.6865 -0.5905
#> [ CPUFloatType{10,3} ]
#>
#> $lt2
#> torch_tensor
-#> 0.8486 1.8607 1.2682 1.6256
-#> 0.2266 1.6468 -0.5558 0.6281
-#> 0.3452 1.2251 -2.1550 1.4221
-#> -0.8279 0.9675 0.1906 -0.3438
-#> 0.5125 1.9340 -2.4328 -0.3449
-#> 0.2268 0.4603 0.8092 -1.5216
-#> -1.9523 -1.2993 -0.4996 -1.1717
-#> -0.1675 0.6987 -1.0828 0.6437
-#> 0.1582 0.8296 -0.1099 0.8975
-#> 0.9855 0.5586 -1.3208 1.2224
+#> 0.2017 0.2961 0.4128 0.8306
+#> -0.2111 1.0196 -0.2206 0.9749
+#> 0.8859 -1.6881 -1.3262 0.7518
+#> 1.4118 0.7942 -0.4399 1.0231
+#> 0.5783 -2.0002 0.3834 -0.3608
+#> -0.1657 0.4673 -0.0885 0.0922
+#> 0.9691 1.9006 1.1714 -0.1824
+#> -0.5008 -0.1226 -0.4390 0.1573
+#> 0.9786 1.2242 0.9042 0.3172
+#> 0.6006 -0.8235 0.9679 0.8357
#> [ CPUFloatType{10,4} ]
#>
materialize(d, rbind = FALSE)
#> $lt1
#> $lt1[[1]]
#> torch_tensor
-#> 0.2102
-#> -1.0118
-#> 0.1966
+#> -1.7313
+#> -0.7450
+#> 0.0750
#> [ CPUFloatType{3} ]
#>
#> $lt1[[2]]
#> torch_tensor
-#> 1.5111
-#> 1.8772
-#> -1.5038
+#> -0.4517
+#> 0.3896
+#> 0.3660
#> [ CPUFloatType{3} ]
#>
#> $lt1[[3]]
#> torch_tensor
-#> -0.7771
-#> -0.7559
-#> -0.9180
+#> -0.3594
+#> -0.5318
+#> 1.5231
#> [ CPUFloatType{3} ]
#>
#> $lt1[[4]]
#> torch_tensor
-#> -0.8596
-#> 2.5035
-#> -0.4579
+#> 1.7082
+#> 0.8961
+#> -0.9832
#> [ CPUFloatType{3} ]
#>
#> $lt1[[5]]
#> torch_tensor
-#> -0.7924
-#> 0.1992
-#> 1.7554
+#> -1.8722
+#> -0.0556
+#> -0.0277
#> [ CPUFloatType{3} ]
#>
#> $lt1[[6]]
#> torch_tensor
-#> -0.6679
-#> 0.3848
-#> -0.0669
+#> 1.7278
+#> -0.2025
+#> 0.0699
#> [ CPUFloatType{3} ]
#>
#> $lt1[[7]]
#> torch_tensor
-#> 0.8603
-#> -1.6431
-#> -0.2236
+#> -1.5121
+#> 0.9003
+#> 0.1712
#> [ CPUFloatType{3} ]
#>
#> $lt1[[8]]
#> torch_tensor
-#> 1.3194
-#> -1.4633
-#> 0.3026
+#> -1.3465
+#> 0.8367
+#> 0.3196
#> [ CPUFloatType{3} ]
#>
#> $lt1[[9]]
#> torch_tensor
-#> 0.2601
-#> 0.1893
-#> -0.1636
+#> -0.4214
+#> 1.7066
+#> 2.3341
#> [ CPUFloatType{3} ]
#>
#> $lt1[[10]]
#> torch_tensor
-#> -0.1530
-#> -0.4149
-#> 0.1363
+#> -1.0550
+#> 1.6865
+#> -0.5905
#> [ CPUFloatType{3} ]
#>
#>
#> $lt2
#> $lt2[[1]]
#> torch_tensor
-#> 0.8486
-#> 1.8607
-#> 1.2682
-#> 1.6256
+#> 0.2017
+#> 0.2961
+#> 0.4128
+#> 0.8306
#> [ CPUFloatType{4} ]
#>
#> $lt2[[2]]
#> torch_tensor
-#> 0.2266
-#> 1.6468
-#> -0.5558
-#> 0.6281
+#> -0.2111
+#> 1.0196
+#> -0.2206
+#> 0.9749
#> [ CPUFloatType{4} ]
#>
#> $lt2[[3]]
#> torch_tensor
-#> 0.3452
-#> 1.2251
-#> -2.1550
-#> 1.4221
+#> 0.8859
+#> -1.6881
+#> -1.3262
+#> 0.7518
#> [ CPUFloatType{4} ]
#>
#> $lt2[[4]]
#> torch_tensor
-#> -0.8279
-#> 0.9675
-#> 0.1906
-#> -0.3438
+#> 1.4118
+#> 0.7942
+#> -0.4399
+#> 1.0231
#> [ CPUFloatType{4} ]
#>
#> $lt2[[5]]
#> torch_tensor
-#> 0.5125
-#> 1.9340
-#> -2.4328
-#> -0.3449
+#> 0.5783
+#> -2.0002
+#> 0.3834
+#> -0.3608
#> [ CPUFloatType{4} ]
#>
#> $lt2[[6]]
#> torch_tensor
-#> 0.2268
-#> 0.4603
-#> 0.8092
-#> -1.5216
+#> -0.1657
+#> 0.4673
+#> -0.0885
+#> 0.0922
#> [ CPUFloatType{4} ]
#>
#> $lt2[[7]]
#> torch_tensor
-#> -1.9523
-#> -1.2993
-#> -0.4996
-#> -1.1717
+#> 0.9691
+#> 1.9006
+#> 1.1714
+#> -0.1824
#> [ CPUFloatType{4} ]
#>
#> $lt2[[8]]
#> torch_tensor
-#> -0.1675
-#> 0.6987
-#> -1.0828
-#> 0.6437
+#> -0.5008
+#> -0.1226
+#> -0.4390
+#> 0.1573
#> [ CPUFloatType{4} ]
#>
#> $lt2[[9]]
#> torch_tensor
-#> 0.1582
-#> 0.8296
-#> -0.1099
-#> 0.8975
+#> 0.9786
+#> 1.2242
+#> 0.9042
+#> 0.3172
#> [ CPUFloatType{4} ]
#>
#> $lt2[[10]]
#> torch_tensor
-#> 0.9855
-#> 0.5586
-#> -1.3208
-#> 1.2224
+#> 0.6006
+#> -0.8235
+#> 0.9679
+#> 0.8357
#> [ CPUFloatType{4} ]
#>
#>
diff --git a/dev/reference/mlr_learners_torch_model.html b/dev/reference/mlr_learners_torch_model.html
index 5dea13ac..7f07e703 100644
--- a/dev/reference/mlr_learners_torch_model.html
+++ b/dev/reference/mlr_learners_torch_model.html
@@ -242,14 +242,14 @@ Exampleslearner$train(task, ids$train)
learner$predict(task, ids$test)
#> <PredictionClassif> for 48 observations:
-#> row_ids truth response
-#> 1 setosa setosa
-#> 6 setosa setosa
-#> 12 setosa setosa
-#> ---
-#> 142 virginica versicolor
-#> 148 virginica versicolor
-#> 149 virginica versicolor
+#> row_ids truth response
+#> 1 setosa virginica
+#> 6 setosa virginica
+#> 12 setosa virginica
+#> ---
+#> 142 virginica virginica
+#> 148 virginica virginica
+#> 149 virginica virginica