diff --git a/dev/articles/callbacks.html b/dev/articles/callbacks.html index c44ebbbc..4f0ed600 100644 --- a/dev/articles/callbacks.html +++ b/dev/articles/callbacks.html @@ -240,7 +240,7 @@
torch
Primerinput = torch_randn(2, 3)
input
#> torch_tensor
-#> 0.3477 0.3774 -0.0754
-#> 1.2803 -0.4639 0.2129
+#> 0.8906 1.4203 0.1197
+#> -2.1628 0.7562 -0.7273
#> [ CPUFloatType{2,3} ]
A nn_module
is constructed from a
nn_module_generator
. nn_linear
is one of the
@@ -132,8 +132,8 @@
torch
Primeroutput = module_1(input)
output
#> torch_tensor
-#> 0.1380 -0.4675 -0.1241 -0.3826
-#> 0.0990 -0.9637 -0.1981 0.4921
+#> 0.9569 -0.7642 -1.2214 0.1804
+#> 0.9405 0.0187 0.8337 0.0819
#> [ CPUFloatType{2,4} ][ grad_fn = <AddmmBackward0> ]
A neural network with one (4-unit) hidden layer and two outputs needs the following ingredients
@@ -149,8 +149,8 @@torch
Primeroutput = softmax(output)
output
#> torch_tensor
-#> 0.3973 0.3557 0.2470
-#> 0.4165 0.3569 0.2266
+#> 0.2596 0.5336 0.2068
+#> 0.2387 0.5439 0.2174
#> [ 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
@@ -211,8 +211,8 @@
While this object allows to easily perform a forward pass, it does
not inherit from nn_module
, which is useful for various
@@ -260,8 +260,8 @@
graph_module(input)
#> torch_tensor
-#> 0.3973 0.3557 0.2470
-#> 0.4165 0.3569 0.2266
+#> 0.2596 0.5336 0.2068
+#> 0.2387 0.5439 0.2174
#> [ CPUFloatType{2,3} ][ grad_fn = <SoftmaxBackward0> ]
ModelDescriptor
to
small_module(batch$x[[1]])
#> torch_tensor
-#> -1.4630 1.8896 -0.6630 -0.1557
-#> -1.6097 1.6810 -0.5001 -0.2267
-#> -1.3823 1.7085 -0.6266 -0.1249
+#> -2.3277 -5.2875 -2.9304 -2.7021
+#> -2.0745 -4.9174 -2.6990 -2.7107
+#> -2.1747 -4.8735 -2.6649 -2.5124
#> [ CPUFloatType{3,4} ][ grad_fn = <AddmmBackward0> ]The first linear layer that takes “Sepal” input
("linear1"
) creates a 2x4 tensor (batch size 2, 4 units),
@@ -702,14 +702,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/articles/pipeop_torch.html b/dev/articles/pipeop_torch.html
index 5d51dda6..8e131634 100644
--- a/dev/articles/pipeop_torch.html
+++ b/dev/articles/pipeop_torch.html
@@ -107,7 +107,7 @@
In this vignette, we will show how to build neural network
architectures as mlr3pipelines::Graphs
s. We will create a
-simple CNN for the tiny-imagenet task, which is a subst of well-known
+simple CNN for the tiny-imagenet task, which is a subset of well-known
Imagenet benchmark.
library(mlr3torch)
@@ -185,7 +185,7 @@
checkpoint = tempfile()
architecture = architecture %>>%
po("torch_loss", t_loss("cross_entropy")) %>>%
- po("torch_optimizer", t_opt("sgd")) %>>%
+ po("torch_optimizer", t_opt("sgd", lr=0.01)) %>>%
po("torch_callbacks",
t_clbk("checkpoint", freq = 20, path = checkpoint)) %>>%
po("torch_model_classif",
diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml
index 07315df2..76ff16a8 100644
--- a/dev/pkgdown.yml
+++ b/dev/pkgdown.yml
@@ -15,7 +15,7 @@ articles:
articles/tabular_learner_list: tabular_learner_list.html
articles/task_list: task_list.html
articles/vision_learner_list: vision_learner_list.html
-last_built: 2025-02-13T17:57Z
+last_built: 2025-02-17T16:39Z
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 91eca90e..5dced718 100644
--- a/dev/reference/DataDescriptor.html
+++ b/dev/reference/DataDescriptor.html
@@ -276,14 +276,14 @@ Examples#> <DataDescriptor: 1 ops>
#> * dataset_shapes: [x: (NA,3,3)]
#> * input_map: (x) -> Graph
-#> * pointer: nop.1f415a.x.output
+#> * pointer: nop.91aca9.x.output
#> * shape: [(NA,3,3)]
# is the same as using the converter:
as_data_descriptor(ds, list(x = c(NA, 3, 3)))
#> <DataDescriptor: 1 ops>
#> * dataset_shapes: [x: (NA,3,3)]
#> * input_map: (x) -> Graph
-#> * pointer: nop.1f415a.x.output
+#> * pointer: nop.91aca9.x.output
#> * shape: [(NA,3,3)]
lt1 = as_lazy_tensor(torch_randn(10, 3))
materialize(lt1, rbind = TRUE)
#> torch_tensor
-#> 1.1753 1.5500 -2.9411
-#> 0.0725 0.7722 0.2219
-#> 0.4078 -0.4639 -0.7275
-#> -0.3355 0.3379 -1.1056
-#> -1.1957 1.0696 -0.9457
-#> 0.2183 -0.0484 -1.0672
-#> 2.5369 -1.0983 1.3079
-#> -1.4412 1.6057 1.6115
-#> 1.1829 -0.8402 0.5994
-#> 1.4231 -0.1819 1.1314
+#> 1.7798 -0.5249 -1.2814
+#> 0.8924 0.4180 0.1037
+#> -0.6312 0.2669 -1.0117
+#> 1.2335 0.8122 0.0740
+#> 0.2550 -0.5285 -0.2936
+#> -0.9206 1.0392 -0.4099
+#> -1.5834 0.8562 -0.2827
+#> -1.6057 0.4856 1.0247
+#> 0.0227 0.7861 -0.5878
+#> -1.3147 -1.4642 -1.5364
#> [ CPUFloatType{10,3} ]
materialize(lt1, rbind = FALSE)
#> [[1]]
#> torch_tensor
-#> 1.1753
-#> 1.5500
-#> -2.9411
+#> 1.7798
+#> -0.5249
+#> -1.2814
#> [ CPUFloatType{3} ]
#>
#> [[2]]
#> torch_tensor
-#> 0.0725
-#> 0.7722
-#> 0.2219
+#> 0.8924
+#> 0.4180
+#> 0.1037
#> [ CPUFloatType{3} ]
#>
#> [[3]]
#> torch_tensor
-#> 0.4078
-#> -0.4639
-#> -0.7275
+#> -0.6312
+#> 0.2669
+#> -1.0117
#> [ CPUFloatType{3} ]
#>
#> [[4]]
#> torch_tensor
-#> -0.3355
-#> 0.3379
-#> -1.1056
+#> 1.2335
+#> 0.8122
+#> 0.0740
#> [ CPUFloatType{3} ]
#>
#> [[5]]
#> torch_tensor
-#> -1.1957
-#> 1.0696
-#> -0.9457
+#> 0.2550
+#> -0.5285
+#> -0.2936
#> [ CPUFloatType{3} ]
#>
#> [[6]]
#> torch_tensor
-#> 0.2183
-#> -0.0484
-#> -1.0672
+#> -0.9206
+#> 1.0392
+#> -0.4099
#> [ CPUFloatType{3} ]
#>
#> [[7]]
#> torch_tensor
-#> 2.5369
-#> -1.0983
-#> 1.3079
+#> -1.5834
+#> 0.8562
+#> -0.2827
#> [ CPUFloatType{3} ]
#>
#> [[8]]
#> torch_tensor
-#> -1.4412
-#> 1.6057
-#> 1.6115
+#> -1.6057
+#> 0.4856
+#> 1.0247
#> [ CPUFloatType{3} ]
#>
#> [[9]]
#> torch_tensor
-#> 1.1829
-#> -0.8402
-#> 0.5994
+#> 0.0227
+#> 0.7861
+#> -0.5878
#> [ CPUFloatType{3} ]
#>
#> [[10]]
#> torch_tensor
-#> 1.4231
-#> -0.1819
-#> 1.1314
+#> -1.3147
+#> -1.4642
+#> -1.5364
#> [ CPUFloatType{3} ]
#>
lt2 = as_lazy_tensor(torch_randn(10, 4))
@@ -232,184 +232,184 @@ Examplesmaterialize(d, rbind = TRUE)
#> $lt1
#> torch_tensor
-#> 1.1753 1.5500 -2.9411
-#> 0.0725 0.7722 0.2219
-#> 0.4078 -0.4639 -0.7275
-#> -0.3355 0.3379 -1.1056
-#> -1.1957 1.0696 -0.9457
-#> 0.2183 -0.0484 -1.0672
-#> 2.5369 -1.0983 1.3079
-#> -1.4412 1.6057 1.6115
-#> 1.1829 -0.8402 0.5994
-#> 1.4231 -0.1819 1.1314
+#> 1.7798 -0.5249 -1.2814
+#> 0.8924 0.4180 0.1037
+#> -0.6312 0.2669 -1.0117
+#> 1.2335 0.8122 0.0740
+#> 0.2550 -0.5285 -0.2936
+#> -0.9206 1.0392 -0.4099
+#> -1.5834 0.8562 -0.2827
+#> -1.6057 0.4856 1.0247
+#> 0.0227 0.7861 -0.5878
+#> -1.3147 -1.4642 -1.5364
#> [ CPUFloatType{10,3} ]
#>
#> $lt2
#> torch_tensor
-#> 0.4379 0.9216 -0.6615 0.4703
-#> 0.6167 -0.3784 -0.1941 -0.2703
-#> -1.9607 0.0528 -0.4324 -1.6075
-#> -1.6543 -0.0203 0.2305 -0.3047
-#> -0.8483 -0.1548 0.6345 -1.1538
-#> -0.2261 -1.8694 0.7451 1.9836
-#> -1.1269 -1.6480 1.0258 -1.1255
-#> -0.1671 0.0031 0.2786 0.8140
-#> -0.8772 1.3573 0.7908 1.7687
-#> 1.6323 0.0763 -0.5912 0.8654
+#> 0.4602 -0.7110 1.1461 -0.9731
+#> -2.7748 0.3840 -0.7011 -0.6743
+#> -0.4695 0.8064 0.4880 -0.1689
+#> -0.5304 0.4486 -0.8541 1.0929
+#> 1.1177 0.0173 0.4548 1.1256
+#> 0.7196 -2.0267 -0.7399 0.4701
+#> -1.4550 0.0642 0.9921 1.7454
+#> -0.4955 0.4125 0.2198 -0.4875
+#> -0.5512 -0.5807 -0.3708 -2.9101
+#> 1.8886 -0.0684 1.8151 0.5676
#> [ CPUFloatType{10,4} ]
#>
materialize(d, rbind = FALSE)
#> $lt1
#> $lt1[[1]]
#> torch_tensor
-#> 1.1753
-#> 1.5500
-#> -2.9411
+#> 1.7798
+#> -0.5249
+#> -1.2814
#> [ CPUFloatType{3} ]
#>
#> $lt1[[2]]
#> torch_tensor
-#> 0.0725
-#> 0.7722
-#> 0.2219
+#> 0.8924
+#> 0.4180
+#> 0.1037
#> [ CPUFloatType{3} ]
#>
#> $lt1[[3]]
#> torch_tensor
-#> 0.4078
-#> -0.4639
-#> -0.7275
+#> -0.6312
+#> 0.2669
+#> -1.0117
#> [ CPUFloatType{3} ]
#>
#> $lt1[[4]]
#> torch_tensor
-#> -0.3355
-#> 0.3379
-#> -1.1056
+#> 1.2335
+#> 0.8122
+#> 0.0740
#> [ CPUFloatType{3} ]
#>
#> $lt1[[5]]
#> torch_tensor
-#> -1.1957
-#> 1.0696
-#> -0.9457
+#> 0.2550
+#> -0.5285
+#> -0.2936
#> [ CPUFloatType{3} ]
#>
#> $lt1[[6]]
#> torch_tensor
-#> 0.2183
-#> -0.0484
-#> -1.0672
+#> -0.9206
+#> 1.0392
+#> -0.4099
#> [ CPUFloatType{3} ]
#>
#> $lt1[[7]]
#> torch_tensor
-#> 2.5369
-#> -1.0983
-#> 1.3079
+#> -1.5834
+#> 0.8562
+#> -0.2827
#> [ CPUFloatType{3} ]
#>
#> $lt1[[8]]
#> torch_tensor
-#> -1.4412
-#> 1.6057
-#> 1.6115
+#> -1.6057
+#> 0.4856
+#> 1.0247
#> [ CPUFloatType{3} ]
#>
#> $lt1[[9]]
#> torch_tensor
-#> 1.1829
-#> -0.8402
-#> 0.5994
+#> 0.0227
+#> 0.7861
+#> -0.5878
#> [ CPUFloatType{3} ]
#>
#> $lt1[[10]]
#> torch_tensor
-#> 1.4231
-#> -0.1819
-#> 1.1314
+#> -1.3147
+#> -1.4642
+#> -1.5364
#> [ CPUFloatType{3} ]
#>
#>
#> $lt2
#> $lt2[[1]]
#> torch_tensor
-#> 0.4379
-#> 0.9216
-#> -0.6615
-#> 0.4703
+#> 0.4602
+#> -0.7110
+#> 1.1461
+#> -0.9731
#> [ CPUFloatType{4} ]
#>
#> $lt2[[2]]
#> torch_tensor
-#> 0.6167
-#> -0.3784
-#> -0.1941
-#> -0.2703
+#> -2.7748
+#> 0.3840
+#> -0.7011
+#> -0.6743
#> [ CPUFloatType{4} ]
#>
#> $lt2[[3]]
#> torch_tensor
-#> -1.9607
-#> 0.0528
-#> -0.4324
-#> -1.6075
+#> -0.4695
+#> 0.8064
+#> 0.4880
+#> -0.1689
#> [ CPUFloatType{4} ]
#>
#> $lt2[[4]]
#> torch_tensor
-#> -1.6543
-#> -0.0203
-#> 0.2305
-#> -0.3047
+#> -0.5304
+#> 0.4486
+#> -0.8541
+#> 1.0929
#> [ CPUFloatType{4} ]
#>
#> $lt2[[5]]
#> torch_tensor
-#> -0.8483
-#> -0.1548
-#> 0.6345
-#> -1.1538
+#> 1.1177
+#> 0.0173
+#> 0.4548
+#> 1.1256
#> [ CPUFloatType{4} ]
#>
#> $lt2[[6]]
#> torch_tensor
-#> -0.2261
-#> -1.8694
-#> 0.7451
-#> 1.9836
+#> 0.7196
+#> -2.0267
+#> -0.7399
+#> 0.4701
#> [ CPUFloatType{4} ]
#>
#> $lt2[[7]]
#> torch_tensor
-#> -1.1269
-#> -1.6480
-#> 1.0258
-#> -1.1255
+#> -1.4550
+#> 0.0642
+#> 0.9921
+#> 1.7454
#> [ CPUFloatType{4} ]
#>
#> $lt2[[8]]
#> torch_tensor
-#> -0.1671
-#> 0.0031
-#> 0.2786
-#> 0.8140
+#> -0.4955
+#> 0.4125
+#> 0.2198
+#> -0.4875
#> [ CPUFloatType{4} ]
#>
#> $lt2[[9]]
#> torch_tensor
-#> -0.8772
-#> 1.3573
-#> 0.7908
-#> 1.7687
+#> -0.5512
+#> -0.5807
+#> -0.3708
+#> -2.9101
#> [ CPUFloatType{4} ]
#>
#> $lt2[[10]]
#> torch_tensor
-#> 1.6323
-#> 0.0763
-#> -0.5912
-#> 0.8654
+#> 1.8886
+#> -0.0684
+#> 1.8151
+#> 0.5676
#> [ CPUFloatType{4} ]
#>
#>
diff --git a/dev/reference/mlr_callback_set.progress.html b/dev/reference/mlr_callback_set.progress.html
index 5de98110..875021e3 100644
--- a/dev/reference/mlr_callback_set.progress.html
+++ b/dev/reference/mlr_callback_set.progress.html
@@ -184,7 +184,7 @@ Examples)
learner$train(task)
-#> Epoch 1 started (2025-02-13 17:57:41)
+#> Epoch 1 started (2025-02-17 16:39:26)
#>
#> [Summary epoch 1]
#> ------------------
@@ -193,7 +193,7 @@ Examples#> * classif.ce = 0.69
#> Measures (Valid):
#> * classif.ce = 0.62
-#> Epoch 2 started (2025-02-13 17:57:42)
+#> Epoch 2 started (2025-02-17 16:39:26)
#>
#> [Summary epoch 2]
#> ------------------
@@ -202,7 +202,7 @@ Examples#> * classif.ce = 0.69
#> Measures (Valid):
#> * classif.ce = 0.56
-#> Epoch 3 started (2025-02-13 17:57:42)
+#> Epoch 3 started (2025-02-17 16:39:26)
#>
#> [Summary epoch 3]
#> ------------------
@@ -211,7 +211,7 @@ Examples#> * classif.ce = 0.45
#> Measures (Valid):
#> * classif.ce = 0.44
-#> Epoch 4 started (2025-02-13 17:57:43)
+#> Epoch 4 started (2025-02-17 16:39:27)
#>
#> [Summary epoch 4]
#> ------------------
@@ -220,7 +220,7 @@ Examples#> * classif.ce = 0.43
#> Measures (Valid):
#> * classif.ce = 0.49
-#> Epoch 5 started (2025-02-13 17:57:43)
+#> Epoch 5 started (2025-02-17 16:39:27)
#>
#> [Summary epoch 5]
#> ------------------
@@ -229,7 +229,7 @@ Examples#> * classif.ce = 0.49
#> Measures (Valid):
#> * classif.ce = 0.60
-#> Finished training for 5 epochs (2025-02-13 17:57:44)
+#> Finished training for 5 epochs (2025-02-17 16:39:28)