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 @@

Writing a Custom Logger## load_state_dict: function (state_dict) ## on_before_valid: function () ## on_batch_end: function () -## Parent env: <environment: 0x56423e26a330> +## Parent env: <environment: 0x563c298ba300> ## Locked objects: FALSE ## Locked class: FALSE ## Portable: TRUE diff --git a/dev/articles/internals_pipeop_torch.html b/dev/articles/internals_pipeop_torch.html index f8a02acb..f1cf446d 100644 --- a/dev/articles/internals_pipeop_torch.html +++ b/dev/articles/internals_pipeop_torch.html @@ -119,8 +119,8 @@

A 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 @@

A 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 @@

A 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.

@@ -185,8 +185,8 @@

Neural Networks as Graphsoutput = po_module_1$train(list(input))[[1]] 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> ]

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 @@

Neural Networks as Graphsoutput = module_graph$train(input)[[1]] 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> ]

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 @@

Neural Networks as Graphs
 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> ]
@@ -378,8 +378,8 @@

small_module(input) #> torch_tensor -#> -0.5510 -0.2563 -0.2200 0.2093 -#> -0.1281 -0.2880 -0.5248 0.6039 +#> -0.6542 -1.3207 -0.4404 -1.2633 +#> 0.2106 0.7202 1.2570 0.0729 #> [ CPUFloatType{2,4} ][ grad_fn = <AddmmBackward0> ]

@@ -443,9 +443,9 @@

Using 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 @@

Building more interesting NNsiris_module$graph$pipeops$linear1$.result #> $output #> torch_tensor -#> 2.9429 0.1877 -1.4562 -3.2100 -#> 2.6257 0.3713 -1.2916 -2.8127 +#> 3.0879 1.9481 2.9554 2.9748 +#> 2.7494 1.7619 2.6595 2.7932 #> [ CPUFloatType{2,4} ][ grad_fn = <AddmmBackward0> ] iris_module$graph$pipeops$linear3$.result #> $output #> torch_tensor -#> 0.6678 0.1714 -0.0278 -0.2963 0.1148 -#> 0.6678 0.1714 -0.0278 -0.2963 0.1148 +#> 0.7149 -0.2495 -0.7778 0.3896 -0.4277 +#> 0.7149 -0.2495 -0.7778 0.3896 -0.4277 #> [ CPUFloatType{2,5} ][ grad_fn = <AddmmBackward0> ]

We observe that the po("nn_merge_cat") concatenates these, as expected:

@@ -717,8 +717,8 @@

Building more interesting NNsiris_module$graph$pipeops$nn_merge_cat$.result #> $output #> torch_tensor -#> 2.9429 0.1877 -1.4562 -3.2100 0.6678 0.1714 -0.0278 -0.2963 0.1148 -#> 2.6257 0.3713 -1.2916 -2.8127 0.6678 0.1714 -0.0278 -0.2963 0.1148 +#> 3.0879 1.9481 2.9554 2.9748 0.7149 -0.2495 -0.7778 0.3896 -0.4277 +#> 2.7494 1.7619 2.6595 2.7932 0.7149 -0.2495 -0.7778 0.3896 -0.4277 #> [ CPUFloatType{2,9} ][ grad_fn = <CatBackward0> ] diff --git a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-37-1.png b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-37-1.png index be2eb9ec..e39c515e 100644 Binary files a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-37-1.png and b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-37-1.png differ diff --git a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-42-1.png b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-42-1.png index 10ac927d..f196230e 100644 Binary files a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-42-1.png and b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-42-1.png differ diff --git a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-46-1.png b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-46-1.png index 84523afb..64268e01 100644 Binary files a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-46-1.png and b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-46-1.png differ diff --git a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-50-1.png b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-50-1.png index fe9aa98c..ac0b80ad 100644 Binary files a/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-50-1.png and b/dev/articles/internals_pipeop_torch_files/figure-html/unnamed-chunk-50-1.png differ diff --git a/dev/articles/lazy_tensor.html b/dev/articles/lazy_tensor.html index 00dc9888..1bf7ca82 100644 --- a/dev/articles/lazy_tensor.html +++ b/dev/articles/lazy_tensor.html @@ -402,7 +402,7 @@

Digging Into Internals#> <DataDescriptor: 1 ops> #> * dataset_shapes: [x: (NA,1)] #> * input_map: (x) -> Graph -#> * pointer: nop.3904f4.x.output +#> * pointer: nop.b1079f.x.output #> * shape: [(NA,1)]

The printed output of the data descriptor informs us about: