diff --git a/dev/articles/callbacks.html b/dev/articles/callbacks.html index 7e365d55..2e516983 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.1123 -1.0291 -1.2675
-#> -0.0152 -0.4650 0.9909
+#> -0.4067 -0.0502 -1.6532
+#> -0.1811 -1.5030 -1.8336
#> [ 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.3891 0.4440 -0.1373 0.4749
-#> -0.3452 -0.4354 0.3701 -0.2034
+#> 0.1462 1.0915 -0.2286 0.4098
+#> 0.0748 0.7198 -0.8370 1.0574
#> [ 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.3527 0.3659 0.2814
-#> 0.4060 0.3514 0.2427
+#> 0.4469 0.3663 0.1868
+#> 0.4343 0.3757 0.1900
#> [ 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.3527 0.3659 0.2814
-#> 0.4060 0.3514 0.2427
+#> 0.4469 0.3663 0.1868
+#> 0.4343 0.3757 0.1900
#> [ CPUFloatType{2,3} ][ grad_fn = <SoftmaxBackward0> ]
ModelDescriptor
to
small_module(batch$x[[1]])
#> torch_tensor
-#> 0.9669 -1.7198 -3.3115 -0.4646
-#> 0.7914 -1.8055 -3.1089 -0.2551
-#> 0.8902 -1.6273 -3.0412 -0.3913
+#> 1.4533 -0.8890 1.1345 0.5390
+#> 1.3696 -0.7698 1.2584 0.3222
+#> 1.3247 -0.7846 1.0718 0.5011
#> [ CPUFloatType{3,4} ][ grad_fn = <AddmmBackward0> ]The first linear layer that takes “Sepal” input
("linear1"
) creates a 2x4 tensor (batch size 2, 4 units),
@@ -690,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 70cbf6db..11e85344 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-15T14:50Z
+last_built: 2024-08-16T07: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 e2d3914f..303df410 100644
--- a/dev/reference/DataDescriptor.html
+++ b/dev/reference/DataDescriptor.html
@@ -263,14 +263,14 @@
mlr_pipeops_nn_squeeze
PipeOpTorchSqueeze
PipeOpTorchUnsqueeze
+ mlr_pipeops_nn_squeeze
PipeOpTorchSqueeze
mlr_pipeops_nn_unsqueeze
PipeOpTorchUnsqueeze
+
+ lt1 = as_lazy_tensor(torch_randn(10, 3))
materialize(lt1, rbind = TRUE)
#> torch_tensor
-#> 0.3563 1.1651 -0.2713
-#> -0.0337 -0.5055 -1.3842
-#> 1.7986 -0.1696 -0.2128
-#> -0.7038 -1.0905 -0.0278
-#> -0.5179 -0.7220 1.2683
-#> 1.1135 0.5323 0.4227
-#> -0.7047 0.0624 3.0104
-#> 0.2488 0.4392 1.2048
-#> 2.4052 1.0117 0.3947
-#> -0.6452 1.9935 -1.6847
+#> 2.6049 -1.8008 0.7110
+#> -1.9610 -0.4367 -1.0464
+#> 0.4687 0.1661 -0.7993
+#> 0.4191 1.6353 -0.3249
+#> -0.2101 -1.4185 -0.3563
+#> 1.5682 -0.8968 0.8227
+#> -0.6386 -1.0188 -0.5339
+#> -0.1097 -0.0742 -0.6809
+#> -0.4520 -0.3911 -0.1303
+#> 0.4354 -1.8564 -1.2265
#> [ CPUFloatType{10,3} ]
materialize(lt1, rbind = FALSE)
#> [[1]]
#> torch_tensor
-#> 0.3563
-#> 1.1651
-#> -0.2713
+#> 2.6049
+#> -1.8008
+#> 0.7110
#> [ CPUFloatType{3} ]
#>
#> [[2]]
#> torch_tensor
-#> 0.01 *
-#> -3.3696
-#> -50.5533
-#> -138.4212
+#> -1.9610
+#> -0.4367
+#> -1.0464
#> [ CPUFloatType{3} ]
#>
#> [[3]]
#> torch_tensor
-#> 1.7986
-#> -0.1696
-#> -0.2128
+#> 0.4687
+#> 0.1661
+#> -0.7993
#> [ CPUFloatType{3} ]
#>
#> [[4]]
#> torch_tensor
-#> -0.7038
-#> -1.0905
-#> -0.0278
+#> 0.4191
+#> 1.6353
+#> -0.3249
#> [ CPUFloatType{3} ]
#>
#> [[5]]
#> torch_tensor
-#> -0.5179
-#> -0.7220
-#> 1.2683
+#> -0.2101
+#> -1.4185
+#> -0.3563
#> [ CPUFloatType{3} ]
#>
#> [[6]]
#> torch_tensor
-#> 1.1135
-#> 0.5323
-#> 0.4227
+#> 1.5682
+#> -0.8968
+#> 0.8227
#> [ CPUFloatType{3} ]
#>
#> [[7]]
#> torch_tensor
-#> -0.7047
-#> 0.0624
-#> 3.0104
+#> -0.6386
+#> -1.0188
+#> -0.5339
#> [ CPUFloatType{3} ]
#>
#> [[8]]
#> torch_tensor
-#> 0.2488
-#> 0.4392
-#> 1.2048
+#> -0.1097
+#> -0.0742
+#> -0.6809
#> [ CPUFloatType{3} ]
#>
#> [[9]]
#> torch_tensor
-#> 2.4052
-#> 1.0117
-#> 0.3947
+#> -0.4520
+#> -0.3911
+#> -0.1303
#> [ CPUFloatType{3} ]
#>
#> [[10]]
#> torch_tensor
-#> -0.6452
-#> 1.9935
-#> -1.6847
+#> 0.4354
+#> -1.8564
+#> -1.2265
#> [ CPUFloatType{3} ]
#>
lt2 = as_lazy_tensor(torch_randn(10, 4))
@@ -220,185 +219,184 @@ Examplesmaterialize(d, rbind = TRUE)
#> $lt1
#> torch_tensor
-#> 0.3563 1.1651 -0.2713
-#> -0.0337 -0.5055 -1.3842
-#> 1.7986 -0.1696 -0.2128
-#> -0.7038 -1.0905 -0.0278
-#> -0.5179 -0.7220 1.2683
-#> 1.1135 0.5323 0.4227
-#> -0.7047 0.0624 3.0104
-#> 0.2488 0.4392 1.2048
-#> 2.4052 1.0117 0.3947
-#> -0.6452 1.9935 -1.6847
+#> 2.6049 -1.8008 0.7110
+#> -1.9610 -0.4367 -1.0464
+#> 0.4687 0.1661 -0.7993
+#> 0.4191 1.6353 -0.3249
+#> -0.2101 -1.4185 -0.3563
+#> 1.5682 -0.8968 0.8227
+#> -0.6386 -1.0188 -0.5339
+#> -0.1097 -0.0742 -0.6809
+#> -0.4520 -0.3911 -0.1303
+#> 0.4354 -1.8564 -1.2265
#> [ CPUFloatType{10,3} ]
#>
#> $lt2
#> torch_tensor
-#> -0.5594 -1.8929 1.0866 -1.8844
-#> 0.3510 -0.5164 -0.1505 0.1984
-#> 0.3853 0.6898 0.2773 0.3464
-#> -1.3875 -1.1069 -0.2861 0.2390
-#> 0.1590 1.0795 0.4727 0.0992
-#> -0.1731 0.5458 1.3633 -0.0826
-#> -0.0253 -0.4512 -0.3332 1.4013
-#> 0.0215 0.1084 1.2579 -1.5340
-#> 1.4099 -0.6246 0.5513 -0.4494
-#> -0.4884 -0.6574 -0.7872 -0.3358
+#> 0.1210 -0.1972 0.2141 0.0868
+#> 0.6636 0.1039 -1.1849 -1.8154
+#> -1.6865 -1.4639 1.8843 -1.5143
+#> 0.0242 0.9182 0.6470 0.3384
+#> 1.1215 -0.5827 1.2752 0.0877
+#> -1.5205 0.5714 -1.3324 0.3357
+#> 0.4955 1.3480 0.7111 -1.1126
+#> -0.2566 -0.4867 0.9912 -0.7515
+#> 0.5338 0.7516 -0.1660 -0.1314
+#> 0.1169 0.7748 0.6916 0.6050
#> [ CPUFloatType{10,4} ]
#>
materialize(d, rbind = FALSE)
#> $lt1
#> $lt1[[1]]
#> torch_tensor
-#> 0.3563
-#> 1.1651
-#> -0.2713
+#> 2.6049
+#> -1.8008
+#> 0.7110
#> [ CPUFloatType{3} ]
#>
#> $lt1[[2]]
#> torch_tensor
-#> 0.01 *
-#> -3.3696
-#> -50.5533
-#> -138.4212
+#> -1.9610
+#> -0.4367
+#> -1.0464
#> [ CPUFloatType{3} ]
#>
#> $lt1[[3]]
#> torch_tensor
-#> 1.7986
-#> -0.1696
-#> -0.2128
+#> 0.4687
+#> 0.1661
+#> -0.7993
#> [ CPUFloatType{3} ]
#>
#> $lt1[[4]]
#> torch_tensor
-#> -0.7038
-#> -1.0905
-#> -0.0278
+#> 0.4191
+#> 1.6353
+#> -0.3249
#> [ CPUFloatType{3} ]
#>
#> $lt1[[5]]
#> torch_tensor
-#> -0.5179
-#> -0.7220
-#> 1.2683
+#> -0.2101
+#> -1.4185
+#> -0.3563
#> [ CPUFloatType{3} ]
#>
#> $lt1[[6]]
#> torch_tensor
-#> 1.1135
-#> 0.5323
-#> 0.4227
+#> 1.5682
+#> -0.8968
+#> 0.8227
#> [ CPUFloatType{3} ]
#>
#> $lt1[[7]]
#> torch_tensor
-#> -0.7047
-#> 0.0624
-#> 3.0104
+#> -0.6386
+#> -1.0188
+#> -0.5339
#> [ CPUFloatType{3} ]
#>
#> $lt1[[8]]
#> torch_tensor
-#> 0.2488
-#> 0.4392
-#> 1.2048
+#> -0.1097
+#> -0.0742
+#> -0.6809
#> [ CPUFloatType{3} ]
#>
#> $lt1[[9]]
#> torch_tensor
-#> 2.4052
-#> 1.0117
-#> 0.3947
+#> -0.4520
+#> -0.3911
+#> -0.1303
#> [ CPUFloatType{3} ]
#>
#> $lt1[[10]]
#> torch_tensor
-#> -0.6452
-#> 1.9935
-#> -1.6847
+#> 0.4354
+#> -1.8564
+#> -1.2265
#> [ CPUFloatType{3} ]
#>
#>
#> $lt2
#> $lt2[[1]]
#> torch_tensor
-#> -0.5594
-#> -1.8929
-#> 1.0866
-#> -1.8844
+#> 0.1210
+#> -0.1972
+#> 0.2141
+#> 0.0868
#> [ CPUFloatType{4} ]
#>
#> $lt2[[2]]
#> torch_tensor
-#> 0.3510
-#> -0.5164
-#> -0.1505
-#> 0.1984
+#> 0.6636
+#> 0.1039
+#> -1.1849
+#> -1.8154
#> [ CPUFloatType{4} ]
#>
#> $lt2[[3]]
#> torch_tensor
-#> 0.3853
-#> 0.6898
-#> 0.2773
-#> 0.3464
+#> -1.6865
+#> -1.4639
+#> 1.8843
+#> -1.5143
#> [ CPUFloatType{4} ]
#>
#> $lt2[[4]]
#> torch_tensor
-#> -1.3875
-#> -1.1069
-#> -0.2861
-#> 0.2390
+#> 0.0242
+#> 0.9182
+#> 0.6470
+#> 0.3384
#> [ CPUFloatType{4} ]
#>
#> $lt2[[5]]
#> torch_tensor
-#> 0.1590
-#> 1.0795
-#> 0.4727
-#> 0.0992
+#> 1.1215
+#> -0.5827
+#> 1.2752
+#> 0.0877
#> [ CPUFloatType{4} ]
#>
#> $lt2[[6]]
#> torch_tensor
-#> -0.1731
-#> 0.5458
-#> 1.3633
-#> -0.0826
+#> -1.5205
+#> 0.5714
+#> -1.3324
+#> 0.3357
#> [ CPUFloatType{4} ]
#>
#> $lt2[[7]]
#> torch_tensor
-#> -0.0253
-#> -0.4512
-#> -0.3332
-#> 1.4013
+#> 0.4955
+#> 1.3480
+#> 0.7111
+#> -1.1126
#> [ CPUFloatType{4} ]
#>
#> $lt2[[8]]
#> torch_tensor
-#> 0.0215
-#> 0.1084
-#> 1.2579
-#> -1.5340
+#> -0.2566
+#> -0.4867
+#> 0.9912
+#> -0.7515
#> [ CPUFloatType{4} ]
#>
#> $lt2[[9]]
#> torch_tensor
-#> 1.4099
-#> -0.6246
-#> 0.5513
-#> -0.4494
+#> 0.5338
+#> 0.7516
+#> -0.1660
+#> -0.1314
#> [ CPUFloatType{4} ]
#>
#> $lt2[[10]]
#> torch_tensor
-#> -0.4884
-#> -0.6574
-#> -0.7872
-#> -0.3358
+#> 0.1169
+#> 0.7748
+#> 0.6916
+#> 0.6050
#> [ CPUFloatType{4} ]
#>
#>
diff --git a/dev/reference/mlr3torch-package.html b/dev/reference/mlr3torch-package.html
index d0b5cc10..f3f82f8a 100644
--- a/dev/reference/mlr3torch-package.html
+++ b/dev/reference/mlr3torch-package.html
@@ -1,7 +1,5 @@
-mlr3torch: Deep Learning with 'mlr3' — mlr3torch-package • mlr3torch
+mlr3torch: Deep Learning with 'mlr3' — mlr3torch-package • mlr3torch
Skip to contents
@@ -53,8 +51,7 @@
Deep Learning library that extends the mlr3 framework by building upon the 'torch' package. It allows to conveniently build, train, and evaluate deep learning models without having to worry about low level details. Custom architectures can be created using the graph language defined in 'mlr3pipelines'.
+Deep Learning library that extends the mlr3 framework by building upon the 'torch' package. It allows to conveniently build, train, and evaluate deep learning models without having to worry about low level details. Custom architectures can be created using the graph language defined in 'mlr3pipelines'.