diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/.nojekyll @@ -0,0 +1 @@ + diff --git a/404.html b/404.html new file mode 100644 index 0000000000000000000000000000000000000000..45ba8412db421bf323febc0880503eb39bbe8777 --- /dev/null +++ b/404.html @@ -0,0 +1,191 @@ + + + + + + + + +Page not found (404) • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +Content not found. Please use links in the navbar. + +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/CONTRIBUTING.html b/CONTRIBUTING.html new file mode 100644 index 0000000000000000000000000000000000000000..a8f8444daadb10448c824139119791b8080e15c1 --- /dev/null +++ b/CONTRIBUTING.html @@ -0,0 +1,228 @@ + + + + + + + + +Contributing to torch • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+ +

This outlines how to propose a change to torch. For more detailed info about contributing to this, and other tidyverse packages, please see the development contributing guide.

+
+

+Fixing typos

+

You can fix typos, spelling mistakes, or grammatical errors in the documentation directly using the GitHub web interface, as long as the changes are made in the source file. This generally means you’ll need to edit roxygen2 comments in an .R, not a .Rd file. You can find the .R file that generates the .Rd by reading the comment in the first line.

+

See also the [Documentation] section.

+
+
+

+Filing bugs

+

If you find a bug in torch please open an issue here. Please, provide detailed information on how to reproduce the bug. It would be great to also provide a reprex.

+
+
+

+Feature requests

+

Feel free to open issues here and add the feature-request tag. Try searching if there’s already an open issue for your feature-request, in this case it’s better to comment or upvote it intead of opening a new one.

+
+
+

+Examples

+

We welcome contributed examples. feel free to open a PR with new examples. The should be placed in the vignettes/examples folder.

+

The examples should be an .R file and a .Rmd file with the same name that just renders the code.

+

See mnist-mlp.R and mnist-mlp.Rmd

+

One must be able to run the example without manually downloading any dataset/file. You should also add an entry to the _pkgdown.yaml file.

+
+
+

+Code contributions

+

We have many open issues in the github repo if there’s one item that you want to work on, you can comment on it an ask for directions.

+
+
+

+Documentation

+

We use roxygen2 to generate the documentation. IN order to update the docs, edit the file in the R directory. To regenerate and preview the docs, use the custom tools/document.R script, as we need to patch roxygen2 to avoid running the examples on CRAN.

+
+
+ +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/LICENSE-text.html b/LICENSE-text.html new file mode 100644 index 0000000000000000000000000000000000000000..c6a949abfc900c663a1132e60be0df4fc9700b5e --- /dev/null +++ b/LICENSE-text.html @@ -0,0 +1,193 @@ + + + + + + + + +License • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
YEAR: 2020
+COPYRIGHT HOLDER: Daniel Falbel
+
+ +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/LICENSE.html b/LICENSE.html new file mode 100644 index 0000000000000000000000000000000000000000..dd73ac7435a827d588f3b74bc37436c07db1e1e4 --- /dev/null +++ b/LICENSE.html @@ -0,0 +1,197 @@ + + + + + + + + +MIT License • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+ +

Copyright (c) 2020 Daniel Falbel

+

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

+

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

+

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+
+ +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/articles/examples/mnist-cnn.html b/articles/examples/mnist-cnn.html new file mode 100644 index 0000000000000000000000000000000000000000..186ea79333d0cb7f9358f2d7cd306282b42ac4ef --- /dev/null +++ b/articles/examples/mnist-cnn.html @@ -0,0 +1,215 @@ + + + + + + + +mnist-cnn • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
dir <- "~/Downloads/mnist"
+
+ds <- mnist_dataset(
+  dir,
+  download = TRUE,
+  transform = function(x) {
+    x <- x$to(dtype = torch_float())/256
+    x[newaxis,..]
+  }
+)
+dl <- dataloader(ds, batch_size = 32, shuffle = TRUE)
+
+net <- nn_module(
+  "Net",
+  initialize = function() {
+    self$conv1 <- nn_conv2d(1, 32, 3, 1)
+    self$conv2 <- nn_conv2d(32, 64, 3, 1)
+    self$dropout1 <- nn_dropout2d(0.25)
+    self$dropout2 <- nn_dropout2d(0.5)
+    self$fc1 <- nn_linear(9216, 128)
+    self$fc2 <- nn_linear(128, 10)
+  },
+  forward = function(x) {
+    x <- self$conv1(x)
+    x <- nnf_relu(x)
+    x <- self$conv2(x)
+    x <- nnf_relu(x)
+    x <- nnf_max_pool2d(x, 2)
+    x <- self$dropout1(x)
+    x <- torch_flatten(x, start_dim = 2)
+    x <- self$fc1(x)
+    x <- nnf_relu(x)
+    x <- self$dropout2(x)
+    x <- self$fc2(x)
+    output <- nnf_log_softmax(x, dim=1)
+    output
+  }
+)
+
+model <- net()
+optimizer <- optim_sgd(model$parameters, lr = 0.01)
+
+epochs <- 10
+
+for (epoch in 1:10) {
+
+  pb <- progress::progress_bar$new(
+    total = length(dl),
+    format = "[:bar] :eta Loss: :loss"
+  )
+  l <- c()
+
+  for (b in enumerate(dl)) {
+    optimizer$zero_grad()
+    output <- model(b[[1]])
+    loss <- nnf_nll_loss(output, b[[2]])
+    loss$backward()
+    optimizer$step()
+    l <- c(l, loss$item())
+    pb$tick(tokens = list(loss = mean(l)))
+  }
+
+  cat(sprintf("Loss at epoch %d: %3f\n", epoch, mean(l)))
+}
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/examples/mnist-cnn_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/examples/mnist-cnn_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/examples/mnist-cnn_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/articles/examples/mnist-dcgan.html b/articles/examples/mnist-dcgan.html new file mode 100644 index 0000000000000000000000000000000000000000..a4c94ca15edb81dbace9f0bba0fbda6e1be35a01 --- /dev/null +++ b/articles/examples/mnist-dcgan.html @@ -0,0 +1,296 @@ + + + + + + + +mnist-dcgan • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
library(torch)
+
+dir <- "~/Downloads/mnist"
+
+ds <- mnist_dataset(
+  dir,
+  download = TRUE,
+  transform = function(x) {
+    x <- x$to(dtype = torch_float())/256
+    x <- 2*(x - 0.5)
+    x[newaxis,..]
+  }
+)
+dl <- dataloader(ds, batch_size = 32, shuffle = TRUE)
+
+generator <- nn_module(
+  "generator",
+  initialize = function(latent_dim, out_channels) {
+    self$main <- nn_sequential(
+      nn_conv_transpose2d(latent_dim, 512, kernel_size = 4,
+                          stride = 1, padding = 0, bias = FALSE),
+      nn_batch_norm2d(512),
+      nn_relu(),
+      nn_conv_transpose2d(512, 256, kernel_size = 4,
+                          stride = 2, padding = 1, bias = FALSE),
+      nn_batch_norm2d(256),
+      nn_relu(),
+      nn_conv_transpose2d(256, 128, kernel_size = 4,
+                          stride = 2, padding = 1, bias = FALSE),
+      nn_batch_norm2d(128),
+      nn_relu(),
+      nn_conv_transpose2d(128, out_channels, kernel_size = 4,
+                          stride = 2, padding = 3, bias = FALSE),
+      nn_tanh()
+    )
+  },
+  forward = function(input) {
+    self$main(input)
+  }
+)
+
+discriminator <- nn_module(
+  "discriminator",
+  initialize = function(in_channels) {
+    self$main <- nn_sequential(
+      nn_conv2d(in_channels, 16, kernel_size = 4, stride = 2, padding = 1, bias = FALSE),
+      nn_leaky_relu(0.2, inplace = TRUE),
+      nn_conv2d(16, 32, kernel_size = 4, stride = 2, padding = 1, bias = FALSE),
+      nn_batch_norm2d(32),
+      nn_leaky_relu(0.2, inplace = TRUE),
+      nn_conv2d(32, 64, kernel_size = 4, stride = 2, padding = 1, bias = FALSE),
+      nn_batch_norm2d(64),
+      nn_leaky_relu(0.2, inplace = TRUE),
+      nn_conv2d(64, 128, kernel_size = 4, stride = 2, padding = 1, bias = FALSE),
+      nn_leaky_relu(0.2, inplace = TRUE)
+    )
+    self$linear <- nn_linear(128, 1)
+    self$sigmoid <- nn_sigmoid()
+  },
+  forward = function(input) {
+    x <- self$main(input)
+    x <- torch_flatten(x, start_dim = 2)
+    x <- self$linear(x)
+    self$sigmoid(x)
+  }
+)
+
+plot_gen <- function(noise) {
+  img <- G(noise)
+  img <- img$cpu()
+  img <- img[1,1,,,newaxis]/2 + 0.5
+  img <- torch_stack(list(img, img, img), dim = 2)[..,1]
+  img <- as.raster(as_array(img))
+  plot(img)
+}
+
+device <- torch_device(ifelse(cuda_is_available(),  "cuda", "cpu"))
+
+G <- generator(latent_dim = 100, out_channels = 1)
+D <- discriminator(in_channels = 1)
+
+init_weights <- function(m) {
+  if (grepl("conv", m$.classes[[1]])) {
+    nn_init_normal_(m$weight$data(), 0.0, 0.02)
+  } else if (grepl("batch_norm", m$.classes[[1]])) {
+    nn_init_normal_(m$weight$data(), 1.0, 0.02)
+    nn_init_constant_(m$bias$data(), 0)
+  }
+}
+
+G[[1]]$apply(init_weights)
+D[[1]]$apply(init_weights)
+
+G$to(device = device)
+D$to(device = device)
+
+G_optimizer <- optim_adam(G$parameters, lr = 2 * 1e-4, betas = c(0.5, 0.999))
+D_optimizer <- optim_adam(D$parameters, lr = 2 * 1e-4, betas = c(0.5, 0.999))
+
+fixed_noise <- torch_randn(1, 100, 1, 1, device = device)
+
+loss <- nn_bce_loss()
+
+for (epoch in 1:10) {
+
+  pb <- progress::progress_bar$new(
+    total = length(dl),
+    format = "[:bar] :eta Loss D: :lossd Loss G: :lossg"
+  )
+  lossg <- c()
+  lossd <- c()
+
+  for (b in enumerate(dl)) {
+
+    y_real <- torch_ones(32, device = device)
+    y_fake <- torch_zeros(32, device = device)
+
+    noise <- torch_randn(32, 100, 1, 1, device = device)
+    fake <- G(noise)
+
+    img <- b[[1]]$to(device = device)
+
+    # train the discriminator ---
+    D_loss <- loss(D(img), y_real) + loss(D(fake$detach()), y_fake)
+
+    D_optimizer$zero_grad()
+    D_loss$backward()
+    D_optimizer$step()
+
+    # train the generator ---
+
+    G_loss <- loss(D(fake), y_real)
+
+    G_optimizer$zero_grad()
+    G_loss$backward()
+    G_optimizer$step()
+
+    lossd <- c(lossd, D_loss$item())
+    lossg <- c(lossg, G_loss$item())
+    pb$tick(tokens = list(lossd = mean(lossd), lossg = mean(lossg)))
+  }
+  plot_gen(fixed_noise)
+
+  cat(sprintf("Epoch %d - Loss D: %3f Loss G: %3f\n", epoch, mean(lossd), mean(lossg)))
+}
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/examples/mnist-dcgan_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/examples/mnist-dcgan_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/examples/mnist-dcgan_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/articles/examples/mnist-mlp.html b/articles/examples/mnist-mlp.html new file mode 100644 index 0000000000000000000000000000000000000000..a374b9a808702e43b3bb791951a10189b4fcfd05 --- /dev/null +++ b/articles/examples/mnist-mlp.html @@ -0,0 +1,203 @@ + + + + + + + +mnist-mlp • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
dir <- "~/Downloads/mnist"
+
+ds <- mnist_dataset(
+  dir,
+  download = TRUE,
+  transform = function(x) {
+    x$to(dtype = torch_float())/256
+  }
+)
+dl <- dataloader(ds, batch_size = 32, shuffle = TRUE)
+
+net <- nn_module(
+  "Net",
+  initialize = function() {
+    self$fc1 <- nn_linear(784, 128)
+    self$fc2 <- nn_linear(128, 10)
+  },
+  forward = function(x) {
+    x %>%
+      torch_flatten(start_dim = 2) %>%
+      self$fc1() %>%
+      nnf_relu() %>%
+      self$fc2() %>%
+      nnf_log_softmax(dim = 1)
+  }
+)
+
+model <- net()
+optimizer <- optim_sgd(model$parameters, lr = 0.01)
+
+epochs <- 10
+
+for (epoch in 1:10) {
+
+  pb <- progress::progress_bar$new(
+    total = length(dl),
+    format = "[:bar] :eta Loss: :loss"
+  )
+  l <- c()
+
+  for (b in enumerate(dl)) {
+    optimizer$zero_grad()
+    output <- model(b[[1]])
+    loss <- nnf_nll_loss(output, b[[2]])
+    loss$backward()
+    optimizer$step()
+    l <- c(l, loss$item())
+    pb$tick(tokens = list(loss = mean(l)))
+  }
+
+  cat(sprintf("Loss at epoch %d: %3f\n", epoch, mean(l)))
+}
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/examples/mnist-mlp_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/examples/mnist-mlp_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/examples/mnist-mlp_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/articles/extending-autograd.html b/articles/extending-autograd.html new file mode 100644 index 0000000000000000000000000000000000000000..80f0a1fc628e36c71b23a6651877e0aa519da760 --- /dev/null +++ b/articles/extending-autograd.html @@ -0,0 +1,222 @@ + + + + + + + +Extending Autograd • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
library(torch)
+

Adding operations to autograd requires implementing a new autograd_function for each operation. Recall that autograd_functionss are what autograd uses to compute the results and gradients, and encode the operation history. Every new function requires you to implement 2 methods:

+
    +
  • forward() - the code that performs the operation. It can take as many arguments as you want, with some of them being optional, if you specify the default values. All kinds of R objects are accepted here. Tensor arguments that track history (i.e., with requires_grad=TRUE) will be converted to ones that don’t track history before the call, and their use will be registered in the graph. Note that this logic won’t traverse lists or any other data structures and will only consider Tensor’s that are direct arguments to the call. You can return either a single Tensor output, or a list of Tensors if there are multiple outputs. Also, please refer to the docs of autograd_function to find descriptions of useful methods that can be called only from forward().

  • +
  • backward() - gradient formula. It will be given as many Tensor arguments as there were outputs, with each of them representing gradient w.r.t. that output. It should return as many Tensors as there were Tensor's that required gradients in forward, with each of them containing the gradient w.r.t. its corresponding input.

  • +
+
+

+Note

+

It’s the user’s responsibility to use the special functions in the forward’s ctx properly in order to ensure that the new autograd_function works properly with the autograd engine.

+
    +
  • save_for_backward() must be used when saving input or ouput of the forward to be used later in the backward.

  • +
  • mark_dirty() must be used to mark any input that is modified inplace by the forward function.

  • +
  • mark_non_differentiable() must be used to tell the engine if an output is not differentiable.

  • +
+
+
+

+Examples

+

Below you can find code for a linear function:

+
linear <- autograd_function(
+  forward = function(ctx, input, weight, bias = NULL) {
+    ctx$save_for_backward(input = input, weight = weight, bias = bias)
+    output <- input$mm(weight$t())
+    if (!is.null(bias))
+      output <- output + bias$unsqueeze(0)$expand_as(output)
+
+    output
+  },
+  backward = function(ctx, grad_output) {
+
+    s <- ctx$saved_variables
+
+    grads <- list(
+      input = NULL,
+      weight = NULL,
+      bias = NULL
+    )
+
+    if (ctx$needs_input_grad$input)
+      grads$input <- grad_output$mm(s$weight)
+
+    if (ctx$needs_input_grad$weight)
+      grads$weight <- grad_output$t()$mm(s$input)
+
+    if (!is.null(s$bias) && ctx$needs_input_grad$bias)
+      grads$bias <- grad_output$sum(dim = 0)
+
+    grads
+  }
+)
+

Here, we give an additional example of a function that is parametrized by non-Tensor arguments:

+
mul_constant <- autograd_function(
+  forward = function(ctx, tensor, constant) {
+    ctx$save_for_backward(constant = constant)
+    tensor * constant
+  },
+  backward = function(ctx, grad_output) {
+    v <- ctx$saved_variables
+    list(
+      tensor = grad_output * v$constant
+    )
+  }
+)
+
x <- torch_tensor(1, requires_grad = TRUE)
+o <- mul_constant(x, 2)
+o$backward()
+x$grad
+
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/extending-autograd_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/extending-autograd_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/extending-autograd_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/articles/index.html b/articles/index.html new file mode 100644 index 0000000000000000000000000000000000000000..04000350caa0ce564ef8aaaf2ce0b4a347fd1561 --- /dev/null +++ b/articles/index.html @@ -0,0 +1,204 @@ + + + + + + + + +Articles • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + + +
+
+ + + +
+ + + + + + + + diff --git a/articles/indexing.html b/articles/indexing.html new file mode 100644 index 0000000000000000000000000000000000000000..64c5ac8b3d1b5a0918524b0c12efc99d16bc44f3 --- /dev/null +++ b/articles/indexing.html @@ -0,0 +1,224 @@ + + + + + + + +Indexing tensors • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
library(torch)
+

In this article we describe the indexing operator for torch tensors and how it compares to the R indexing operator for arrays.

+

Torch’s indexing semantics are closer to numpy’s semantics than R’s. You will find a lot of similarities between this article and the numpy indexing article available here.

+
+

+Single element indexing

+

Single element indexing for a 1-D tensors works mostly as expected. Like R, it is 1-based. Unlike R though, it accepts negative indices for indexing from the end of the array. (In R, negative indices are used to remove elements.)

+
x <- torch_tensor(1:10)
+x[1]
+x[-1]
+

You can also subset matrices and higher dimensions arrays using the same syntax:

+
x <- x$reshape(shape = c(2,5))
+x
+x[1,3]
+x[1,-1]
+

Note that if one indexes a multidimensional tensor with fewer indices than dimensions, one gets an error, unlike in R that would flatten the array. For example:

+
x[1]
+
+
+

+Slicing and striding

+

It is possible to slice and stride arrays to extract sub-arrays of the same number of dimensions, but of different sizes than the original. This is best illustrated by a few examples:

+
x <- torch_tensor(1:10)
+x
+x[2:5]
+x[1:(-7)]
+

You can also use the 1:10:2 syntax which means: In the range from 1 to 10, take every second item. For example:

+
x[1:5:2]
+

Another special syntax is the N, meaning the size of the specified dimension.

+
x[5:N]
+
+
+

+Getting the complete dimension

+

Like in R, you can take all elements in a dimension by leaving an index empty.

+

Consider a matrix:

+
x <- torch_randn(2, 3)
+x
+

The following syntax will give you the first row:

+
x[1,]
+

And this would give you the first 2 columns:

+
x[,1:2]
+
+
+

+Dropping dimensions

+

By default, when indexing by a single integer, this dimension will be dropped to avoid the singleton dimension:

+
x <- torch_randn(2, 3)
+x[1,]$shape
+

You can optionally use the drop = FALSE argument to avoid dropping the dimension.

+
x[1,,drop = FALSE]$shape
+
+
+

+Adding a new dimension

+

It’s possible to add a new dimension to a tensor using index-like syntax:

+
x <- torch_tensor(c(10))
+x$shape
+x[, newaxis]$shape
+x[, newaxis, newaxis]$shape
+

You can also use NULL instead of newaxis:

+
x[,NULL]$shape
+
+
+

+Dealing with variable number of indices

+

Sometimes we don’t know how many dimensions a tensor has, but we do know what to do with the last available dimension, or the first one. To subsume all others, we can use ..:

+
z <- torch_tensor(1:125)$reshape(c(5,5,5))
+z[1,..]
+z[..,1]
+
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/indexing_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/indexing_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/indexing_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/articles/loading-data.html b/articles/loading-data.html new file mode 100644 index 0000000000000000000000000000000000000000..a64f0edf7191a4c08487742a279af282c11d28f8 --- /dev/null +++ b/articles/loading-data.html @@ -0,0 +1,274 @@ + + + + + + + +Loading data • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
library(torch)
+
+

+Datasets and data loaders

+

Central to data ingestion and preprocessing are datasets and data loaders.

+

torch comes equipped with a bag of datasets related to, mostly, image recognition and natural language processing (e.g., mnist_dataset()), which can be iterated over by means of dataloaders:

+
# ...
+ds <- mnist_dataset(
+  dir, 
+  download = TRUE, 
+  transform = function(x) {
+    x <- x$to(dtype = torch_float())/256
+    x[newaxis,..]
+  }
+)
+
+dl <- dataloader(ds, batch_size = 32, shuffle = TRUE)
+
+for (b in enumerate(dl)) {
+  # ...
+

Cf. vignettes/examples/mnist-cnn.R for a complete example.

+

What if you want to train on a different dataset? In these cases, you subclass Dataset, an abstract container that needs to know how to iterate over the given data. To that purpose, your subclass needs to implement .getitem(), and say what should be returned when the data loader is asking for the next batch.

+

In .getitem(), you can implement whatever preprocessing you require. Additionally, you should implement .length(), so users can find out how many items there are in the dataset.

+

While this may sound complicated, it is not at all. The base logic is straightforward – complexity will, naturally, correlate with how involved your preprocessing is. To provide you with a simple but functional prototype, here we show how to create your own dataset to train on Allison Horst's penguins.

+
+
+

+A custom dataset

+
library(palmerpenguins)
+library(magrittr)
+
+penguins
+

Datasets are R6 classes created using the dataset() constructor. You can pass a name and various member functions. Among those should be initialize(), to create instance variables, .getitem(), to indicate how the data should be returned, and .length(), to say how many items we have.

+

In addition, any number of helper functions can be defined.

+

Here, we assume the penguins have already been loaded, and all preprocessing consists in removing lines with NA values, transforming factors to numbers starting from 0, and converting from R data types to torch tensors.

+

In .getitem, we essentially decide how this data is going to be used: All variables besides species go into x, the predictor, and species will constitute y, the target. Predictor and target are returned in a list, to be accessed as batch[[1]] and batch[[2]] during training.

+
penguins_dataset <- dataset(
+
+  name = "penguins_dataset",
+
+  initialize = function() {
+    self$data <- self$prepare_penguin_data()
+  },
+
+  .getitem = function(index) {
+
+    x <- self$data[index, 2:-1]
+    y <- self$data[index, 1]$to(torch_long())
+
+    list(x, y)
+  },
+
+  .length = function() {
+    self$data$size()[[1]]
+  },
+
+  prepare_penguin_data = function() {
+
+    input <- na.omit(penguins)
+    # conveniently, the categorical data are already factors
+    input$species <- as.numeric(input$species)
+    input$island <- as.numeric(input$island)
+    input$sex <- as.numeric(input$sex)
+
+    input <- as.matrix(input)
+    torch_tensor(input)
+  }
+)
+

Let’s create the dataset , query for it’s length, and look at its first item:

+
tuxes <- penguins_dataset()
+tuxes$.length()
+tuxes$.getitem(1)
+

To be able to iterate over tuxes, we need a data loader (we override the default batch size of 1):

+
dl <-tuxes %>% dataloader(batch_size = 8)
+

Calling .length() on a data loader (as opposed to a dataset) will return the number of batches we have:

+
dl$.length()
+

And we can create an iterator to inspect the first batch:

+
iter <- dl$.iter()
+b <- iter$.next()
+b
+

To train a network, we can use enumerate to iterate over batches.

+
+
+

+Training with data loaders

+

Our example network is very simple. (In reality, we would want to treat island as the categorical variable it is, and either one-hot-encode or embed it.)

+
net <- nn_module(
+  "PenguinNet",
+  initialize = function() {
+    self$fc1 <- nn_linear(6, 32)
+    self$fc2 <- nn_linear(32, 3)
+  },
+  forward = function(x) {
+    x %>%
+      self$fc1() %>%
+      nnf_relu() %>%
+      self$fc2() %>%
+      nnf_log_softmax(dim = 1)
+  }
+)
+
+model <- net()
+

We still need an optimizer:

+
optimizer <- optim_sgd(model$parameters, lr = 0.01)
+

And we’re ready to train:

+
for (epoch in 1:10) {
+
+  l <- c()
+
+  for (b in enumerate(dl)) {
+    optimizer$zero_grad()
+    output <- model(b[[1]])
+    loss <- nnf_nll_loss(output, b[[2]])
+    loss$backward()
+    optimizer$step()
+    l <- c(l, loss$item())
+  }
+
+  cat(sprintf("Loss at epoch %d: %3f\n", epoch, mean(l)))
+}
+
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/loading-data_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/loading-data_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/loading-data_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/articles/tensor-creation.html b/articles/tensor-creation.html new file mode 100644 index 0000000000000000000000000000000000000000..4d2699fdc99d09523e35c74c5663af832b27f1bf --- /dev/null +++ b/articles/tensor-creation.html @@ -0,0 +1,231 @@ + + + + + + + +Creating tensors • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
library(torch)
+

In this article we describe various ways of creating torch tensors in R.

+
+

+From R objects

+

You can create tensors from R objects using the torch_tensor function. The torch_tensor function takes an R vector, matrix or array and creates an equivalent torch_tensor.

+

You can see a few examples below:

+
torch_tensor(c(1,2,3))
+
+# conform to row-major indexing used in torch
+torch_tensor(matrix(1:10, ncol = 5, nrow = 2, byrow = TRUE))
+torch_tensor(array(runif(12), dim = c(2, 2, 3)))
+

By default, we will create tensors in the cpu device, converting their R datatype to the corresponding torch dtype.

+
+

Note currently, only numeric and boolean types are supported.

+
+

You can always modify dtype and device when converting an R object to a torch tensor. For example:

+
torch_tensor(1, dtype = torch_long())
+torch_tensor(1, device = "cpu", dtype = torch_float64())
+

Other options available when creating a tensor are:

+
    +
  • +requires_grad: boolean indicating if you want autograd to record operations on them for automatic differentiation.
  • +
  • +pin_memory: – If set, the tensor returned would be allocated in pinned memory. Works only for CPU tensors.
  • +
+

These options are available for all functions that can be used to create new tensors, including the factory functions listed in the next section.

+
+
+

+Using creation functions

+

You can also use the torch_* functions listed below to create torch tensors using some algorithm.

+

For example, the torch_randn function will create tensors using the normal distribution with mean 0 and standard deviation 1. You can use the ... argument to pass the size of the dimensions. For example, the code below will create a normally distributed tensor with shape 5x3.

+
x <- torch_randn(5, 3)
+x
+

Another example is torch_ones, which creates a tensor filled with ones.

+
x <- torch_ones(2, 4, dtype = torch_int64(), device = "cpu")
+x
+

Here is the full list of functions that can be used to bulk-create tensors in torch:

+
    +
  • +torch_arange: Returns a tensor with a sequence of integers,
  • +
  • +torch_empty: Returns a tensor with uninitialized values,
  • +
  • +torch_eye: Returns an identity matrix,
  • +
  • +torch_full: Returns a tensor filled with a single value,
  • +
  • +torch_linspace: Returns a tensor with values linearly spaced in some interval,
  • +
  • +torch_logspace: Returns a tensor with values logarithmically spaced in some interval,
  • +
  • +torch_ones: Returns a tensor filled with all ones,
  • +
  • +torch_rand: Returns a tensor filled with values drawn from a uniform distribution on [0, 1).
  • +
  • +torch_randint: Returns a tensor with integers randomly drawn from an interval,
  • +
  • +torch_randn: Returns a tensor filled with values drawn from a unit normal distribution,
  • +
  • +torch_randperm: Returns a tensor filled with a random permutation of integers in some interval,
  • +
  • +torch_zeros: Returns a tensor filled with all zeros.
  • +
+
+
+

+Conversion

+

Once a tensor exists you can convert between dtypes and move to a different device with to method. For example:

+
x <- torch_tensor(1)
+y <- x$to(dtype = torch_int32())
+x
+y
+

You can also copy a tensor to the GPU using:

+
x <- torch_tensor(1)
+y <- x$cuda())
+
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/tensor-creation_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/tensor-creation_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/tensor-creation_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/articles/using-autograd.html b/articles/using-autograd.html new file mode 100644 index 0000000000000000000000000000000000000000..bd636e86f23a7ae27655c1bd2c673ade137b9fe3 --- /dev/null +++ b/articles/using-autograd.html @@ -0,0 +1,268 @@ + + + + + + + +Using autograd • torch + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
library(torch)
+

So far, all we’ve been using from torch is tensors, but we’ve been performing all calculations ourselves – the computing the predictions, the loss, the gradients (and thus, the necessary updates to the weights), and the new weight values. In this chapter, we’ll make a significant change: Namely, we spare ourselves the cumbersome calculation of gradients, and have torch do it for us.

+

Before we see that in action, let’s get some more background.

+
+

+Automatic differentiation with autograd

+

Torch uses a module called autograd to record operations performed on tensors, and store what has to be done to obtain the respective gradients. These actions are stored as functions, and those functions are applied in order when the gradient of the output (normally, the loss) with respect to those tensors is calculated: starting from the output node and propagating gradients back through the network. This is a form of reverse mode automatic differentiation.

+

As users, we can see a bit of this implementation. As a prerequisite for this “recording” to happen, tensors have to be created with requires_grad = TRUE. E.g.

+
x <- torch_ones(2,2, requires_grad = TRUE)
+

To be clear, this is a tensor with respect to which gradients have to be calculated – normally, a tensor representing a weight or a bias, not the input data 1. If we now perform some operation on that tensor, assigning the result to y

+
y <- x$mean()
+

we find that y now has a non-empty grad_fn that tells torch how to compute the gradient of y with respect to x:

+
y$grad_fn
+

Actual computation of gradients is triggered by calling backward() on the output tensor.

+
y$backward()
+

That executed, x now has a non-empty field grad that stores the gradient of y with respect to x:

+
x$grad
+

With a longer chain of computations, we can peek at how torch builds up a graph of backward operations.

+

Here is a slightly more complex example. We call retain_grad() on y and z just for demonstration purposes; by default, intermediate gradients – while of course they have to be computed – aren’t stored, in order to save memory.

+
x1 <- torch_ones(2,2, requires_grad = TRUE)
+x2 <- torch_tensor(1.1, requires_grad = TRUE)
+y <- x1 * (x2 + 2)
+y$retain_grad()
+z <- y$pow(2) * 3
+z$retain_grad()
+out <- z$mean()
+

Starting from out$grad_fn, we can follow the graph all back to the leaf nodes:

+
# how to compute the gradient for mean, the last operation executed
+out$grad_fn
+# how to compute the gradient for the multiplication by 3 in z = y$pow(2) * 3
+out$grad_fn$next_functions
+# how to compute the gradient for pow in z = y.pow(2) * 3
+out$grad_fn$next_functions[[1]]$next_functions
+# how to compute the gradient for the multiplication in y = x * (x + 2)
+out$grad_fn$next_functions[[1]]$next_functions[[1]]$next_functions
+# how to compute the gradient for the two branches of y = x * (x + 2),
+# where the left branch is a leaf node (AccumulateGrad for x1)
+out$grad_fn$next_functions[[1]]$next_functions[[1]]$next_functions[[1]]$next_functions
+# here we arrive at the other leaf node (AccumulateGrad for x2)
+out$grad_fn$next_functions[[1]]$next_functions[[1]]$next_functions[[1]]$next_functions[[2]]$next_functions
+

After calling out$backward(), all tensors in the graph will have their respective gradients created. Without our calls to retain_grad above, z$grad and y$grad would be empty:

+
out$backward()
+z$grad
+y$grad
+x2$grad
+x1$grad
+

Thus acquainted with autograd, we’re ready to modify our example.

+
+
+

+The simple network, now using autograd

+

For a single new line calling loss$backward(), now a number of lines (that did manual backprop) are gone:

+
### generate training data -----------------------------------------------------
+# input dimensionality (number of input features)
+d_in <- 3
+# output dimensionality (number of predicted features)
+d_out <- 1
+# number of observations in training set
+n <- 100
+# create random data
+x <- torch_randn(n, d_in)
+y <- x[,1]*0.2 - x[..,2]*1.3 - x[..,3]*0.5 + torch_randn(n)
+y <- y$unsqueeze(dim = 1)
+### initialize weights ---------------------------------------------------------
+# dimensionality of hidden layer
+d_hidden <- 32
+# weights connecting input to hidden layer
+w1 <- torch_randn(d_in, d_hidden, requires_grad = TRUE)
+# weights connecting hidden to output layer
+w2 <- torch_randn(d_hidden, d_out, requires_grad = TRUE)
+# hidden layer bias
+b1 <- torch_zeros(1, d_hidden, requires_grad = TRUE)
+# output layer bias
+b2 <- torch_zeros(1, d_out,requires_grad = TRUE)
+### network parameters ---------------------------------------------------------
+learning_rate <- 1e-4
+### training loop --------------------------------------------------------------
+for (t in 1:200) {
+
+    ### -------- Forward pass -------- 
+    y_pred <- x$mm(w1)$add(b1)$clamp(min = 0)$mm(w2)$add(b2)
+    ### -------- compute loss -------- 
+    loss <- (y_pred - y)$pow(2)$mean()
+    if (t %% 10 == 0) cat(t, as_array(loss), "\n")
+    ### -------- Backpropagation -------- 
+    # compute the gradient of loss with respect to all tensors with requires_grad = True.
+    loss$backward()
+
+    ### -------- Update weights -------- 
+
+    # Wrap in torch.no_grad() because this is a part we DON'T want to record for automatic gradient computation
+    with_no_grad({
+
+      w1$sub_(learning_rate * w1$grad)
+      w2$sub_(learning_rate * w2$grad)
+      b1$sub_(learning_rate * b1$grad)
+      b2$sub_(learning_rate * b2$grad)
+
+      # Zero the gradients after every pass, because they'd accumulate otherwise
+      w1$grad$zero_()
+      w2$grad$zero_()
+      b1$grad$zero_()
+      b2$grad$zero_()
+
+    })
+
+}
+

We still manually compute the forward pass, and we still manually update the weights. In the last two chapters of this section, we’ll see how these parts of the logic can be made more modular and reusable, as well.

+
+
+
+
    +
  1. Unless we want to change the data, as in adversarial example generation↩︎

  2. +
+
+
+ + + +
+ + + + +
+ + + + + + diff --git a/articles/using-autograd_files/accessible-code-block-0.0.1/empty-anchor.js b/articles/using-autograd_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 0000000000000000000000000000000000000000..ca349fd6a570108bde9d7daace534cd651c5f042 --- /dev/null +++ b/articles/using-autograd_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/authors.html b/authors.html new file mode 100644 index 0000000000000000000000000000000000000000..f0689e6ee9600d1534c4d689e3dbc7e311d06fa4 --- /dev/null +++ b/authors.html @@ -0,0 +1,206 @@ + + + + + + + + +Authors • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
    +
  • +

    Daniel Falbel. Author, maintainer, copyright holder. +

    +
  • +
  • +

    Javier Luraschi. Author, copyright holder. +

    +
  • +
  • +

    Dmitriy Selivanov. Contributor. +

    +
  • +
  • +

    Athos Damiani. Contributor. +

    +
  • +
  • +

    RStudio. Copyright holder. +

    +
  • +
+ +
+ +
+ + + + +
+ + + + + + + + diff --git a/bootstrap-toc.css b/bootstrap-toc.css new file mode 100644 index 0000000000000000000000000000000000000000..5a859415c1f7eacfd94920968bc910e2f1f1427e --- /dev/null +++ b/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/bootstrap-toc.js b/bootstrap-toc.js new file mode 100644 index 0000000000000000000000000000000000000000..1cdd573b20f53b3ebe31c021e154c4338ca456af --- /dev/null +++ b/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docsearch.css b/docsearch.css new file mode 100644 index 0000000000000000000000000000000000000000..e5f1fe1dfa2c34c51fe941829b511acd8c763301 --- /dev/null +++ b/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docsearch.js b/docsearch.js new file mode 100644 index 0000000000000000000000000000000000000000..b35504cd3a282816130a16881f3ebeead9c1bcb4 --- /dev/null +++ b/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000000000000000000000000000000000000..cef60c793870d31bff9a6f9abf3517e9d79bc492 --- /dev/null +++ b/index.html @@ -0,0 +1,276 @@ + + + + + + + +Tensors and Neural Networks with GPU Acceleration • torch + + + + + + + + + + +
    +
    + + + + +
    +
    +
    + + +
    +

    +Installation

    +

    Run:

    +
    remotes::install_github("mlverse/torch")
    +

    At the first package load additional software will be installed.

    +
    +
    +

    +Example

    +

    Currently this package is only a proof of concept and you can only create a Torch Tensor from an R object. And then convert back from a torch Tensor to an R object.

    +
    library(torch)
    +x <- array(runif(8), dim = c(2, 2, 2))
    +y <- torch_tensor(x, dtype = torch_float64())
    +y
    +#> torch_tensor 
    +#> (1,.,.) = 
    +#>   0.8687  0.0157
    +#>   0.4237  0.8971
    +#> 
    +#> (2,.,.) = 
    +#>   0.4021  0.5509
    +#>   0.3374  0.9034
    +#> [ CPUDoubleType{2,2,2} ]
    +identical(x, as_array(y))
    +#> [1] TRUE
    +
    +

    +Simple Autograd Example

    +

    In the following snippet we let torch, using the autograd feature, calculate the derivatives:

    +
    x <- torch_tensor(1, requires_grad = TRUE)
    +w <- torch_tensor(2, requires_grad = TRUE)
    +b <- torch_tensor(3, requires_grad = TRUE)
    +y <- w * x + b
    +y$backward()
    +x$grad
    +#> torch_tensor 
    +#>  2
    +#> [ CPUFloatType{1} ]
    +w$grad
    +#> torch_tensor 
    +#>  1
    +#> [ CPUFloatType{1} ]
    +b$grad
    +#> torch_tensor 
    +#>  1
    +#> [ CPUFloatType{1} ]
    +
    +
    +

    +Linear Regression

    +

    In the following example we are going to fit a linear regression from scratch using torch’s Autograd.

    +

    Note all methods that end with _ (eg. sub_), will modify the tensors in place.

    +
    x <- torch_randn(100, 2)
    +y <- 0.1 + 0.5*x[,1] - 0.7*x[,2]
    +
    +w <- torch_randn(2, 1, requires_grad = TRUE)
    +b <- torch_zeros(1, requires_grad = TRUE)
    +
    +lr <- 0.5
    +for (i in 1:100) {
    +  y_hat <- torch_mm(x, w) + b
    +  loss <- torch_mean((y - y_hat$squeeze(1))^2)
    +
    +  loss$backward()
    +
    +  with_no_grad({
    +    w$sub_(w$grad*lr)
    +    b$sub_(b$grad*lr)
    +
    +    w$grad$zero_()
    +    b$grad$zero_()
    +  })
    +}
    +print(w)
    +#> torch_tensor 
    +#>  0.5000
    +#> -0.7000
    +#> [ CPUFloatType{2,1} ]
    +print(b)
    +#> torch_tensor 
    +#> 0.01 *
    +#> 10.0000
    +#> [ CPUFloatType{1} ]
    +
    +
    +
    +

    +Contributing

    +

    No matter your current skills it’s possible to contribute to torch development. See the contributing guide for more information.

    +
    +
    +
    + + +
    + + +
    + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + diff --git a/link.svg b/link.svg new file mode 100644 index 0000000000000000000000000000000000000000..88ad82769b87f10725c57dca6fcf41b4bffe462c --- /dev/null +++ b/link.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/pkgdown.css b/pkgdown.css new file mode 100644 index 0000000000000000000000000000000000000000..c01e5923be6ff1edbccf20f93be6bdf8dbd67bb3 --- /dev/null +++ b/pkgdown.css @@ -0,0 +1,367 @@ +/* Sticky footer */ + +/** + * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ + * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css + * + * .Site -> body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body { + position: relative; +} + +body > .container { + display: flex; + height: 100%; + flex-direction: column; +} + +body > .container .row { + flex: 1 0 auto; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; + flex-shrink: 0; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +img { + max-width: 100%; +} + +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +dd { + margin-left: 3em; +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + margin-left: -30px; + display:inline-block; + width: 30px; + height: 30px; + visibility: hidden; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +.hasAnchor:hover a.anchor { + visibility: visible; +} + +@media (max-width: 767px) { + .hasAnchor:hover a.anchor { + visibility: hidden; + } +} + + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -40px; +} + +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} + +/* Sidebar --------------------------*/ + +#pkgdown-sidebar { + margin-top: 30px; + position: -webkit-sticky; + position: sticky; + top: 70px; +} + +#pkgdown-sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#pkgdown-sidebar h2:first-child { + margin-top: 0; +} + +#pkgdown-sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + +.orcid { + font-size: 16px; + color: #A6CE39; + /* margins are required by official ORCID trademark and display guidelines */ + margin-left:4px; + margin-right:4px; + vertical-align: middle; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} + +.ref-index td {vertical-align: top;} +.ref-index .icon {width: 40px;} +.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top;} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre { + word-wrap: normal; + word-break: normal; + border: 1px solid #eee; +} + +pre, code { + background-color: #f8f8f8; + color: #333; +} + +pre code { + overflow: auto; + word-wrap: normal; + white-space: pre; +} + +pre .img { + margin: 5px 0; +} + +pre .img img { + background-color: #fff; + display: block; + height: auto; +} + +code a, pre a { + color: #375f84; +} + +a.sourceLine:hover { + text-decoration: none; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.message { color: black; font-weight: bolder;} +.error { color: orange; font-weight: bolder;} +.warning { color: #6A0366; font-weight: bolder;} + +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* headroom.js ------------------------ */ + +.headroom { + will-change: transform; + transition: transform 200ms linear; +} +.headroom--pinned { + transform: translateY(0%); +} +.headroom--unpinned { + transform: translateY(-100%); +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} + +/* fontawesome ------------------------ */ + +.fab { + font-family: "Font Awesome 5 Brands" !important; +} + +/* don't display links in code chunks when printing */ +/* source: https://stackoverflow.com/a/10781533 */ +@media print { + code a:link:after, code a:visited:after { + content: ""; + } +} diff --git a/pkgdown.js b/pkgdown.js new file mode 100644 index 0000000000000000000000000000000000000000..7e7048faebb92b85ed06afddd1a8a4581241d6a4 --- /dev/null +++ b/pkgdown.js @@ -0,0 +1,108 @@ +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $('.navbar-fixed-top').headroom(); + + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); + }); + + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } + + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); + + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } + + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); + + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } + + /* Clipboard --------------------------*/ + + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); + } + + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; + + $(".examples, div.sourceCode").addClass("hasCopyButton"); + + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); + + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); + + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent; + } + }); + + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); + + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); + }); + } +})(window.jQuery || window.$) diff --git a/pkgdown.yml b/pkgdown.yml new file mode 100644 index 0000000000000000000000000000000000000000..4d5db221031b8e43c961257aa2ec6f828fc0ebe0 --- /dev/null +++ b/pkgdown.yml @@ -0,0 +1,14 @@ +pandoc: 2.7.3 +pkgdown: 1.5.1 +pkgdown_sha: ~ +articles: + mnist-cnn: examples/mnist-cnn.html + mnist-dcgan: examples/mnist-dcgan.html + mnist-mlp: examples/mnist-mlp.html + extending-autograd: extending-autograd.html + indexing: indexing.html + loading-data: loading-data.html + tensor-creation: tensor-creation.html + using-autograd: using-autograd.html +last_built: 2020-08-25T20:10Z + diff --git a/reference/AutogradContext.html b/reference/AutogradContext.html new file mode 100644 index 0000000000000000000000000000000000000000..f39db5cf1c5457dd73dcdc401b51fdd2db7937a6 --- /dev/null +++ b/reference/AutogradContext.html @@ -0,0 +1,306 @@ + + + + + + + + +Class representing the context. — AutogradContext • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Class representing the context.

    +

    Class representing the context.

    +
    + + + +

    Public fields

    + +

    +
    ptr

    (Dev related) pointer to the context c++ object.

    + +

    +

    Active bindings

    + +

    +
    needs_input_grad

    boolean listing arguments of forward and whether they require_grad.

    + +
    saved_variables

    list of objects that were saved for backward via save_for_backward.

    + +

    +

    Methods

    + + +

    Public methods

    + + +


    +

    Method new()

    +

    (Dev related) Initializes the context. Not user related.

    Usage

    +

    AutogradContext$new(
    +  ptr,
    +  env,
    +  argument_names = NULL,
    +  argument_needs_grad = NULL
    +)

    + +

    Arguments

    +

    +
    ptr

    pointer to the c++ object

    + +
    env

    environment that encloses both forward and backward

    + +
    argument_names

    names of forward arguments

    + +
    argument_needs_grad

    whether each argument in forward needs grad.

    + +

    +


    +

    Method save_for_backward()

    +

    Saves given objects for a future call to backward().

    +

    This should be called at most once, and only from inside the forward() +method.

    +

    Later, saved objects can be accessed through the saved_variables attribute. +Before returning them to the user, a check is made to ensure they weren’t used +in any in-place operation that modified their content.

    +

    Arguments can also be any kind of R object.

    Usage

    +

    AutogradContext$save_for_backward(...)

    + +

    Arguments

    +

    +
    ...

    any kind of R object that will be saved for the backward pass. +It's common to pass named arguments.

    + +

    +


    +

    Method mark_non_differentiable()

    +

    Marks outputs as non-differentiable.

    +

    This should be called at most once, only from inside the forward() method, +and all arguments should be outputs.

    +

    This will mark outputs as not requiring gradients, increasing the efficiency +of backward computation. You still need to accept a gradient for each output +in backward(), but it’s always going to be a zero tensor with the same +shape as the shape of a corresponding output.

    +

    This is used e.g. for indices returned from a max Function.

    Usage

    +

    AutogradContext$mark_non_differentiable(...)

    + +

    Arguments

    +

    +
    ...

    non-differentiable outputs.

    + +

    +


    +

    Method mark_dirty()

    +

    Marks given tensors as modified in an in-place operation.

    +

    This should be called at most once, only from inside the forward() method, +and all arguments should be inputs.

    +

    Every tensor that’s been modified in-place in a call to forward() should +be given to this function, to ensure correctness of our checks. It doesn’t +matter whether the function is called before or after modification.

    Usage

    +

    AutogradContext$mark_dirty(...)

    + +

    Arguments

    +

    +
    ...

    tensors that are modified in-place.

    + +

    +


    +

    Method clone()

    +

    The objects of this class are cloneable with this method.

    Usage

    +

    AutogradContext$clone(deep = FALSE)

    + +

    Arguments

    +

    +
    deep

    Whether to make a deep clone.

    + +

    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/as_array.html b/reference/as_array.html new file mode 100644 index 0000000000000000000000000000000000000000..1706df553425a9942fe04b3bacb71db53d398cbe --- /dev/null +++ b/reference/as_array.html @@ -0,0 +1,205 @@ + + + + + + + + +Converts to array — as_array • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Converts to array

    +
    + +
    as_array(x)
    + +

    Arguments

    + + + + + + +
    x

    object to be converted into an array

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/autograd_backward.html b/reference/autograd_backward.html new file mode 100644 index 0000000000000000000000000000000000000000..f9954c77c0295c758bb1d7a25bd579796cbf81d5 --- /dev/null +++ b/reference/autograd_backward.html @@ -0,0 +1,258 @@ + + + + + + + + +Computes the sum of gradients of given tensors w.r.t. graph leaves. — autograd_backward • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The graph is differentiated using the chain rule. If any of tensors are +non-scalar (i.e. their data has more than one element) and require gradient, +then the Jacobian-vector product would be computed, in this case the function +additionally requires specifying grad_tensors. It should be a sequence of +matching length, that contains the “vector” in the Jacobian-vector product, +usually the gradient of the differentiated function w.r.t. corresponding +tensors (None is an acceptable value for all tensors that don’t need gradient +tensors).

    +
    + +
    autograd_backward(
    +  tensors,
    +  grad_tensors = NULL,
    +  retain_graph = create_graph,
    +  create_graph = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    tensors

    (list of Tensor) – Tensors of which the derivative will +be computed.

    grad_tensors

    (list of (Tensor or NULL)) – The “vector” in the Jacobian-vector product, usually gradients w.r.t. each element of corresponding tensors. NULLvalues can be specified for scalar Tensors or ones that don’t require grad. If aNULL` value would be acceptable for all +grad_tensors, then this argument is optional.

    retain_graph

    (bool, optional) – If FALSE, the graph used to compute +the grad will be freed. Note that in nearly all cases setting this option to +TRUE is not needed and often can be worked around in a much more efficient +way. Defaults to the value of create_graph.

    create_graph

    (bool, optional) – If TRUE, graph of the derivative will +be constructed, allowing to compute higher order derivative products. +Defaults to FALSE.

    + +

    Details

    + +

    This function accumulates gradients in the leaves - you might need to zero +them before calling it.

    + +

    Examples

    +
    if (torch_is_installed()) { +x <- torch_tensor(1, requires_grad = TRUE) +y <- 2 * x + +a <- torch_tensor(1, requires_grad = TRUE) +b <- 3 * a + +autograd_backward(list(y, b)) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/autograd_function.html b/reference/autograd_function.html new file mode 100644 index 0000000000000000000000000000000000000000..ba5cb5a47614f8a865f67f50e18a443c383bccb7 --- /dev/null +++ b/reference/autograd_function.html @@ -0,0 +1,246 @@ + + + + + + + + +Records operation history and defines formulas for differentiating ops. — autograd_function • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Every operation performed on Tensor's creates a new function object, that +performs the computation, and records that it happened. The history is +retained in the form of a DAG of functions, with edges denoting data +dependencies (input <- output). Then, when backward is called, the graph is +processed in the topological ordering, by calling backward() methods of each +Function object, and passing returned gradients on to next Function's.

    +
    + +
    autograd_function(forward, backward)
    + +

    Arguments

    + + + + + + + + + + +
    forward

    Performs the operation. It must accept a context ctx as the first argument, +followed by any number of arguments (tensors or other types). The context can be +used to store tensors that can be then retrieved during the backward pass. +See AutogradContext for more information about context methods.

    backward

    Defines a formula for differentiating the operation. It must accept +a context ctx as the first argument, followed by as many outputs did forward() +return, and it should return a named list. Each argument is the gradient w.r.t +the given output, and each element in the returned list should be the gradient +w.r.t. the corresponding input. The context can be used to retrieve tensors saved +during the forward pass. It also has an attribute ctx$needs_input_grad as a +named list of booleans representing whether each input needs gradient. +E.g., backward() will have ctx$needs_input_grad$input = TRUE if the input +argument to forward() needs gradient computated w.r.t. the output. +See AutogradContext for more information about context methods.

    + + +

    Examples

    +
    if (torch_is_installed()) { + +exp2 <- autograd_function( + forward = function(ctx, i) { + result <- i$exp() + ctx$save_for_backward(result = result) + result + }, + backward = function(ctx, grad_output) { + list(i = grad_output * ctx$saved_variable$result) + } +) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/autograd_grad.html b/reference/autograd_grad.html new file mode 100644 index 0000000000000000000000000000000000000000..49ac297de39b92b6c0d2203df63494f4c51466dc --- /dev/null +++ b/reference/autograd_grad.html @@ -0,0 +1,263 @@ + + + + + + + + +Computes and returns the sum of gradients of outputs w.r.t. the inputs. — autograd_grad • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    grad_outputs should be a list of length matching output containing the “vector” +in Jacobian-vector product, usually the pre-computed gradients w.r.t. each of +the outputs. If an output doesn’t require_grad, then the gradient can be None).

    +
    + +
    autograd_grad(
    +  outputs,
    +  inputs,
    +  grad_outputs = NULL,
    +  retain_graph = create_graph,
    +  create_graph = FALSE,
    +  allow_unused = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    outputs

    (sequence of Tensor) – outputs of the differentiated function.

    inputs

    (sequence of Tensor) – Inputs w.r.t. which the gradient will be +returned (and not accumulated into .grad).

    grad_outputs

    (sequence of Tensor) – The “vector” in the Jacobian-vector +product. Usually gradients w.r.t. each output. None values can be specified for +scalar Tensors or ones that don’t require grad. If a None value would be acceptable +for all grad_tensors, then this argument is optional. Default: None.

    retain_graph

    (bool, optional) – If FALSE, the graph used to compute the +grad will be freed. Note that in nearly all cases setting this option to TRUE is +not needed and often can be worked around in a much more efficient way. +Defaults to the value of create_graph.

    create_graph

    (bool, optional) – If TRUE, graph of the derivative will be constructed, allowing to compute higher order derivative products. Default: FALSE`.

    allow_unused

    (bool, optional) – If FALSE, specifying inputs that were +not used when computing outputs (and therefore their grad is always zero) is an +error. Defaults to FALSE

    + +

    Details

    + +

    If only_inputs is TRUE, the function will only return a list of gradients w.r.t +the specified inputs. If it’s FALSE, then gradient w.r.t. all remaining leaves +will still be computed, and will be accumulated into their .grad attribute.

    + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_tensor(0.5, requires_grad = TRUE) +b <- torch_tensor(0.9, requires_grad = TRUE) +x <- torch_tensor(runif(100)) +y <- 2 * x + 1 +loss <- (y - (w*x + b))^2 +loss <- loss$mean() + +o <- autograd_grad(loss, list(w, b)) +o + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/autograd_set_grad_mode.html b/reference/autograd_set_grad_mode.html new file mode 100644 index 0000000000000000000000000000000000000000..a8ab1c0e4c9caedf100ea46fa4943aa1a82fa72a --- /dev/null +++ b/reference/autograd_set_grad_mode.html @@ -0,0 +1,205 @@ + + + + + + + + +Set grad mode — autograd_set_grad_mode • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sets or disables gradient history.

    +
    + +
    autograd_set_grad_mode(enabled)
    + +

    Arguments

    + + + + + + +
    enabled

    bool wether to enable or disable the gradient recording.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/cuda_current_device.html b/reference/cuda_current_device.html new file mode 100644 index 0000000000000000000000000000000000000000..8496bfc8891fde6bf01be05543042609d1b11d0a --- /dev/null +++ b/reference/cuda_current_device.html @@ -0,0 +1,197 @@ + + + + + + + + +Returns the index of a currently selected device. — cuda_current_device • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Returns the index of a currently selected device.

    +
    + +
    cuda_current_device()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/cuda_device_count.html b/reference/cuda_device_count.html new file mode 100644 index 0000000000000000000000000000000000000000..efb669e8b455da7bee34dafbb250c5fea4c601bc --- /dev/null +++ b/reference/cuda_device_count.html @@ -0,0 +1,197 @@ + + + + + + + + +Returns the number of GPUs available. — cuda_device_count • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Returns the number of GPUs available.

    +
    + +
    cuda_device_count()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/cuda_is_available.html b/reference/cuda_is_available.html new file mode 100644 index 0000000000000000000000000000000000000000..324f843fd67a05badae2f5a42e305bb65d4e961d --- /dev/null +++ b/reference/cuda_is_available.html @@ -0,0 +1,197 @@ + + + + + + + + +Returns a bool indicating if CUDA is currently available. — cuda_is_available • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Returns a bool indicating if CUDA is currently available.

    +
    + +
    cuda_is_available()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/dataloader.html b/reference/dataloader.html new file mode 100644 index 0000000000000000000000000000000000000000..588972f74f94f865c692c061c95da8f2e3068bb8 --- /dev/null +++ b/reference/dataloader.html @@ -0,0 +1,278 @@ + + + + + + + + +Data loader. Combines a dataset and a sampler, and provides +single- or multi-process iterators over the dataset. — dataloader • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Data loader. Combines a dataset and a sampler, and provides +single- or multi-process iterators over the dataset.

    +
    + +
    dataloader(
    +  dataset,
    +  batch_size = 1,
    +  shuffle = FALSE,
    +  sampler = NULL,
    +  batch_sampler = NULL,
    +  num_workers = 0,
    +  collate_fn = NULL,
    +  pin_memory = FALSE,
    +  drop_last = FALSE,
    +  timeout = 0,
    +  worker_init_fn = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    dataset

    (Dataset): dataset from which to load the data.

    batch_size

    (int, optional): how many samples per batch to load +(default: 1).

    shuffle

    (bool, optional): set to TRUE to have the data reshuffled +at every epoch (default: FALSE).

    sampler

    (Sampler, optional): defines the strategy to draw samples from +the dataset. If specified, shuffle must be False.

    batch_sampler

    (Sampler, optional): like sampler, but returns a batch of +indices at a time. Mutually exclusive with batch_size, +shuffle, sampler, and drop_last.

    num_workers

    (int, optional): how many subprocesses to use for data +loading. 0 means that the data will be loaded in the main process. +(default: 0)

    collate_fn

    (callable, optional): merges a list of samples to form a mini-batch.

    pin_memory

    (bool, optional): If TRUE, the data loader will copy tensors +into CUDA pinned memory before returning them. If your data elements +are a custom type, or your collate_fn returns a batch that is a custom type +see the example below.

    drop_last

    (bool, optional): set to TRUE to drop the last incomplete batch, +if the dataset size is not divisible by the batch size. If FALSE and +the size of dataset is not divisible by the batch size, then the last batch +will be smaller. (default: FALSE)

    timeout

    (numeric, optional): if positive, the timeout value for collecting a batch +from workers. Should always be non-negative. (default: 0)

    worker_init_fn

    (callable, optional): If not NULL, this will be called on each +worker subprocess with the worker id (an int in [0, num_workers - 1]) as +input, after seeding and before data loading. (default: NULL)

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/dataloader_make_iter.html b/reference/dataloader_make_iter.html new file mode 100644 index 0000000000000000000000000000000000000000..2457a2f3435e48bf70c52a6f7fa1c748ee875957 --- /dev/null +++ b/reference/dataloader_make_iter.html @@ -0,0 +1,205 @@ + + + + + + + + +Creates an iterator from a DataLoader — dataloader_make_iter • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates an iterator from a DataLoader

    +
    + +
    dataloader_make_iter(dataloader)
    + +

    Arguments

    + + + + + + +
    dataloader

    a dataloader object.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/dataloader_next.html b/reference/dataloader_next.html new file mode 100644 index 0000000000000000000000000000000000000000..f6d153591b8b3902879af4522238d1def92468cc --- /dev/null +++ b/reference/dataloader_next.html @@ -0,0 +1,205 @@ + + + + + + + + +Get the next element of a dataloader iterator — dataloader_next • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Get the next element of a dataloader iterator

    +
    + +
    dataloader_next(iter)
    + +

    Arguments

    + + + + + + +
    iter

    a DataLoader iter created with dataloader_make_iter.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/dataset.html b/reference/dataset.html new file mode 100644 index 0000000000000000000000000000000000000000..e37341508c97f579ab0233d285b9124480940ead --- /dev/null +++ b/reference/dataset.html @@ -0,0 +1,235 @@ + + + + + + + + +An abstract class representing a <code>Dataset</code>. — dataset • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    All datasets that represent a map from keys to data samples should subclass +it. All subclasses should overwrite get_item, supporting fetching a +data sample for a given key. Subclasses could also optionally overwrite +lenght, which is expected to return the size of the dataset by many +~torch.utils.data.Sampler implementations and the default options +of ~torch.utils.data.DataLoader.

    +
    + +
    dataset(name = NULL, inherit = Dataset, ..., parent_env = parent.frame())
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    name

    a name for the dataset. It it's also used as the class +for it.

    inherit

    you can optionally inherit from a dataset when creating a +new dataset.

    ...

    public methods for the dataset class

    parent_env

    An environment to use as the parent of newly-created +objects.

    + +

    Note

    + +

    ~torch.utils.data.DataLoader by default constructs a index +sampler that yields integral indices. To make it work with a map-style +dataset with non-integral indices/keys, a custom sampler must be provided.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/default_dtype.html b/reference/default_dtype.html new file mode 100644 index 0000000000000000000000000000000000000000..c72275329c44fa0244ff0d20454c49a07cdbef40 --- /dev/null +++ b/reference/default_dtype.html @@ -0,0 +1,208 @@ + + + + + + + + +Gets and sets the default floating point dtype. — torch_set_default_dtype • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Gets and sets the default floating point dtype.

    +
    + +
    torch_set_default_dtype(d)
    +
    +torch_get_default_dtype()
    + +

    Arguments

    + + + + + + +
    d

    The default floating point dtype to set. Initially set to +torch_float().

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/enumerate.dataloader.html b/reference/enumerate.dataloader.html new file mode 100644 index 0000000000000000000000000000000000000000..ec845e8a2205229a48c5fcbabd7339adfd6ff676 --- /dev/null +++ b/reference/enumerate.dataloader.html @@ -0,0 +1,214 @@ + + + + + + + + +Enumerate an iterator — enumerate.dataloader • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Enumerate an iterator

    +
    + +
    # S3 method for dataloader
    +enumerate(x, max_len = 1e+06, ...)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    x

    the generator to enumerate.

    max_len

    maximum number of iterations.

    ...

    passed to specific methods.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/enumerate.html b/reference/enumerate.html new file mode 100644 index 0000000000000000000000000000000000000000..9b3979a3066bcf1662f4e19d09fa965b20941368 --- /dev/null +++ b/reference/enumerate.html @@ -0,0 +1,209 @@ + + + + + + + + +Enumerate an iterator — enumerate • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Enumerate an iterator

    +
    + +
    enumerate(x, ...)
    + +

    Arguments

    + + + + + + + + + + +
    x

    the generator to enumerate.

    ...

    passed to specific methods.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/figures/torch.png b/reference/figures/torch.png new file mode 100644 index 0000000000000000000000000000000000000000..61d24b86074b110f4cf3298f417c4148938c8f05 Binary files /dev/null and b/reference/figures/torch.png differ diff --git a/reference/index.html b/reference/index.html new file mode 100644 index 0000000000000000000000000000000000000000..f220701f57831048a5197f05d529c24c36f939d3 --- /dev/null +++ b/reference/index.html @@ -0,0 +1,2965 @@ + + + + + + + + +Function reference • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    AutogradContext

    +

    Class representing the context.

    +

    as_array()

    +

    Converts to array

    +

    autograd_backward()

    +

    Computes the sum of gradients of given tensors w.r.t. graph leaves.

    +

    autograd_function()

    +

    Records operation history and defines formulas for differentiating ops.

    +

    autograd_grad()

    +

    Computes and returns the sum of gradients of outputs w.r.t. the inputs.

    +

    autograd_set_grad_mode()

    +

    Set grad mode

    +

    cuda_current_device()

    +

    Returns the index of a currently selected device.

    +

    cuda_device_count()

    +

    Returns the number of GPUs available.

    +

    cuda_is_available()

    +

    Returns a bool indicating if CUDA is currently available.

    +

    dataloader()

    +

    Data loader. Combines a dataset and a sampler, and provides +single- or multi-process iterators over the dataset.

    +

    dataloader_make_iter()

    +

    Creates an iterator from a DataLoader

    +

    dataloader_next()

    +

    Get the next element of a dataloader iterator

    +

    dataset()

    +

    An abstract class representing a Dataset.

    +

    torch_set_default_dtype() torch_get_default_dtype()

    +

    Gets and sets the default floating point dtype.

    +

    enumerate()

    +

    Enumerate an iterator

    +

    enumerate(<dataloader>)

    +

    Enumerate an iterator

    +

    install_torch()

    +

    Install Torch

    +

    is_dataloader()

    +

    Checks if the object is a dataloader

    +

    is_torch_dtype()

    +

    Check if object is a torch data type

    +

    is_torch_layout()

    +

    Check if an object is a torch layout.

    +

    is_torch_memory_format()

    +

    Check if an object is a memory format

    +

    is_torch_qscheme()

    +

    Checks if an object is a QScheme

    +

    load_state_dict()

    +

    Load a state dict file

    +

    nn_adaptive_avg_pool1d()

    +

    Applies a 1D adaptive average pooling over an input signal composed of several input planes.

    +

    nn_adaptive_avg_pool2d()

    +

    Applies a 2D adaptive average pooling over an input signal composed of several input planes.

    +

    nn_adaptive_avg_pool3d()

    +

    Applies a 3D adaptive average pooling over an input signal composed of several input planes.

    +

    nn_adaptive_log_softmax_with_loss()

    +

    AdaptiveLogSoftmaxWithLoss module

    +

    nn_adaptive_max_pool1d()

    +

    Applies a 1D adaptive max pooling over an input signal composed of several input planes.

    +

    nn_adaptive_max_pool2d()

    +

    Applies a 2D adaptive max pooling over an input signal composed of several input planes.

    +

    nn_adaptive_max_pool3d()

    +

    Applies a 3D adaptive max pooling over an input signal composed of several input planes.

    +

    nn_avg_pool1d()

    +

    Applies a 1D average pooling over an input signal composed of several +input planes.

    +

    nn_avg_pool2d()

    +

    Applies a 2D average pooling over an input signal composed of several input +planes.

    +

    nn_avg_pool3d()

    +

    Applies a 3D average pooling over an input signal composed of several input +planes.

    +

    nn_batch_norm1d()

    +

    BatchNorm1D module

    +

    nn_batch_norm2d()

    +

    BatchNorm2D

    +

    nn_bce_loss()

    +

    Binary cross entropy loss

    +

    nn_bilinear()

    +

    Bilinear module

    +

    nn_celu()

    +

    CELU module

    +

    nn_conv1d()

    +

    Conv1D module

    +

    nn_conv2d()

    +

    Conv2D module

    +

    nn_conv3d()

    +

    Conv3D module

    +

    nn_conv_transpose1d()

    +

    ConvTranspose1D

    +

    nn_conv_transpose2d()

    +

    ConvTranpose2D module

    +

    nn_conv_transpose3d()

    +

    ConvTranpose3D module

    +

    nn_cross_entropy_loss()

    +

    CrossEntropyLoss module

    +

    nn_dropout()

    +

    Dropout module

    +

    nn_dropout2d()

    +

    Dropout2D module

    +

    nn_dropout3d()

    +

    Dropout3D module

    +

    nn_elu()

    +

    ELU module

    +

    nn_embedding()

    +

    Embedding module

    +

    nn_fractional_max_pool2d()

    +

    Applies a 2D fractional max pooling over an input signal composed of several input planes.

    +

    nn_fractional_max_pool3d()

    +

    Applies a 3D fractional max pooling over an input signal composed of several input planes.

    +

    nn_gelu()

    +

    GELU module

    +

    nn_glu()

    +

    GLU module

    +

    nn_hardshrink()

    +

    Hardshwink module

    +

    nn_hardsigmoid()

    +

    Hardsigmoid module

    +

    nn_hardswish()

    +

    Hardswish module

    +

    nn_hardtanh()

    +

    Hardtanh module

    +

    nn_identity()

    +

    Identity module

    +

    nn_init_calculate_gain()

    +

    Calculate gain

    +

    nn_init_constant_()

    +

    Constant initialization

    +

    nn_init_dirac_()

    +

    Dirac initialization

    +

    nn_init_eye_()

    +

    Eye initialization

    +

    nn_init_kaiming_normal_()

    +

    Kaiming normal initialization

    +

    nn_init_kaiming_uniform_()

    +

    Kaiming uniform initialization

    +

    nn_init_normal_()

    +

    Normal initialization

    +

    nn_init_ones_()

    +

    Ones initialization

    +

    nn_init_orthogonal_()

    +

    Orthogonal initialization

    +

    nn_init_sparse_()

    +

    Sparse initialization

    +

    nn_init_trunc_normal_()

    +

    Truncated normal initialization

    +

    nn_init_uniform_()

    +

    Uniform initialization

    +

    nn_init_xavier_normal_()

    +

    Xavier normal initialization

    +

    nn_init_xavier_uniform_()

    +

    Xavier uniform initialization

    +

    nn_init_zeros_()

    +

    Zeros initialization

    +

    nn_leaky_relu()

    +

    LeakyReLU module

    +

    nn_linear()

    +

    Linear module

    +

    nn_log_sigmoid()

    +

    LogSigmoid module

    +

    nn_log_softmax()

    +

    LogSoftmax module

    +

    nn_lp_pool1d()

    +

    Applies a 1D power-average pooling over an input signal composed of several input +planes.

    +

    nn_lp_pool2d()

    +

    Applies a 2D power-average pooling over an input signal composed of several input +planes.

    +

    nn_max_pool1d()

    +

    MaxPool1D module

    +

    nn_max_pool2d()

    +

    MaxPool2D module

    +

    nn_max_pool3d()

    +

    Applies a 3D max pooling over an input signal composed of several input +planes.

    +

    nn_max_unpool1d()

    +

    Computes a partial inverse of MaxPool1d.

    +

    nn_max_unpool2d()

    +

    Computes a partial inverse of MaxPool2d.

    +

    nn_max_unpool3d()

    +

    Computes a partial inverse of MaxPool3d.

    +

    nn_module()

    +

    Base class for all neural network modules.

    +

    nn_module_list()

    +

    Holds submodules in a list.

    +

    nn_multihead_attention()

    +

    MultiHead attention

    +

    nn_prelu()

    +

    PReLU module

    +

    nn_relu()

    +

    ReLU module

    +

    nn_relu6()

    +

    ReLu6 module

    +

    nn_rnn()

    +

    RNN module

    +

    nn_rrelu()

    +

    RReLU module

    +

    nn_selu()

    +

    SELU module

    +

    nn_sequential()

    +

    A sequential container

    +

    nn_sigmoid()

    +

    Sigmoid module

    +

    nn_softmax()

    +

    Softmax module

    +

    nn_softmax2d()

    +

    Softmax2d module

    +

    nn_softmin()

    +

    Softmin

    +

    nn_softplus()

    +

    Softplus module

    +

    nn_softshrink()

    +

    Softshrink module

    +

    nn_softsign()

    +

    Softsign module

    +

    nn_tanh()

    +

    Tanh module

    +

    nn_tanhshrink()

    +

    Tanhshrink module

    +

    nn_threshold()

    +

    Threshoold module

    +

    nn_utils_rnn_pack_padded_sequence()

    +

    Packs a Tensor containing padded sequences of variable length.

    +

    nn_utils_rnn_pack_sequence()

    +

    Packs a list of variable length Tensors

    +

    nn_utils_rnn_pad_packed_sequence()

    +

    Pads a packed batch of variable length sequences.

    +

    nn_utils_rnn_pad_sequence()

    +

    Pad a list of variable length Tensors with padding_value

    +

    nnf_adaptive_avg_pool1d()

    +

    Adaptive_avg_pool1d

    +

    nnf_adaptive_avg_pool2d()

    +

    Adaptive_avg_pool2d

    +

    nnf_adaptive_avg_pool3d()

    +

    Adaptive_avg_pool3d

    +

    nnf_adaptive_max_pool1d()

    +

    Adaptive_max_pool1d

    +

    nnf_adaptive_max_pool2d()

    +

    Adaptive_max_pool2d

    +

    nnf_adaptive_max_pool3d()

    +

    Adaptive_max_pool3d

    +

    nnf_affine_grid()

    +

    Affine_grid

    +

    nnf_alpha_dropout()

    +

    Alpha_dropout

    +

    nnf_avg_pool1d()

    +

    Avg_pool1d

    +

    nnf_avg_pool2d()

    +

    Avg_pool2d

    +

    nnf_avg_pool3d()

    +

    Avg_pool3d

    +

    nnf_batch_norm()

    +

    Batch_norm

    +

    nnf_bilinear()

    +

    Bilinear

    +

    nnf_binary_cross_entropy()

    +

    Binary_cross_entropy

    +

    nnf_binary_cross_entropy_with_logits()

    +

    Binary_cross_entropy_with_logits

    +

    nnf_celu() nnf_celu_()

    +

    Celu

    +

    nnf_conv1d()

    +

    Conv1d

    +

    nnf_conv2d()

    +

    Conv2d

    +

    nnf_conv3d()

    +

    Conv3d

    +

    nnf_conv_tbc()

    +

    Conv_tbc

    +

    nnf_conv_transpose1d()

    +

    Conv_transpose1d

    +

    nnf_conv_transpose2d()

    +

    Conv_transpose2d

    +

    nnf_conv_transpose3d()

    +

    Conv_transpose3d

    +

    nnf_cosine_embedding_loss()

    +

    Cosine_embedding_loss

    +

    nnf_cosine_similarity()

    +

    Cosine_similarity

    +

    nnf_cross_entropy()

    +

    Cross_entropy

    +

    nnf_ctc_loss()

    +

    Ctc_loss

    +

    nnf_dropout()

    +

    Dropout

    +

    nnf_dropout2d()

    +

    Dropout2d

    +

    nnf_dropout3d()

    +

    Dropout3d

    +

    nnf_elu() nnf_elu_()

    +

    Elu

    +

    nnf_embedding()

    +

    Embedding

    +

    nnf_embedding_bag()

    +

    Embedding_bag

    +

    nnf_fold()

    +

    Fold

    +

    nnf_fractional_max_pool2d()

    +

    Fractional_max_pool2d

    +

    nnf_fractional_max_pool3d()

    +

    Fractional_max_pool3d

    +

    nnf_gelu()

    +

    Gelu

    +

    nnf_glu()

    +

    Glu

    +

    nnf_grid_sample()

    +

    Grid_sample

    +

    nnf_group_norm()

    +

    Group_norm

    +

    nnf_gumbel_softmax()

    +

    Gumbel_softmax

    +

    nnf_hardshrink()

    +

    Hardshrink

    +

    nnf_hardsigmoid()

    +

    Hardsigmoid

    +

    nnf_hardswish()

    +

    Hardswish

    +

    nnf_hardtanh() nnf_hardtanh_()

    +

    Hardtanh

    +

    nnf_hinge_embedding_loss()

    +

    Hinge_embedding_loss

    +

    nnf_instance_norm()

    +

    Instance_norm

    +

    nnf_interpolate()

    +

    Interpolate

    +

    nnf_kl_div()

    +

    Kl_div

    +

    nnf_l1_loss()

    +

    L1_loss

    +

    nnf_layer_norm()

    +

    Layer_norm

    +

    nnf_leaky_relu()

    +

    Leaky_relu

    +

    nnf_linear()

    +

    Linear

    +

    nnf_local_response_norm()

    +

    Local_response_norm

    +

    nnf_log_softmax()

    +

    Log_softmax

    +

    nnf_logsigmoid()

    +

    Logsigmoid

    +

    nnf_lp_pool1d()

    +

    Lp_pool1d

    +

    nnf_lp_pool2d()

    +

    Lp_pool2d

    +

    nnf_margin_ranking_loss()

    +

    Margin_ranking_loss

    +

    nnf_max_pool1d()

    +

    Max_pool1d

    +

    nnf_max_pool2d()

    +

    Max_pool2d

    +

    nnf_max_pool3d()

    +

    Max_pool3d

    +

    nnf_max_unpool1d()

    +

    Max_unpool1d

    +

    nnf_max_unpool2d()

    +

    Max_unpool2d

    +

    nnf_max_unpool3d()

    +

    Max_unpool3d

    +

    nnf_mse_loss()

    +

    Mse_loss

    +

    nnf_multi_head_attention_forward()

    +

    Multi head attention forward

    +

    nnf_multi_margin_loss()

    +

    Multi_margin_loss

    +

    nnf_multilabel_margin_loss()

    +

    Multilabel_margin_loss

    +

    nnf_multilabel_soft_margin_loss()

    +

    Multilabel_soft_margin_loss

    +

    nnf_nll_loss()

    +

    Nll_loss

    +

    nnf_normalize()

    +

    Normalize

    +

    nnf_one_hot()

    +

    One_hot

    +

    nnf_pad()

    +

    Pad

    +

    nnf_pairwise_distance()

    +

    Pairwise_distance

    +

    nnf_pdist()

    +

    Pdist

    +

    nnf_pixel_shuffle()

    +

    Pixel_shuffle

    +

    nnf_poisson_nll_loss()

    +

    Poisson_nll_loss

    +

    nnf_prelu()

    +

    Prelu

    +

    nnf_relu() nnf_relu_()

    +

    Relu

    +

    nnf_relu6()

    +

    Relu6

    +

    nnf_rrelu() nnf_rrelu_()

    +

    Rrelu

    +

    nnf_selu() nnf_selu_()

    +

    Selu

    +

    nnf_sigmoid()

    +

    Sigmoid

    +

    nnf_smooth_l1_loss()

    +

    Smooth_l1_loss

    +

    nnf_soft_margin_loss()

    +

    Soft_margin_loss

    +

    nnf_softmax()

    +

    Softmax

    +

    nnf_softmin()

    +

    Softmin

    +

    nnf_softplus()

    +

    Softplus

    +

    nnf_softshrink()

    +

    Softshrink

    +

    nnf_softsign()

    +

    Softsign

    +

    nnf_tanhshrink()

    +

    Tanhshrink

    +

    nnf_threshold() nnf_threshold_()

    +

    Threshold

    +

    nnf_triplet_margin_loss()

    +

    Triplet_margin_loss

    +

    nnf_unfold()

    +

    Unfold

    +

    optim_adam()

    +

    Implements Adam algorithm.

    +

    optim_required()

    +

    Dummy value indicating a required value.

    +

    optim_sgd()

    +

    SGD optimizer

    +

    tensor_dataset()

    +

    Dataset wrapping tensors.

    +

    torch_abs

    +

    Abs

    +

    torch_acos

    +

    Acos

    +

    torch_adaptive_avg_pool1d

    +

    Adaptive_avg_pool1d

    +

    torch_add

    +

    Add

    +

    torch_addbmm

    +

    Addbmm

    +

    torch_addcdiv

    +

    Addcdiv

    +

    torch_addcmul

    +

    Addcmul

    +

    torch_addmm

    +

    Addmm

    +

    torch_addmv

    +

    Addmv

    +

    torch_addr

    +

    Addr

    +

    torch_allclose

    +

    Allclose

    +

    torch_angle

    +

    Angle

    +

    torch_arange

    +

    Arange

    +

    torch_argmax

    +

    Argmax

    +

    torch_argmin

    +

    Argmin

    +

    torch_argsort

    +

    Argsort

    +

    torch_as_strided

    +

    As_strided

    +

    torch_asin

    +

    Asin

    +

    torch_atan

    +

    Atan

    +

    torch_atan2

    +

    Atan2

    +

    torch_avg_pool1d

    +

    Avg_pool1d

    +

    torch_baddbmm

    +

    Baddbmm

    +

    torch_bartlett_window

    +

    Bartlett_window

    +

    torch_bernoulli

    +

    Bernoulli

    +

    torch_bincount

    +

    Bincount

    +

    torch_bitwise_and

    +

    Bitwise_and

    +

    torch_bitwise_not

    +

    Bitwise_not

    +

    torch_bitwise_or

    +

    Bitwise_or

    +

    torch_bitwise_xor

    +

    Bitwise_xor

    +

    torch_blackman_window

    +

    Blackman_window

    +

    torch_bmm

    +

    Bmm

    +

    torch_broadcast_tensors

    +

    Broadcast_tensors

    +

    torch_can_cast

    +

    Can_cast

    +

    torch_cartesian_prod

    +

    Cartesian_prod

    +

    torch_cat

    +

    Cat

    +

    torch_cdist

    +

    Cdist

    +

    torch_ceil

    +

    Ceil

    +

    torch_celu_

    +

    Celu_

    +

    torch_chain_matmul

    +

    Chain_matmul

    +

    torch_cholesky

    +

    Cholesky

    +

    torch_cholesky_inverse

    +

    Cholesky_inverse

    +

    torch_cholesky_solve

    +

    Cholesky_solve

    +

    torch_chunk

    +

    Chunk

    +

    torch_clamp

    +

    Clamp

    +

    torch_combinations

    +

    Combinations

    +

    torch_conj

    +

    Conj

    +

    torch_conv1d

    +

    Conv1d

    +

    torch_conv2d

    +

    Conv2d

    +

    torch_conv3d

    +

    Conv3d

    +

    torch_conv_tbc

    +

    Conv_tbc

    +

    torch_conv_transpose1d

    +

    Conv_transpose1d

    +

    torch_conv_transpose2d

    +

    Conv_transpose2d

    +

    torch_conv_transpose3d

    +

    Conv_transpose3d

    +

    torch_cos

    +

    Cos

    +

    torch_cosh

    +

    Cosh

    +

    torch_cosine_similarity

    +

    Cosine_similarity

    +

    torch_cross

    +

    Cross

    +

    torch_cummax

    +

    Cummax

    +

    torch_cummin

    +

    Cummin

    +

    torch_cumprod

    +

    Cumprod

    +

    torch_cumsum

    +

    Cumsum

    +

    torch_det

    +

    Det

    +

    torch_device()

    +

    Create a Device object

    +

    torch_diag

    +

    Diag

    +

    torch_diag_embed

    +

    Diag_embed

    +

    torch_diagflat

    +

    Diagflat

    +

    torch_diagonal

    +

    Diagonal

    +

    torch_digamma

    +

    Digamma

    +

    torch_dist

    +

    Dist

    +

    torch_div

    +

    Div

    +

    torch_dot

    +

    Dot

    +

    torch_float32() torch_float() torch_float64() torch_double() torch_float16() torch_half() torch_uint8() torch_int8() torch_int16() torch_short() torch_int32() torch_int() torch_int64() torch_long() torch_bool() torch_quint8() torch_qint8() torch_qint32()

    +

    Torch data types

    +

    torch_eig

    +

    Eig

    +

    torch_einsum

    +

    Einsum

    +

    torch_empty

    +

    Empty

    +

    torch_empty_like

    +

    Empty_like

    +

    torch_empty_strided

    +

    Empty_strided

    +

    torch_eq

    +

    Eq

    +

    torch_equal

    +

    Equal

    +

    torch_erf

    +

    Erf

    +

    torch_erfc

    +

    Erfc

    +

    torch_erfinv

    +

    Erfinv

    +

    torch_exp

    +

    Exp

    +

    torch_expm1

    +

    Expm1

    +

    torch_eye

    +

    Eye

    +

    torch_fft

    +

    Fft

    +

    torch_finfo()

    +

    Floating point type info

    +

    torch_flatten

    +

    Flatten

    +

    torch_flip

    +

    Flip

    +

    torch_floor

    +

    Floor

    +

    torch_floor_divide

    +

    Floor_divide

    +

    torch_fmod

    +

    Fmod

    +

    torch_frac

    +

    Frac

    +

    torch_full

    +

    Full

    +

    torch_full_like

    +

    Full_like

    +

    torch_gather

    +

    Gather

    +

    torch_ge

    +

    Ge

    +

    torch_generator()

    +

    Create a Generator object

    +

    torch_geqrf

    +

    Geqrf

    +

    torch_ger

    +

    Ger

    +

    torch_gt

    +

    Gt

    +

    torch_hamming_window

    +

    Hamming_window

    +

    torch_hann_window

    +

    Hann_window

    +

    torch_histc

    +

    Histc

    +

    torch_ifft

    +

    Ifft

    +

    torch_iinfo()

    +

    Integer type info

    +

    torch_imag

    +

    Imag

    +

    torch_index_select

    +

    Index_select

    +

    torch_inverse

    +

    Inverse

    +

    torch_irfft

    +

    Irfft

    +

    torch_is_complex

    +

    Is_complex

    +

    torch_is_floating_point

    +

    Is_floating_point

    +

    torch_is_installed()

    +

    Verifies if torch is installed

    +

    torch_isfinite

    +

    Isfinite

    +

    torch_isinf

    +

    Isinf

    +

    torch_isnan

    +

    Isnan

    +

    torch_kthvalue

    +

    Kthvalue

    +

    torch_strided() torch_sparse_coo()

    +

    Creates the corresponding layout

    +

    torch_le

    +

    Le

    +

    torch_lerp

    +

    Lerp

    +

    torch_lgamma

    +

    Lgamma

    +

    torch_linspace

    +

    Linspace

    +

    torch_load()

    +

    Loads a saved object

    +

    torch_log

    +

    Log

    +

    torch_log10

    +

    Log10

    +

    torch_log1p

    +

    Log1p

    +

    torch_log2

    +

    Log2

    +

    torch_logdet

    +

    Logdet

    +

    torch_logical_and

    +

    Logical_and

    +

    torch_logical_not

    +

    Logical_not

    +

    torch_logical_or

    +

    Logical_or

    +

    torch_logical_xor

    +

    Logical_xor

    +

    torch_logspace

    +

    Logspace

    +

    torch_logsumexp

    +

    Logsumexp

    +

    torch_lstsq

    +

    Lstsq

    +

    torch_lt

    +

    Lt

    +

    torch_lu()

    +

    LU

    +

    torch_lu_solve

    +

    Lu_solve

    +

    torch_manual_seed()

    +

    Sets the seed for generating random numbers.

    +

    torch_masked_select

    +

    Masked_select

    +

    torch_matmul

    +

    Matmul

    +

    torch_matrix_power

    +

    Matrix_power

    +

    torch_matrix_rank

    +

    Matrix_rank

    +

    torch_max

    +

    Max

    +

    torch_mean

    +

    Mean

    +

    torch_median

    +

    Median

    +

    torch_contiguous_format() torch_preserve_format() torch_channels_last_format()

    +

    Memory format

    +

    torch_meshgrid

    +

    Meshgrid

    +

    torch_min

    +

    Min

    +

    torch_mm

    +

    Mm

    +

    torch_mode

    +

    Mode

    +

    torch_mul

    +

    Mul

    +

    torch_multinomial

    +

    Multinomial

    +

    torch_mv

    +

    Mv

    +

    torch_mvlgamma

    +

    Mvlgamma

    +

    torch_narrow

    +

    Narrow

    +

    torch_ne

    +

    Ne

    +

    torch_neg

    +

    Neg

    +

    torch_nonzero

    +

    Nonzero

    +

    torch_norm

    +

    Norm

    +

    torch_normal

    +

    Normal

    +

    torch_ones

    +

    Ones

    +

    torch_ones_like

    +

    Ones_like

    +

    torch_orgqr

    +

    Orgqr

    +

    torch_ormqr

    +

    Ormqr

    +

    torch_pdist

    +

    Pdist

    +

    torch_pinverse

    +

    Pinverse

    +

    torch_pixel_shuffle

    +

    Pixel_shuffle

    +

    torch_poisson

    +

    Poisson

    +

    torch_polygamma

    +

    Polygamma

    +

    torch_pow

    +

    Pow

    +

    torch_prod

    +

    Prod

    +

    torch_promote_types

    +

    Promote_types

    +

    torch_qr

    +

    Qr

    +

    torch_per_channel_affine() torch_per_tensor_affine() torch_per_channel_symmetric() torch_per_tensor_symmetric()

    +

    Creates the corresponding Scheme object

    +

    torch_quantize_per_channel

    +

    Quantize_per_channel

    +

    torch_quantize_per_tensor

    +

    Quantize_per_tensor

    +

    torch_rand

    +

    Rand

    +

    torch_rand_like

    +

    Rand_like

    +

    torch_randint

    +

    Randint

    +

    torch_randint_like

    +

    Randint_like

    +

    torch_randn

    +

    Randn

    +

    torch_randn_like

    +

    Randn_like

    +

    torch_randperm

    +

    Randperm

    +

    torch_range

    +

    Range

    +

    torch_real

    +

    Real

    +

    torch_reciprocal

    +

    Reciprocal

    +

    torch_reduction_sum() torch_reduction_mean() torch_reduction_none()

    +

    Creates the reduction objet

    +

    torch_relu_

    +

    Relu_

    +

    torch_remainder

    +

    Remainder

    +

    torch_renorm

    +

    Renorm

    +

    torch_repeat_interleave

    +

    Repeat_interleave

    +

    torch_reshape

    +

    Reshape

    +

    torch_result_type

    +

    Result_type

    +

    torch_rfft

    +

    Rfft

    +

    torch_roll

    +

    Roll

    +

    torch_rot90

    +

    Rot90

    +

    torch_round

    +

    Round

    +

    torch_rrelu_

    +

    Rrelu_

    +

    torch_rsqrt

    +

    Rsqrt

    +

    torch_save()

    +

    Saves an object to a disk file.

    +

    torch_selu_

    +

    Selu_

    +

    torch_sigmoid

    +

    Sigmoid

    +

    torch_sign

    +

    Sign

    +

    torch_sin

    +

    Sin

    +

    torch_sinh

    +

    Sinh

    +

    torch_slogdet

    +

    Slogdet

    +

    torch_solve

    +

    Solve

    +

    torch_sort

    +

    Sort

    +

    torch_sparse_coo_tensor

    +

    Sparse_coo_tensor

    +

    torch_split

    +

    Split

    +

    torch_sqrt

    +

    Sqrt

    +

    torch_square

    +

    Square

    +

    torch_squeeze

    +

    Squeeze

    +

    torch_stack

    +

    Stack

    +

    torch_std

    +

    Std

    +

    torch_std_mean

    +

    Std_mean

    +

    torch_stft

    +

    Stft

    +

    torch_sum

    +

    Sum

    +

    torch_svd

    +

    Svd

    +

    torch_symeig

    +

    Symeig

    +

    torch_t

    +

    T

    +

    torch_take

    +

    Take

    +

    torch_tan

    +

    Tan

    +

    torch_tanh

    +

    Tanh

    +

    torch_tensor()

    +

    Converts R objects to a torch tensor

    +

    torch_tensordot

    +

    Tensordot

    +

    torch_threshold_

    +

    Threshold_

    +

    torch_topk

    +

    Topk

    +

    torch_trace

    +

    Trace

    +

    torch_transpose

    +

    Transpose

    +

    torch_trapz

    +

    Trapz

    +

    torch_triangular_solve

    +

    Triangular_solve

    +

    torch_tril

    +

    Tril

    +

    torch_tril_indices

    +

    Tril_indices

    +

    torch_triu

    +

    Triu

    +

    torch_triu_indices

    +

    Triu_indices

    +

    torch_true_divide

    +

    True_divide

    +

    torch_trunc

    +

    Trunc

    +

    torch_unbind

    +

    Unbind

    +

    torch_unique_consecutive

    +

    Unique_consecutive

    +

    torch_unsqueeze

    +

    Unsqueeze

    +

    torch_var

    +

    Var

    +

    torch_var_mean

    +

    Var_mean

    +

    torch_where

    +

    Where

    +

    torch_zeros

    +

    Zeros

    +

    torch_zeros_like

    +

    Zeros_like

    +

    with_enable_grad()

    +

    Enable grad

    +

    with_no_grad()

    +

    Temporarily modify gradient recording.

    +
    + + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/install_torch.html b/reference/install_torch.html new file mode 100644 index 0000000000000000000000000000000000000000..c76dada89f9ec20c5ae50ac0d197a89a454d3fe6 --- /dev/null +++ b/reference/install_torch.html @@ -0,0 +1,234 @@ + + + + + + + + +Install Torch — install_torch • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Installs Torch and its dependencies.

    +
    + +
    install_torch(
    +  version = "1.5.0",
    +  type = install_type(version = version),
    +  reinstall = FALSE,
    +  path = install_path(),
    +  ...
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    version

    The Torch version to install.

    type

    The installation type for Torch. Valid values are "cpu" or the 'CUDA' version.

    reinstall

    Re-install Torch even if its already installed?

    path

    Optional path to install or check for an already existing installation.

    ...

    other optional arguments (like load for manual installation.)

    + +

    Details

    + +

    When using path to install in a specific location, make sure the TORCH_HOME environment +variable is set to this same path to reuse this installation. The TORCH_INSTALL environment +variable can be set to 0 to prevent auto-installing torch and TORCH_LOAD set to 0 +to avoid loading dependencies automatically. These environment variables are meant for advanced use +cases and troubleshootinng only.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/is_dataloader.html b/reference/is_dataloader.html new file mode 100644 index 0000000000000000000000000000000000000000..490be567263016e17b76ce1a30a1aa806443b733 --- /dev/null +++ b/reference/is_dataloader.html @@ -0,0 +1,205 @@ + + + + + + + + +Checks if the object is a dataloader — is_dataloader • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Checks if the object is a dataloader

    +
    + +
    is_dataloader(x)
    + +

    Arguments

    + + + + + + +
    x

    object to check

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/is_torch_dtype.html b/reference/is_torch_dtype.html new file mode 100644 index 0000000000000000000000000000000000000000..fd59ed56b36671eeef64d68edc63d425b64f7870 --- /dev/null +++ b/reference/is_torch_dtype.html @@ -0,0 +1,205 @@ + + + + + + + + +Check if object is a torch data type — is_torch_dtype • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Check if object is a torch data type

    +
    + +
    is_torch_dtype(x)
    + +

    Arguments

    + + + + + + +
    x

    object to check.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/is_torch_layout.html b/reference/is_torch_layout.html new file mode 100644 index 0000000000000000000000000000000000000000..b6fb134b340a08c885e1385bc3d4df781eadb985 --- /dev/null +++ b/reference/is_torch_layout.html @@ -0,0 +1,205 @@ + + + + + + + + +Check if an object is a torch layout. — is_torch_layout • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Check if an object is a torch layout.

    +
    + +
    is_torch_layout(x)
    + +

    Arguments

    + + + + + + +
    x

    object to check

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/is_torch_memory_format.html b/reference/is_torch_memory_format.html new file mode 100644 index 0000000000000000000000000000000000000000..41e87487eaa407666be11f83de893d9a5a111ad3 --- /dev/null +++ b/reference/is_torch_memory_format.html @@ -0,0 +1,205 @@ + + + + + + + + +Check if an object is a memory format — is_torch_memory_format • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Check if an object is a memory format

    +
    + +
    is_torch_memory_format(x)
    + +

    Arguments

    + + + + + + +
    x

    object to check

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/is_torch_qscheme.html b/reference/is_torch_qscheme.html new file mode 100644 index 0000000000000000000000000000000000000000..8be769665c23c304955c842d1f2aeabd65f2eea1 --- /dev/null +++ b/reference/is_torch_qscheme.html @@ -0,0 +1,205 @@ + + + + + + + + +Checks if an object is a QScheme — is_torch_qscheme • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Checks if an object is a QScheme

    +
    + +
    is_torch_qscheme(x)
    + +

    Arguments

    + + + + + + +
    x

    object to check

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/load_state_dict.html b/reference/load_state_dict.html new file mode 100644 index 0000000000000000000000000000000000000000..e096995f3696e7b446ff985fc738ae5400c2f82c --- /dev/null +++ b/reference/load_state_dict.html @@ -0,0 +1,218 @@ + + + + + + + + +Load a state dict file — load_state_dict • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This function should only be used to load models saved in python. +For it to work correctly you need to use torch.save with the flag: +_use_new_zipfile_serialization=True and also remove all nn.Parameter +classes from the tensors in the dict.

    +
    + +
    load_state_dict(path)
    + +

    Arguments

    + + + + + + +
    path

    to the state dict file

    + +

    Value

    + +

    a named list of tensors.

    +

    Details

    + +

    The above might change with development of this +in pytorch's C++ api.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_adaptive_avg_pool1d.html b/reference/nn_adaptive_avg_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..f0082b0dfc6d752b906800a5734abd7735fef01a --- /dev/null +++ b/reference/nn_adaptive_avg_pool1d.html @@ -0,0 +1,215 @@ + + + + + + + + +Applies a 1D adaptive average pooling over an input signal composed of several input planes. — nn_adaptive_avg_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The output size is H, for any input size. +The number of output features is equal to the number of input planes.

    +
    + +
    nn_adaptive_avg_pool1d(output_size)
    + +

    Arguments

    + + + + + + +
    output_size

    the target output size H

    + + +

    Examples

    +
    if (torch_is_installed()) { +# target output size of 5 +m = nn_adaptive_avg_pool1d(5) +input <- torch_randn(1, 64, 8) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_adaptive_avg_pool2d.html b/reference/nn_adaptive_avg_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..76f7880fed9f5286a2bd179a35797f290ff8ed54 --- /dev/null +++ b/reference/nn_adaptive_avg_pool2d.html @@ -0,0 +1,222 @@ + + + + + + + + +Applies a 2D adaptive average pooling over an input signal composed of several input planes. — nn_adaptive_avg_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The output is of size H x W, for any input size. +The number of output features is equal to the number of input planes.

    +
    + +
    nn_adaptive_avg_pool2d(output_size)
    + +

    Arguments

    + + + + + + +
    output_size

    the target output size of the image of the form H x W. +Can be a tuple (H, W) or a single H for a square image H x H. +H and W can be either a int, or NULL which means the size will +be the same as that of the input.

    + + +

    Examples

    +
    if (torch_is_installed()) { +# target output size of 5x7 +m <- nn_adaptive_avg_pool2d(c(5,7)) +input <- torch_randn(1, 64, 8, 9) +output <- m(input) +# target output size of 7x7 (square) +m <- nn_adaptive_avg_pool2d(7) +input <- torch_randn(1, 64, 10, 9) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_adaptive_avg_pool3d.html b/reference/nn_adaptive_avg_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..24f5f0d9b53e99a82269c3337f7aa76c82287e4f --- /dev/null +++ b/reference/nn_adaptive_avg_pool3d.html @@ -0,0 +1,222 @@ + + + + + + + + +Applies a 3D adaptive average pooling over an input signal composed of several input planes. — nn_adaptive_avg_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The output is of size D x H x W, for any input size. +The number of output features is equal to the number of input planes.

    +
    + +
    nn_adaptive_avg_pool3d(output_size)
    + +

    Arguments

    + + + + + + +
    output_size

    the target output size of the form D x H x W. +Can be a tuple (D, H, W) or a single number D for a cube D x D x D. +D, H and W can be either a int, or None which means the size will +be the same as that of the input.

    + + +

    Examples

    +
    if (torch_is_installed()) { +# target output size of 5x7x9 +m <- nn_adaptive_avg_pool3d(c(5,7,9)) +input <- torch_randn(1, 64, 8, 9, 10) +output <- m(input) +# target output size of 7x7x7 (cube) +m <- nn_adaptive_avg_pool3d(7) +input <- torch_randn(1, 64, 10, 9, 8) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_adaptive_log_softmax_with_loss.html b/reference/nn_adaptive_log_softmax_with_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..ff9dfbdad6e7cb5a950efe4dacbc6e17df6847ec --- /dev/null +++ b/reference/nn_adaptive_log_softmax_with_loss.html @@ -0,0 +1,303 @@ + + + + + + + + +AdaptiveLogSoftmaxWithLoss module — nn_adaptive_log_softmax_with_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + + + +
    nn_adaptive_log_softmax_with_loss(
    +  in_features,
    +  n_classes,
    +  cutoffs,
    +  div_value = 4,
    +  head_bias = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    in_features

    (int): Number of features in the input tensor

    n_classes

    (int): Number of classes in the dataset

    cutoffs

    (Sequence): Cutoffs used to assign targets to their buckets

    div_value

    (float, optional): value used as an exponent to compute sizes +of the clusters. Default: 4.0

    head_bias

    (bool, optional): If True, adds a bias term to the 'head' of the +adaptive softmax. Default: False

    + +

    Value

    + +

    NamedTuple with output and loss fields:

      +
    • output is a Tensor of size N containing computed target +log probabilities for each example

    • +
    • loss is a Scalar representing the computed negative +log likelihood loss

    • +
    + +

    Details

    + +

    Adaptive softmax is an approximate strategy for training models with large +output spaces. It is most effective when the label distribution is highly +imbalanced, for example in natural language modelling, where the word +frequency distribution approximately follows the Zipf's law.

    +

    Adaptive softmax partitions the labels into several clusters, according to +their frequency. These clusters may contain different number of targets +each.

    +

    Additionally, clusters containing less frequent labels assign lower +dimensional embeddings to those labels, which speeds up the computation. +For each minibatch, only clusters for which at least one target is +present are evaluated.

    +

    The idea is that the clusters which are accessed frequently +(like the first one, containing most frequent labels), should also be cheap +to compute -- that is, contain a small number of assigned labels. +We highly recommend taking a look at the original paper for more details.

      +
    • cutoffs should be an ordered Sequence of integers sorted +in the increasing order. +It controls number of clusters and the partitioning of targets into +clusters. For example setting cutoffs = c(10, 100, 1000) +means that first 10 targets will be assigned +to the 'head' of the adaptive softmax, targets 11, 12, ..., 100 will be +assigned to the first cluster, and targets 101, 102, ..., 1000 will be +assigned to the second cluster, while targets +1001, 1002, ..., n_classes - 1 will be assigned +to the last, third cluster.

    • +
    • div_value is used to compute the size of each additional cluster, +which is given as +\(\left\lfloor\frac{\mbox{in\_features}}{\mbox{div\_value}^{idx}}\right\rfloor\), +where \(idx\) is the cluster index (with clusters +for less frequent words having larger indices, +and indices starting from \(1\)).

    • +
    • head_bias if set to True, adds a bias term to the 'head' of the +adaptive softmax. See paper for details. Set to False in the official +implementation.

    • +
    + +

    Note

    + +

    This module returns a NamedTuple with output +and loss fields. See further documentation for details.

    +

    To compute log-probabilities for all classes, the log_prob +method can be used.

    +

    Warning

    + + + +

    Labels passed as inputs to this module should be sorted according to +their frequency. This means that the most frequent label should be +represented by the index 0, and the least frequent +label should be represented by the index n_classes - 1.

    +

    Shape

    + + + +
      +
    • input: \((N, \mbox{in\_features})\)

    • +
    • target: \((N)\) where each value satisfies \(0 <= \mbox{target[i]} <= \mbox{n\_classes}\)

    • +
    • output1: \((N)\)

    • +
    • output2: Scalar

    • +
    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_adaptive_max_pool1d.html b/reference/nn_adaptive_max_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..f764f003b8c55996d3837af854ddc62296d6aa04 --- /dev/null +++ b/reference/nn_adaptive_max_pool1d.html @@ -0,0 +1,220 @@ + + + + + + + + +Applies a 1D adaptive max pooling over an input signal composed of several input planes. — nn_adaptive_max_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The output size is H, for any input size. +The number of output features is equal to the number of input planes.

    +
    + +
    nn_adaptive_max_pool1d(output_size, return_indices = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    output_size

    the target output size H

    return_indices

    if TRUE, will return the indices along with the outputs. +Useful to pass to nn_max_unpool1d(). Default: FALSE

    + + +

    Examples

    +
    if (torch_is_installed()) { +# target output size of 5 +m <- nn_adaptive_max_pool1d(5) +input <- torch_randn(1, 64, 8) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_adaptive_max_pool2d.html b/reference/nn_adaptive_max_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..8bbee40837e5dc94719437a836b48b926a5adae6 --- /dev/null +++ b/reference/nn_adaptive_max_pool2d.html @@ -0,0 +1,227 @@ + + + + + + + + +Applies a 2D adaptive max pooling over an input signal composed of several input planes. — nn_adaptive_max_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The output is of size H x W, for any input size. +The number of output features is equal to the number of input planes.

    +
    + +
    nn_adaptive_max_pool2d(output_size, return_indices = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    output_size

    the target output size of the image of the form H x W. +Can be a tuple (H, W) or a single H for a square image H x H. +H and W can be either a int, or None which means the size will +be the same as that of the input.

    return_indices

    if TRUE, will return the indices along with the outputs. +Useful to pass to nn_max_unpool2d(). Default: FALSE

    + + +

    Examples

    +
    if (torch_is_installed()) { +# target output size of 5x7 +m <- nn_adaptive_max_pool2d(c(5,7)) +input <- torch_randn(1, 64, 8, 9) +output <- m(input) +# target output size of 7x7 (square) +m <- nn_adaptive_max_pool2d(7) +input <- torch_randn(1, 64, 10, 9) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_adaptive_max_pool3d.html b/reference/nn_adaptive_max_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..0e8749c3ecfe85153aa293630e25568d7f4cd484 --- /dev/null +++ b/reference/nn_adaptive_max_pool3d.html @@ -0,0 +1,227 @@ + + + + + + + + +Applies a 3D adaptive max pooling over an input signal composed of several input planes. — nn_adaptive_max_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The output is of size D x H x W, for any input size. +The number of output features is equal to the number of input planes.

    +
    + +
    nn_adaptive_max_pool3d(output_size, return_indices = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    output_size

    the target output size of the image of the form D x H x W. +Can be a tuple (D, H, W) or a single D for a cube D x D x D. +D, H and W can be either a int, or None which means the size will +be the same as that of the input.

    return_indices

    if TRUE, will return the indices along with the outputs. +Useful to pass to nn_max_unpool3d(). Default: FALSE

    + + +

    Examples

    +
    if (torch_is_installed()) { +# target output size of 5x7x9 +m <- nn_adaptive_max_pool3d(c(5,7,9)) +input <- torch_randn(1, 64, 8, 9, 10) +output <- m(input) +# target output size of 7x7x7 (cube) +m <- nn_adaptive_max_pool3d(7) +input <- torch_randn(1, 64, 10, 9, 8) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_avg_pool1d.html b/reference/nn_avg_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..6700c5895a478e3004611761ba235bd4f319f1ad --- /dev/null +++ b/reference/nn_avg_pool1d.html @@ -0,0 +1,269 @@ + + + + + + + + +Applies a 1D average pooling over an input signal composed of several +input planes. — nn_avg_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    In the simplest case, the output value of the layer with input size \((N, C, L)\), +output \((N, C, L_{out})\) and kernel_size \(k\) +can be precisely described as:

    +

    $$ + \text{out}(N_i, C_j, l) = \frac{1}{k} \sum_{m=0}^{k-1} +\text{input}(N_i, C_j, \text{stride} \times l + m) +$$

    +
    + +
    nn_avg_pool1d(
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  ceil_mode = FALSE,
    +  count_include_pad = TRUE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window

    stride

    the stride of the window. Default value is kernel_size

    padding

    implicit zero padding to be added on both sides

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    count_include_pad

    when TRUE, will include the zero-padding in the averaging calculation

    + +

    Details

    + +

    If padding is non-zero, then the input is implicitly zero-padded on both sides +for padding number of points.

    +

    The parameters kernel_size, stride, padding can each be +an int or a one-element tuple.

    +

    Shape

    + + + +
      +
    • Input: \((N, C, L_{in})\)

    • +
    • Output: \((N, C, L_{out})\), where

    • +
    + +

    $$ + L_{out} = \left\lfloor \frac{L_{in} + + 2 \times \text{padding} - \text{kernel\_size}}{\text{stride}} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +# pool with window of size=3, stride=2 +m <- nn_avg_pool1d(3, stride=2) +m(torch_randn(1, 1, 8)) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_avg_pool2d.html b/reference/nn_avg_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..0bc7d66c6cc2f9a97c1018a01acffd8e588f43b8 --- /dev/null +++ b/reference/nn_avg_pool2d.html @@ -0,0 +1,285 @@ + + + + + + + + +Applies a 2D average pooling over an input signal composed of several input +planes. — nn_avg_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    In the simplest case, the output value of the layer with input size \((N, C, H, W)\), +output \((N, C, H_{out}, W_{out})\) and kernel_size \((kH, kW)\) +can be precisely described as:

    +

    $$ + out(N_i, C_j, h, w) = \frac{1}{kH * kW} \sum_{m=0}^{kH-1} \sum_{n=0}^{kW-1} +input(N_i, C_j, stride[0] \times h + m, stride[1] \times w + n) +$$

    +
    + +
    nn_avg_pool2d(
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  ceil_mode = FALSE,
    +  count_include_pad = TRUE,
    +  divisor_override = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window

    stride

    the stride of the window. Default value is kernel_size

    padding

    implicit zero padding to be added on both sides

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    count_include_pad

    when TRUE, will include the zero-padding in the averaging calculation

    divisor_override

    if specified, it will be used as divisor, otherwise kernel_size will be used

    + +

    Details

    + +

    If padding is non-zero, then the input is implicitly zero-padded on both sides +for padding number of points.

    +

    The parameters kernel_size, stride, padding can either be:

      +
    • a single int -- in which case the same value is used for the height and width dimension

    • +
    • a tuple of two ints -- in which case, the first int is used for the height dimension, +and the second int for the width dimension

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((N, C, H_{in}, W_{in})\)

    • +
    • Output: \((N, C, H_{out}, W_{out})\), where

    • +
    + +

    $$ + H_{out} = \left\lfloor\frac{H_{in} + 2 \times \text{padding}[0] - + \text{kernel\_size}[0]}{\text{stride}[0]} + 1\right\rfloor +$$ +$$ + W_{out} = \left\lfloor\frac{W_{in} + 2 \times \text{padding}[1] - + \text{kernel\_size}[1]}{\text{stride}[1]} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +# pool of square window of size=3, stride=2 +m <- nn_avg_pool2d(3, stride=2) +# pool of non-square window +m <- nn_avg_pool2d(c(3, 2), stride=c(2, 1)) +input <- torch_randn(20, 16, 50, 32) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_avg_pool3d.html b/reference/nn_avg_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..25f253978b8bdc686c5dd5ad2db96feb9cbcc5f4 --- /dev/null +++ b/reference/nn_avg_pool3d.html @@ -0,0 +1,297 @@ + + + + + + + + +Applies a 3D average pooling over an input signal composed of several input +planes. — nn_avg_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    In the simplest case, the output value of the layer with input size \((N, C, D, H, W)\), +output \((N, C, D_{out}, H_{out}, W_{out})\) and kernel_size \((kD, kH, kW)\) +can be precisely described as:

    +

    $$ + \begin{aligned} +\text{out}(N_i, C_j, d, h, w) ={} & \sum_{k=0}^{kD-1} \sum_{m=0}^{kH-1} \sum_{n=0}^{kW-1} \\ +& \frac{\text{input}(N_i, C_j, \text{stride}[0] \times d + k, + \text{stride}[1] \times h + m, \text{stride}[2] \times w + n)} +{kD \times kH \times kW} +\end{aligned} +$$

    +
    + +
    nn_avg_pool3d(
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  ceil_mode = FALSE,
    +  count_include_pad = TRUE,
    +  divisor_override = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window

    stride

    the stride of the window. Default value is kernel_size

    padding

    implicit zero padding to be added on all three sides

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    count_include_pad

    when TRUE, will include the zero-padding in the averaging calculation

    divisor_override

    if specified, it will be used as divisor, otherwise kernel_size will be used

    + +

    Details

    + +

    If padding is non-zero, then the input is implicitly zero-padded on all three sides +for padding number of points.

    +

    The parameters kernel_size, stride can either be:

      +
    • a single int -- in which case the same value is used for the depth, height and width dimension

    • +
    • a tuple of three ints -- in which case, the first int is used for the depth dimension, +the second int for the height dimension and the third int for the width dimension

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((N, C, D_{in}, H_{in}, W_{in})\)

    • +
    • Output: \((N, C, D_{out}, H_{out}, W_{out})\), where

    • +
    + +

    $$ + D_{out} = \left\lfloor\frac{D_{in} + 2 \times \text{padding}[0] - + \text{kernel\_size}[0]}{\text{stride}[0]} + 1\right\rfloor +$$ +$$ + H_{out} = \left\lfloor\frac{H_{in} + 2 \times \text{padding}[1] - + \text{kernel\_size}[1]}{\text{stride}[1]} + 1\right\rfloor +$$ +$$ + W_{out} = \left\lfloor\frac{W_{in} + 2 \times \text{padding}[2] - + \text{kernel\_size}[2]}{\text{stride}[2]} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +# pool of square window of size=3, stride=2 +m = nn_avg_pool3d(3, stride=2) +# pool of non-square window +m = nn_avg_pool3d(c(3, 2, 2), stride=c(2, 1, 2)) +input = torch_randn(20, 16, 50,44, 31) +output = m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_batch_norm1d.html b/reference/nn_batch_norm1d.html new file mode 100644 index 0000000000000000000000000000000000000000..441b07d54931a731c3c6691fdcfb68e7f34054a8 --- /dev/null +++ b/reference/nn_batch_norm1d.html @@ -0,0 +1,287 @@ + + + + + + + + +BatchNorm1D module — nn_batch_norm1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies Batch Normalization over a 2D or 3D input (a mini-batch of 1D +inputs with optional additional channel dimension) as described in the paper +Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift

    +
    + +
    nn_batch_norm1d(
    +  num_features,
    +  eps = 1e-05,
    +  momentum = 0.1,
    +  affine = TRUE,
    +  track_running_stats = TRUE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    num_features

    \(C\) from an expected input of size +\((N, C, L)\) or \(L\) from input of size \((N, L)\)

    eps

    a value added to the denominator for numerical stability. +Default: 1e-5

    momentum

    the value used for the running_mean and running_var +computation. Can be set to NULL for cumulative moving average +(i.e. simple average). Default: 0.1

    affine

    a boolean value that when set to TRUE, this module has +learnable affine parameters. Default: TRUE

    track_running_stats

    a boolean value that when set to TRUE, this +module tracks the running mean and variance, and when set to FALSE, +this module does not track such statistics and always uses batch +statistics in both training and eval modes. Default: TRUE

    + +

    Details

    + +

    $$ +y = \frac{x - \mathrm{E}[x]}{\sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta +$$

    +

    The mean and standard-deviation are calculated per-dimension over +the mini-batches and \(\gamma\) and \(\beta\) are learnable parameter vectors +of size C (where C is the input size). By default, the elements of \(\gamma\) +are set to 1 and the elements of \(\beta\) are set to 0.

    +

    Also by default, during training this layer keeps running estimates of its +computed mean and variance, which are then used for normalization during +evaluation. The running estimates are kept with a default :attr:momentum +of 0.1. +If track_running_stats is set to FALSE, this layer then does not +keep running estimates, and batch statistics are instead used during +evaluation time as well.

    +

    Note

    + + + + +

    This momentum argument is different from one used in optimizer +classes and the conventional notion of momentum. Mathematically, the +update rule for running statistics here is +\(\hat{x}_{\mbox{new}} = (1 - \mbox{momentum}) \times \hat{x} + \mbox{momentum} \times x_t\), +where \(\hat{x}\) is the estimated statistic and \(x_t\) is the +new observed value.

    +

    Because the Batch Normalization is done over the C dimension, computing statistics +on (N, L) slices, it's common terminology to call this Temporal Batch Normalization.

    +

    Shape

    + + + +
      +
    • Input: \((N, C)\) or \((N, C, L)\)

    • +
    • Output: \((N, C)\) or \((N, C, L)\) (same shape as input)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +# With Learnable Parameters +m <- nn_batch_norm1d(100) +# Without Learnable Parameters +m <- nn_batch_norm1d(100, affine = FALSE) +input <- torch_randn(20, 100) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_batch_norm2d.html b/reference/nn_batch_norm2d.html new file mode 100644 index 0000000000000000000000000000000000000000..9a70aa5a4126a1a0ffa85cc12afab5f7e18d7ee2 --- /dev/null +++ b/reference/nn_batch_norm2d.html @@ -0,0 +1,286 @@ + + + + + + + + +BatchNorm2D — nn_batch_norm2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies Batch Normalization over a 4D input (a mini-batch of 2D inputs +additional channel dimension) as described in the paper +Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift.

    +
    + +
    nn_batch_norm2d(
    +  num_features,
    +  eps = 1e-05,
    +  momentum = 0.1,
    +  affine = TRUE,
    +  track_running_stats = TRUE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    num_features

    \(C\) from an expected input of size +\((N, C, H, W)\)

    eps

    a value added to the denominator for numerical stability. +Default: 1e-5

    momentum

    the value used for the running_mean and running_var +computation. Can be set to None for cumulative moving average +(i.e. simple average). Default: 0.1

    affine

    a boolean value that when set to TRUE, this module has +learnable affine parameters. Default: TRUE

    track_running_stats

    a boolean value that when set to TRUE, this +module tracks the running mean and variance, and when set to FALSE, +this module does not track such statistics and uses batch statistics instead +in both training and eval modes if the running mean and variance are None. +Default: TRUE

    + +

    Details

    + +

    $$ + y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta +$$

    +

    The mean and standard-deviation are calculated per-dimension over +the mini-batches and \(\gamma\) and \(\beta\) are learnable parameter vectors +of size C (where C is the input size). By default, the elements of \(\gamma\) are set +to 1 and the elements of \(\beta\) are set to 0. The standard-deviation is calculated +via the biased estimator, equivalent to torch_var(input, unbiased=FALSE). +Also by default, during training this layer keeps running estimates of its +computed mean and variance, which are then used for normalization during +evaluation. The running estimates are kept with a default momentum +of 0.1.

    +

    If track_running_stats is set to FALSE, this layer then does not +keep running estimates, and batch statistics are instead used during +evaluation time as well.

    +

    Note

    + +

    This momentum argument is different from one used in optimizer +classes and the conventional notion of momentum. Mathematically, the +update rule for running statistics here is +\(\hat{x}_{\mbox{new}} = (1 - \mbox{momentum}) \times \hat{x} + \mbox{momentum} \times x_t\), +where \(\hat{x}\) is the estimated statistic and \(x_t\) is the +new observed value. +Because the Batch Normalization is done over the C dimension, computing statistics +on (N, H, W) slices, it's common terminology to call this Spatial Batch Normalization.

    +

    Shape

    + + + +
      +
    • Input: \((N, C, H, W)\)

    • +
    • Output: \((N, C, H, W)\) (same shape as input)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +# With Learnable Parameters +m <- nn_batch_norm2d(100) +# Without Learnable Parameters +m <- nn_batch_norm2d(100, affine=FALSE) +input <- torch_randn(20, 100, 35, 45) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_bce_loss.html b/reference/nn_bce_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..df7700e571824c234038d14fbb5ff21e7c85ad98 --- /dev/null +++ b/reference/nn_bce_loss.html @@ -0,0 +1,271 @@ + + + + + + + + +Binary cross entropy loss — nn_bce_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that measures the Binary Cross Entropy +between the target and the output:

    +
    + +
    nn_bce_loss(weight = NULL, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + +
    weight

    (Tensor, optional): a manual rescaling weight given to the loss +of each batch element. If given, has to be a Tensor of size nbatch.

    reduction

    (string, optional): Specifies the reduction to apply to the output: +'none' | 'mean' | 'sum'. 'none': no reduction will be applied, +'mean': the sum of the output will be divided by the number of +elements in the output, 'sum': the output will be summed. Note: size_average +and reduce are in the process of being deprecated, and in the meantime, +specifying either of those two args will override reduction. Default: 'mean'

    + +

    Details

    + +

    The unreduced (i.e. with reduction set to 'none') loss can be described as: +$$ + \ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad +l_n = - w_n \left[ y_n \cdot \log x_n + (1 - y_n) \cdot \log (1 - x_n) \right] +$$ +where \(N\) is the batch size. If reduction is not 'none' +(default 'mean'), then

    +

    $$ + \ell(x, y) = \left\{ \begin{array}{ll} +\mbox{mean}(L), & \mbox{if reduction} = \mbox{'mean';}\\ +\mbox{sum}(L), & \mbox{if reduction} = \mbox{'sum'.} +\end{array} +\right. +$$

    +

    This is used for measuring the error of a reconstruction in for example +an auto-encoder. Note that the targets \(y\) should be numbers +between 0 and 1.

    +

    Notice that if \(x_n\) is either 0 or 1, one of the log terms would be +mathematically undefined in the above loss equation. PyTorch chooses to set +\(\log (0) = -\infty\), since \(\lim_{x\to 0} \log (x) = -\infty\).

    +

    However, an infinite term in the loss equation is not desirable for several reasons. +For one, if either \(y_n = 0\) or \((1 - y_n) = 0\), then we would be +multiplying 0 with infinity. Secondly, if we have an infinite loss value, then +we would also have an infinite term in our gradient, since +\(\lim_{x\to 0} \frac{d}{dx} \log (x) = \infty\).

    +

    This would make BCELoss's backward method nonlinear with respect to \(x_n\), +and using it for things like linear regression would not be straight-forward. +Our solution is that BCELoss clamps its log function outputs to be greater than +or equal to -100. This way, we can always have a finite loss value and a linear +backward method.

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where \(*\) means, any number of additional +dimensions

    • +
    • Target: \((N, *)\), same shape as the input

    • +
    • Output: scalar. If reduction is 'none', then \((N, *)\), same +shape as input.

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_sigmoid() +loss <- nn_bce_loss() +input <- torch_randn(3, requires_grad=TRUE) +target <- torch_rand(3) +output <- loss(m(input), target) +output$backward() + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_bilinear.html b/reference/nn_bilinear.html new file mode 100644 index 0000000000000000000000000000000000000000..54039fa19339c0bf48f82b9a61d22eb5ef90d27e --- /dev/null +++ b/reference/nn_bilinear.html @@ -0,0 +1,257 @@ + + + + + + + + +Bilinear module — nn_bilinear • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a bilinear transformation to the incoming data +\(y = x_1^T A x_2 + b\)

    +
    + +
    nn_bilinear(in1_features, in2_features, out_features, bias = TRUE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    in1_features

    size of each first input sample

    in2_features

    size of each second input sample

    out_features

    size of each output sample

    bias

    If set to FALSE, the layer will not learn an additive bias. +Default: TRUE

    + +

    Shape

    + + + +
      +
    • Input1: \((N, *, H_{in1})\) \(H_{in1}=\mbox{in1\_features}\) and +\(*\) means any number of additional dimensions. All but the last +dimension of the inputs should be the same.

    • +
    • Input2: \((N, *, H_{in2})\) where \(H_{in2}=\mbox{in2\_features}\).

    • +
    • Output: \((N, *, H_{out})\) where \(H_{out}=\mbox{out\_features}\) +and all but the last dimension are the same shape as the input.

    • +
    + +

    Attributes

    + + + +
      +
    • weight: the learnable weights of the module of shape +\((\mbox{out\_features}, \mbox{in1\_features}, \mbox{in2\_features})\). +The values are initialized from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\), where +\(k = \frac{1}{\mbox{in1\_features}}\)

    • +
    • bias: the learnable bias of the module of shape \((\mbox{out\_features})\). +If bias is TRUE, the values are initialized from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\), where +\(k = \frac{1}{\mbox{in1\_features}}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_bilinear(20, 30, 50) +input1 <- torch_randn(128, 20) +input2 <- torch_randn(128, 30) +output = m(input1, input2) +print(output$size()) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_celu.html b/reference/nn_celu.html new file mode 100644 index 0000000000000000000000000000000000000000..975cbe0a1015ccbf089c4689e3e194a81ce483a2 --- /dev/null +++ b/reference/nn_celu.html @@ -0,0 +1,233 @@ + + + + + + + + +CELU module — nn_celu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_celu(alpha = 1, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    alpha

    the \(\alpha\) value for the CELU formulation. Default: 1.0

    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    $$ + \mbox{CELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x/\alpha) - 1)) +$$

    +

    More details can be found in the paper +Continuously Differentiable Exponential Linear Units.

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_celu() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_conv1d.html b/reference/nn_conv1d.html new file mode 100644 index 0000000000000000000000000000000000000000..b76f87f1e94bf9ecb5c90e69552736739a41e174 --- /dev/null +++ b/reference/nn_conv1d.html @@ -0,0 +1,344 @@ + + + + + + + + +Conv1D module — nn_conv1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D convolution over an input signal composed of several input +planes. +In the simplest case, the output value of the layer with input size +\((N, C_{\mbox{in}}, L)\) and output \((N, C_{\mbox{out}}, L_{\mbox{out}})\) can be +precisely described as:

    +
    + +
    nn_conv1d(
    +  in_channels,
    +  out_channels,
    +  kernel_size,
    +  stride = 1,
    +  padding = 0,
    +  dilation = 1,
    +  groups = 1,
    +  bias = TRUE,
    +  padding_mode = "zeros"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    in_channels

    (int): Number of channels in the input image

    out_channels

    (int): Number of channels produced by the convolution

    kernel_size

    (int or tuple): Size of the convolving kernel

    stride

    (int or tuple, optional): Stride of the convolution. Default: 1

    padding

    (int or tuple, optional): Zero-padding added to both sides of +the input. Default: 0

    dilation

    (int or tuple, optional): Spacing between kernel +elements. Default: 1

    groups

    (int, optional): Number of blocked connections from input +channels to output channels. Default: 1

    bias

    (bool, optional): If TRUE, adds a learnable bias to the +output. Default: TRUE

    padding_mode

    (string, optional): 'zeros', 'reflect', +'replicate' or 'circular'. Default: 'zeros'

    + +

    Details

    + +

    $$ +\mbox{out}(N_i, C_{\mbox{out}_j}) = \mbox{bias}(C_{\mbox{out}_j}) + + \sum_{k = 0}^{C_{in} - 1} \mbox{weight}(C_{\mbox{out}_j}, k) +\star \mbox{input}(N_i, k) +$$

    +

    where \(\star\) is the valid +cross-correlation operator, +\(N\) is a batch size, \(C\) denotes a number of channels, +\(L\) is a length of signal sequence.

      +
    • stride controls the stride for the cross-correlation, a single +number or a one-element tuple.

    • +
    • padding controls the amount of implicit zero-paddings on both sides +for padding number of points.

    • +
    • dilation controls the spacing between the kernel points; also +known as the à trous algorithm. It is harder to describe, but this +link +has a nice visualization of what dilation does.

    • +
    • groups controls the connections between inputs and outputs. +in_channels and out_channels must both be divisible by +groups. For example,

        +
      • At groups=1, all inputs are convolved to all outputs.

      • +
      • At groups=2, the operation becomes equivalent to having two conv +layers side by side, each seeing half the input channels, +and producing half the output channels, and both subsequently +concatenated.

      • +
      • At groups= in_channels, each input channel is convolved with +its own set of filters, +of size \(\left\lfloor\frac{out\_channels}{in\_channels}\right\rfloor\).

      • +
    • +
    + +

    Note

    + + + + +

    Depending of the size of your kernel, several (of the last) +columns of the input might be lost, because it is a valid +cross-correlation, and not a full cross-correlation. +It is up to the user to add proper padding.

    +

    When groups == in_channels and out_channels == K * in_channels, +where K is a positive integer, this operation is also termed in +literature as depthwise convolution. +In other words, for an input of size \((N, C_{in}, L_{in})\), +a depthwise convolution with a depthwise multiplier K, can be constructed by arguments +\((C_{\mbox{in}}=C_{in}, C_{\mbox{out}}=C_{in} \times K, ..., \mbox{groups}=C_{in})\).

    +

    Shape

    + + + +
      +
    • Input: \((N, C_{in}, L_{in})\)

    • +
    • Output: \((N, C_{out}, L_{out})\) where

    • +
    + +

    $$ + L_{out} = \left\lfloor\frac{L_{in} + 2 \times \mbox{padding} - \mbox{dilation} + \times (\mbox{kernel\_size} - 1) - 1}{\mbox{stride}} + 1\right\rfloor +$$

    +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of the module of shape +\((\mbox{out\_channels}, \frac{\mbox{in\_channels}}{\mbox{groups}}, \mbox{kernel\_size})\). +The values of these weights are sampled from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{in}} * \mbox{kernel\_size}}\)

    • +
    • bias (Tensor): the learnable bias of the module of shape +(out_channels). If bias is TRUE, then the values of these weights are +sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{in}} * \mbox{kernel\_size}}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_conv1d(16, 33, 3, stride=2) +input <- torch_randn(20, 16, 50) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_conv2d.html b/reference/nn_conv2d.html new file mode 100644 index 0000000000000000000000000000000000000000..4359ba6259f87c6bb9964451be00e8f2afb3edf6 --- /dev/null +++ b/reference/nn_conv2d.html @@ -0,0 +1,361 @@ + + + + + + + + +Conv2D module — nn_conv2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D convolution over an input signal composed of several input +planes.

    +
    + +
    nn_conv2d(
    +  in_channels,
    +  out_channels,
    +  kernel_size,
    +  stride = 1,
    +  padding = 0,
    +  dilation = 1,
    +  groups = 1,
    +  bias = TRUE,
    +  padding_mode = "zeros"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    in_channels

    (int): Number of channels in the input image

    out_channels

    (int): Number of channels produced by the convolution

    kernel_size

    (int or tuple): Size of the convolving kernel

    stride

    (int or tuple, optional): Stride of the convolution. Default: 1

    padding

    (int or tuple, optional): Zero-padding added to both sides of +the input. Default: 0

    dilation

    (int or tuple, optional): Spacing between kernel elements. Default: 1

    groups

    (int, optional): Number of blocked connections from input +channels to output channels. Default: 1

    bias

    (bool, optional): If TRUE, adds a learnable bias to the +output. Default: TRUE

    padding_mode

    (string, optional): 'zeros', 'reflect', +'replicate' or 'circular'. Default: 'zeros'

    + +

    Details

    + +

    In the simplest case, the output value of the layer with input size +\((N, C_{\mbox{in}}, H, W)\) and output \((N, C_{\mbox{out}}, H_{\mbox{out}}, W_{\mbox{out}})\) +can be precisely described as:

    +

    $$ +\mbox{out}(N_i, C_{\mbox{out}_j}) = \mbox{bias}(C_{\mbox{out}_j}) + + \sum_{k = 0}^{C_{\mbox{in}} - 1} \mbox{weight}(C_{\mbox{out}_j}, k) \star \mbox{input}(N_i, k) +$$

    +

    where \(\star\) is the valid 2D cross-correlation operator, +\(N\) is a batch size, \(C\) denotes a number of channels, +\(H\) is a height of input planes in pixels, and \(W\) is +width in pixels.

      +
    • stride controls the stride for the cross-correlation, a single +number or a tuple.

    • +
    • padding controls the amount of implicit zero-paddings on both +sides for padding number of points for each dimension.

    • +
    • dilation controls the spacing between the kernel points; also +known as the à trous algorithm. It is harder to describe, but this link_ +has a nice visualization of what dilation does.

    • +
    • groups controls the connections between inputs and outputs. +in_channels and out_channels must both be divisible by +groups. For example,

        +
      • At groups=1, all inputs are convolved to all outputs.

      • +
      • At groups=2, the operation becomes equivalent to having two conv +layers side by side, each seeing half the input channels, +and producing half the output channels, and both subsequently +concatenated.

      • +
      • At groups= in_channels, each input channel is convolved with +its own set of filters, of size: +\(\left\lfloor\frac{out\_channels}{in\_channels}\right\rfloor\).

      • +
    • +
    + +

    The parameters kernel_size, stride, padding, dilation can either be:

      +
    • a single int -- in which case the same value is used for the height and +width dimension

    • +
    • a tuple of two ints -- in which case, the first int is used for the height dimension, +and the second int for the width dimension

    • +
    + +

    Note

    + + + + +

    Depending of the size of your kernel, several (of the last) +columns of the input might be lost, because it is a valid cross-correlation, +and not a full cross-correlation. +It is up to the user to add proper padding.

    +

    When groups == in_channels and out_channels == K * in_channels, +where K is a positive integer, this operation is also termed in +literature as depthwise convolution. +In other words, for an input of size :math:(N, C_{in}, H_{in}, W_{in}), +a depthwise convolution with a depthwise multiplier K, can be constructed by arguments +\((in\_channels=C_{in}, out\_channels=C_{in} \times K, ..., groups=C_{in})\).

    +

    In some circumstances when using the CUDA backend with CuDNN, this operator +may select a nondeterministic algorithm to increase performance. If this is +undesirable, you can try to make the operation deterministic (potentially at +a performance cost) by setting backends_cudnn_deterministic = TRUE.

    +

    Shape

    + + + +
      +
    • Input: \((N, C_{in}, H_{in}, W_{in})\)

    • +
    • Output: \((N, C_{out}, H_{out}, W_{out})\) where +$$ + H_{out} = \left\lfloor\frac{H_{in} + 2 \times \mbox{padding}[0] - \mbox{dilation}[0] + \times (\mbox{kernel\_size}[0] - 1) - 1}{\mbox{stride}[0]} + 1\right\rfloor +$$ +$$ + W_{out} = \left\lfloor\frac{W_{in} + 2 \times \mbox{padding}[1] - \mbox{dilation}[1] + \times (\mbox{kernel\_size}[1] - 1) - 1}{\mbox{stride}[1]} + 1\right\rfloor +$$

    • +
    + +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of the module of shape +\((\mbox{out\_channels}, \frac{\mbox{in\_channels}}{\mbox{groups}}\), +\(\mbox{kernel\_size[0]}, \mbox{kernel\_size[1]})\). +The values of these weights are sampled from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{in}} * \prod_{i=0}^{1}\mbox{kernel\_size}[i]}\)

    • +
    • bias (Tensor): the learnable bias of the module of shape +(out_channels). If bias is TRUE, +then the values of these weights are +sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{in}} * \prod_{i=0}^{1}\mbox{kernel\_size}[i]}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { + +# With square kernels and equal stride +m <- nn_conv2d(16, 33, 3, stride = 2) +# non-square kernels and unequal stride and with padding +m <- nn_conv2d(16, 33, c(3, 5), stride=c(2, 1), padding=c(4, 2)) +# non-square kernels and unequal stride and with padding and dilation +m <- nn_conv2d(16, 33, c(3, 5), stride=c(2, 1), padding=c(4, 2), dilation=c(3, 1)) +input <- torch_randn(20, 16, 50, 100) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_conv3d.html b/reference/nn_conv3d.html new file mode 100644 index 0000000000000000000000000000000000000000..df61ceae39c700d3333f6c31440d65b6c14bc0ca --- /dev/null +++ b/reference/nn_conv3d.html @@ -0,0 +1,349 @@ + + + + + + + + +Conv3D module — nn_conv3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 3D convolution over an input signal composed of several input +planes. +In the simplest case, the output value of the layer with input size \((N, C_{in}, D, H, W)\) +and output \((N, C_{out}, D_{out}, H_{out}, W_{out})\) can be precisely described as:

    +
    + +
    nn_conv3d(
    +  in_channels,
    +  out_channels,
    +  kernel_size,
    +  stride = 1,
    +  padding = 0,
    +  dilation = 1,
    +  groups = 1,
    +  bias = TRUE,
    +  padding_mode = "zeros"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    in_channels

    (int): Number of channels in the input image

    out_channels

    (int): Number of channels produced by the convolution

    kernel_size

    (int or tuple): Size of the convolving kernel

    stride

    (int or tuple, optional): Stride of the convolution. Default: 1

    padding

    (int or tuple, optional): Zero-padding added to all three sides of the input. Default: 0

    dilation

    (int or tuple, optional): Spacing between kernel elements. Default: 1

    groups

    (int, optional): Number of blocked connections from input channels to output channels. Default: 1

    bias

    (bool, optional): If TRUE, adds a learnable bias to the output. Default: TRUE

    padding_mode

    (string, optional): 'zeros', 'reflect', 'replicate' or 'circular'. Default: 'zeros'

    + +

    Details

    + +

    $$ + out(N_i, C_{out_j}) = bias(C_{out_j}) + + \sum_{k = 0}^{C_{in} - 1} weight(C_{out_j}, k) \star input(N_i, k) +$$

    +

    where \(\star\) is the valid 3D cross-correlation operator

      +
    • stride controls the stride for the cross-correlation.

    • +
    • padding controls the amount of implicit zero-paddings on both +sides for padding number of points for each dimension.

    • +
    • dilation controls the spacing between the kernel points; also known as the à trous algorithm. +It is harder to describe, but this link_ has a nice visualization of what dilation does.

    • +
    • groups controls the connections between inputs and outputs. +in_channels and out_channels must both be divisible by +groups. For example,

    • +
    • At groups=1, all inputs are convolved to all outputs.

    • +
    • At groups=2, the operation becomes equivalent to having two conv +layers side by side, each seeing half the input channels, +and producing half the output channels, and both subsequently +concatenated.

    • +
    • At groups= in_channels, each input channel is convolved with +its own set of filters, of size +\(\left\lfloor\frac{out\_channels}{in\_channels}\right\rfloor\).

    • +
    + +

    The parameters kernel_size, stride, padding, dilation can either be:

      +
    • a single int -- in which case the same value is used for the depth, height and width dimension

    • +
    • a tuple of three ints -- in which case, the first int is used for the depth dimension, +the second int for the height dimension and the third int for the width dimension

    • +
    + +

    Note

    + +

    Depending of the size of your kernel, several (of the last) +columns of the input might be lost, because it is a valid cross-correlation, +and not a full cross-correlation. +It is up to the user to add proper padding.

    +

    When groups == in_channels and out_channels == K * in_channels, +where K is a positive integer, this operation is also termed in +literature as depthwise convolution. +In other words, for an input of size \((N, C_{in}, D_{in}, H_{in}, W_{in})\), +a depthwise convolution with a depthwise multiplier K, can be constructed by arguments +\((in\_channels=C_{in}, out\_channels=C_{in} \times K, ..., groups=C_{in})\).

    +

    In some circumstances when using the CUDA backend with CuDNN, this operator +may select a nondeterministic algorithm to increase performance. If this is +undesirable, you can try to make the operation deterministic (potentially at +a performance cost) by setting torch.backends.cudnn.deterministic = TRUE. +Please see the notes on :doc:/notes/randomness for background.

    +

    Shape

    + + + +
      +
    • Input: \((N, C_{in}, D_{in}, H_{in}, W_{in})\)

    • +
    • Output: \((N, C_{out}, D_{out}, H_{out}, W_{out})\) where +$$ + D_{out} = \left\lfloor\frac{D_{in} + 2 \times \mbox{padding}[0] - \mbox{dilation}[0] + \times (\mbox{kernel\_size}[0] - 1) - 1}{\mbox{stride}[0]} + 1\right\rfloor + $$ +$$ + H_{out} = \left\lfloor\frac{H_{in} + 2 \times \mbox{padding}[1] - \mbox{dilation}[1] + \times (\mbox{kernel\_size}[1] - 1) - 1}{\mbox{stride}[1]} + 1\right\rfloor + $$ +$$ + W_{out} = \left\lfloor\frac{W_{in} + 2 \times \mbox{padding}[2] - \mbox{dilation}[2] + \times (\mbox{kernel\_size}[2] - 1) - 1}{\mbox{stride}[2]} + 1\right\rfloor + $$

    • +
    + +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of the module of shape +\((\mbox{out\_channels}, \frac{\mbox{in\_channels}}{\mbox{groups}},\) +\(\mbox{kernel\_size[0]}, \mbox{kernel\_size[1]}, \mbox{kernel\_size[2]})\). +The values of these weights are sampled from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{in}} * \prod_{i=0}^{2}\mbox{kernel\_size}[i]}\)

    • +
    • bias (Tensor): the learnable bias of the module of shape (out_channels). If bias is True, +then the values of these weights are +sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{in}} * \prod_{i=0}^{2}\mbox{kernel\_size}[i]}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +# With square kernels and equal stride +m <- nn_conv3d(16, 33, 3, stride=2) +# non-square kernels and unequal stride and with padding +m <- nn_conv3d(16, 33, c(3, 5, 2), stride=c(2, 1, 1), padding=c(4, 2, 0)) +input <- torch_randn(20, 16, 10, 50, 100) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_conv_transpose1d.html b/reference/nn_conv_transpose1d.html new file mode 100644 index 0000000000000000000000000000000000000000..ed731902a97b698fabfde3d38b809123f5d57600 --- /dev/null +++ b/reference/nn_conv_transpose1d.html @@ -0,0 +1,342 @@ + + + + + + + + +ConvTranspose1D — nn_conv_transpose1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D transposed convolution operator over an input image +composed of several input planes.

    +
    + +
    nn_conv_transpose1d(
    +  in_channels,
    +  out_channels,
    +  kernel_size,
    +  stride = 1,
    +  padding = 0,
    +  output_padding = 0,
    +  groups = 1,
    +  bias = TRUE,
    +  dilation = 1,
    +  padding_mode = "zeros"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    in_channels

    (int): Number of channels in the input image

    out_channels

    (int): Number of channels produced by the convolution

    kernel_size

    (int or tuple): Size of the convolving kernel

    stride

    (int or tuple, optional): Stride of the convolution. Default: 1

    padding

    (int or tuple, optional): dilation * (kernel_size - 1) - padding zero-padding +will be added to both sides of the input. Default: 0

    output_padding

    (int or tuple, optional): Additional size added to one side +of the output shape. Default: 0

    groups

    (int, optional): Number of blocked connections from input channels to output channels. Default: 1

    bias

    (bool, optional): If True, adds a learnable bias to the output. Default: TRUE

    dilation

    (int or tuple, optional): Spacing between kernel elements. Default: 1

    padding_mode

    (string, optional): 'zeros', 'reflect', +'replicate' or 'circular'. Default: 'zeros'

    + +

    Details

    + +

    This module can be seen as the gradient of Conv1d with respect to its input. +It is also known as a fractionally-strided convolution or +a deconvolution (although it is not an actual deconvolution operation).

      +
    • stride controls the stride for the cross-correlation.

    • +
    • padding controls the amount of implicit zero-paddings on both +sides for dilation * (kernel_size - 1) - padding number of points. See note +below for details.

    • +
    • output_padding controls the additional size added to one side +of the output shape. See note below for details.

    • +
    • dilation controls the spacing between the kernel points; also known as the +à trous algorithm. It is harder to describe, but this link +has a nice visualization of what dilation does.

    • +
    • groups controls the connections between inputs and outputs. +in_channels and out_channels must both be divisible by +groups. For example,

        +
      • At groups=1, all inputs are convolved to all outputs.

      • +
      • At groups=2, the operation becomes equivalent to having two conv +layers side by side, each seeing half the input channels, +and producing half the output channels, and both subsequently +concatenated.

      • +
      • At groups= in_channels, each input channel is convolved with +its own set of filters (of size +\(\left\lfloor\frac{out\_channels}{in\_channels}\right\rfloor\)).

      • +
    • +
    + +

    Note

    + +

    Depending of the size of your kernel, several (of the last) +columns of the input might be lost, because it is a valid cross-correlation, +and not a full cross-correlation. +It is up to the user to add proper padding.

    +

    The padding argument effectively adds dilation * (kernel_size - 1) - padding +amount of zero padding to both sizes of the input. This is set so that +when a ~torch.nn.Conv1d and a ~torch.nn.ConvTranspose1d +are initialized with same parameters, they are inverses of each other in +regard to the input and output shapes. However, when stride > 1, +~torch.nn.Conv1d maps multiple input shapes to the same output +shape. output_padding is provided to resolve this ambiguity by +effectively increasing the calculated output shape on one side. Note +that output_padding is only used to find output shape, but does +not actually add zero-padding to output.

    +

    In some circumstances when using the CUDA backend with CuDNN, this operator +may select a nondeterministic algorithm to increase performance. If this is +undesirable, you can try to make the operation deterministic (potentially at +a performance cost) by setting torch.backends.cudnn.deterministic = TRUE.

    +

    Shape

    + + + +
      +
    • Input: \((N, C_{in}, L_{in})\)

    • +
    • Output: \((N, C_{out}, L_{out})\) where +$$ + L_{out} = (L_{in} - 1) \times \mbox{stride} - 2 \times \mbox{padding} + \mbox{dilation} +\times (\mbox{kernel\_size} - 1) + \mbox{output\_padding} + 1 +$$

    • +
    + +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of the module of shape +\((\mbox{in\_channels}, \frac{\mbox{out\_channels}}{\mbox{groups}},\) +\(\mbox{kernel\_size})\). +The values of these weights are sampled from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{out}} * \mbox{kernel\_size}}\)

    • +
    • bias (Tensor): the learnable bias of the module of shape (out_channels). +If bias is TRUE, then the values of these weights are +sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{out}} * \mbox{kernel\_size}}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_conv_transpose1d(32, 16, 2) +input <- torch_randn(10, 32, 2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_conv_transpose2d.html b/reference/nn_conv_transpose2d.html new file mode 100644 index 0000000000000000000000000000000000000000..c78915f0c94bd55b4d5cabfaf0bf5ab7ed26e894 --- /dev/null +++ b/reference/nn_conv_transpose2d.html @@ -0,0 +1,362 @@ + + + + + + + + +ConvTranpose2D module — nn_conv_transpose2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D transposed convolution operator over an input image +composed of several input planes.

    +
    + +
    nn_conv_transpose2d(
    +  in_channels,
    +  out_channels,
    +  kernel_size,
    +  stride = 1,
    +  padding = 0,
    +  output_padding = 0,
    +  groups = 1,
    +  bias = TRUE,
    +  dilation = 1,
    +  padding_mode = "zeros"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    in_channels

    (int): Number of channels in the input image

    out_channels

    (int): Number of channels produced by the convolution

    kernel_size

    (int or tuple): Size of the convolving kernel

    stride

    (int or tuple, optional): Stride of the convolution. Default: 1

    padding

    (int or tuple, optional): dilation * (kernel_size - 1) - padding zero-padding +will be added to both sides of each dimension in the input. Default: 0

    output_padding

    (int or tuple, optional): Additional size added to one side +of each dimension in the output shape. Default: 0

    groups

    (int, optional): Number of blocked connections from input channels to output channels. Default: 1

    bias

    (bool, optional): If True, adds a learnable bias to the output. Default: True

    dilation

    (int or tuple, optional): Spacing between kernel elements. Default: 1

    padding_mode

    (string, optional): 'zeros', 'reflect', +'replicate' or 'circular'. Default: 'zeros'

    + +

    Details

    + +

    This module can be seen as the gradient of Conv2d with respect to its input. +It is also known as a fractionally-strided convolution or +a deconvolution (although it is not an actual deconvolution operation).

      +
    • stride controls the stride for the cross-correlation.

    • +
    • padding controls the amount of implicit zero-paddings on both +sides for dilation * (kernel_size - 1) - padding number of points. See note +below for details.

    • +
    • output_padding controls the additional size added to one side +of the output shape. See note below for details.

    • +
    • dilation controls the spacing between the kernel points; also known as the à trous algorithm. +It is harder to describe, but this link_ has a nice visualization of what dilation does.

    • +
    • groups controls the connections between inputs and outputs. +in_channels and out_channels must both be divisible by +groups. For example,

        +
      • At groups=1, all inputs are convolved to all outputs.

      • +
      • At groups=2, the operation becomes equivalent to having two conv +layers side by side, each seeing half the input channels, +and producing half the output channels, and both subsequently +concatenated.

      • +
      • At groups= in_channels, each input channel is convolved with +its own set of filters (of size +\(\left\lfloor\frac{out\_channels}{in\_channels}\right\rfloor\)).

      • +
    • +
    + +

    The parameters kernel_size, stride, padding, output_padding +can either be:

      +
    • a single int -- in which case the same value is used for the height and width dimensions

    • +
    • a tuple of two ints -- in which case, the first int is used for the height dimension, +and the second int for the width dimension

    • +
    + +

    Note

    + +

    Depending of the size of your kernel, several (of the last) +columns of the input might be lost, because it is a valid cross-correlation_, +and not a full cross-correlation. It is up to the user to add proper padding.

    +

    The padding argument effectively adds dilation * (kernel_size - 1) - padding +amount of zero padding to both sizes of the input. This is set so that +when a nn_conv2d and a nn_conv_transpose2d are initialized with same +parameters, they are inverses of each other in +regard to the input and output shapes. However, when stride > 1, +nn_conv2d maps multiple input shapes to the same output +shape. output_padding is provided to resolve this ambiguity by +effectively increasing the calculated output shape on one side. Note +that output_padding is only used to find output shape, but does +not actually add zero-padding to output.

    +

    In some circumstances when using the CUDA backend with CuDNN, this operator +may select a nondeterministic algorithm to increase performance. If this is +undesirable, you can try to make the operation deterministic (potentially at +a performance cost) by setting torch.backends.cudnn.deterministic = TRUE.

    +

    Shape

    + + + +
      +
    • Input: \((N, C_{in}, H_{in}, W_{in})\)

    • +
    • Output: \((N, C_{out}, H_{out}, W_{out})\) where +$$ + H_{out} = (H_{in} - 1) \times \mbox{stride}[0] - 2 \times \mbox{padding}[0] + \mbox{dilation}[0] +\times (\mbox{kernel\_size}[0] - 1) + \mbox{output\_padding}[0] + 1 +$$ +$$ + W_{out} = (W_{in} - 1) \times \mbox{stride}[1] - 2 \times \mbox{padding}[1] + \mbox{dilation}[1] +\times (\mbox{kernel\_size}[1] - 1) + \mbox{output\_padding}[1] + 1 +$$

    • +
    + +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of the module of shape +\((\mbox{in\_channels}, \frac{\mbox{out\_channels}}{\mbox{groups}},\) +\(\mbox{kernel\_size[0]}, \mbox{kernel\_size[1]})\). +The values of these weights are sampled from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{out}} * \prod_{i=0}^{1}\mbox{kernel\_size}[i]}\)

    • +
    • bias (Tensor): the learnable bias of the module of shape (out_channels) +If bias is True, then the values of these weights are +sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{out}} * \prod_{i=0}^{1}\mbox{kernel\_size}[i]}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +# With square kernels and equal stride +m <- nn_conv_transpose2d(16, 33, 3, stride=2) +# non-square kernels and unequal stride and with padding +m <- nn_conv_transpose2d(16, 33, c(3, 5), stride=c(2, 1), padding=c(4, 2)) +input <- torch_randn(20, 16, 50, 100) +output <- m(input) +# exact output size can be also specified as an argument +input <- torch_randn(1, 16, 12, 12) +downsample <- nn_conv2d(16, 16, 3, stride=2, padding=1) +upsample <- nn_conv_transpose2d(16, 16, 3, stride=2, padding=1) +h <- downsample(input) +h$size() +output <- upsample(h, output_size=input$size()) +output$size() + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_conv_transpose3d.html b/reference/nn_conv_transpose3d.html new file mode 100644 index 0000000000000000000000000000000000000000..948a3473fa96eb81a03dc83951af11cc65fb0fa5 --- /dev/null +++ b/reference/nn_conv_transpose3d.html @@ -0,0 +1,363 @@ + + + + + + + + +ConvTranpose3D module — nn_conv_transpose3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 3D transposed convolution operator over an input image composed of several input +planes.

    +
    + +
    nn_conv_transpose3d(
    +  in_channels,
    +  out_channels,
    +  kernel_size,
    +  stride = 1,
    +  padding = 0,
    +  output_padding = 0,
    +  groups = 1,
    +  bias = TRUE,
    +  dilation = 1,
    +  padding_mode = "zeros"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    in_channels

    (int): Number of channels in the input image

    out_channels

    (int): Number of channels produced by the convolution

    kernel_size

    (int or tuple): Size of the convolving kernel

    stride

    (int or tuple, optional): Stride of the convolution. Default: 1

    padding

    (int or tuple, optional): dilation * (kernel_size - 1) - padding zero-padding +will be added to both sides of each dimension in the input. Default: 0 +output_padding (int or tuple, optional): Additional size added to one side +of each dimension in the output shape. Default: 0

    output_padding

    (int or tuple, optional): Additional size added to one side +of each dimension in the output shape. Default: 0

    groups

    (int, optional): Number of blocked connections from input channels to output channels. Default: 1

    bias

    (bool, optional): If True, adds a learnable bias to the output. Default: True

    dilation

    (int or tuple, optional): Spacing between kernel elements. Default: 1

    padding_mode

    (string, optional): 'zeros', 'reflect', 'replicate' or 'circular'. Default: 'zeros'

    + +

    Details

    + +

    The transposed convolution operator multiplies each input value element-wise by a learnable kernel, +and sums over the outputs from all input feature planes.

    +

    This module can be seen as the gradient of Conv3d with respect to its input. +It is also known as a fractionally-strided convolution or +a deconvolution (although it is not an actual deconvolution operation).

      +
    • stride controls the stride for the cross-correlation.

    • +
    • padding controls the amount of implicit zero-paddings on both +sides for dilation * (kernel_size - 1) - padding number of points. See note +below for details.

    • +
    • output_padding controls the additional size added to one side +of the output shape. See note below for details.

    • +
    • dilation controls the spacing between the kernel points; also known as the à trous algorithm. +It is harder to describe, but this link_ has a nice visualization of what dilation does.

    • +
    • groups controls the connections between inputs and outputs. +in_channels and out_channels must both be divisible by +groups. For example,

        +
      • At groups=1, all inputs are convolved to all outputs.

      • +
      • At groups=2, the operation becomes equivalent to having two conv +layers side by side, each seeing half the input channels, +and producing half the output channels, and both subsequently +concatenated.

      • +
      • At groups= in_channels, each input channel is convolved with +its own set of filters (of size +\(\left\lfloor\frac{out\_channels}{in\_channels}\right\rfloor\)).

      • +
    • +
    + +

    The parameters kernel_size, stride, padding, output_padding +can either be:

      +
    • a single int -- in which case the same value is used for the depth, height and width dimensions

    • +
    • a tuple of three ints -- in which case, the first int is used for the depth dimension, +the second int for the height dimension and the third int for the width dimension

    • +
    + +

    Note

    + +

    Depending of the size of your kernel, several (of the last) +columns of the input might be lost, because it is a valid cross-correlation, +and not a full cross-correlation. +It is up to the user to add proper padding.

    +

    The padding argument effectively adds dilation * (kernel_size - 1) - padding +amount of zero padding to both sizes of the input. This is set so that +when a ~torch.nn.Conv3d and a ~torch.nn.ConvTranspose3d +are initialized with same parameters, they are inverses of each other in +regard to the input and output shapes. However, when stride > 1, +~torch.nn.Conv3d maps multiple input shapes to the same output +shape. output_padding is provided to resolve this ambiguity by +effectively increasing the calculated output shape on one side. Note +that output_padding is only used to find output shape, but does +not actually add zero-padding to output.

    +

    In some circumstances when using the CUDA backend with CuDNN, this operator +may select a nondeterministic algorithm to increase performance. If this is +undesirable, you can try to make the operation deterministic (potentially at +a performance cost) by setting torch.backends.cudnn.deterministic = TRUE.

    +

    Shape

    + + + +
      +
    • Input: \((N, C_{in}, D_{in}, H_{in}, W_{in})\)

    • +
    • Output: \((N, C_{out}, D_{out}, H_{out}, W_{out})\) where +$$ + D_{out} = (D_{in} - 1) \times \mbox{stride}[0] - 2 \times \mbox{padding}[0] + \mbox{dilation}[0] +\times (\mbox{kernel\_size}[0] - 1) + \mbox{output\_padding}[0] + 1 +$$ +$$ + H_{out} = (H_{in} - 1) \times \mbox{stride}[1] - 2 \times \mbox{padding}[1] + \mbox{dilation}[1] +\times (\mbox{kernel\_size}[1] - 1) + \mbox{output\_padding}[1] + 1 +$$ +$$ + W_{out} = (W_{in} - 1) \times \mbox{stride}[2] - 2 \times \mbox{padding}[2] + \mbox{dilation}[2] +\times (\mbox{kernel\_size}[2] - 1) + \mbox{output\_padding}[2] + 1 +$$

    • +
    + +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of the module of shape +\((\mbox{in\_channels}, \frac{\mbox{out\_channels}}{\mbox{groups}},\) +\(\mbox{kernel\_size[0]}, \mbox{kernel\_size[1]}, \mbox{kernel\_size[2]})\). +The values of these weights are sampled from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{out}} * \prod_{i=0}^{2}\mbox{kernel\_size}[i]}\)

    • +
    • bias (Tensor): the learnable bias of the module of shape (out_channels) +If bias is True, then the values of these weights are +sampled from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{groups}{C_{\mbox{out}} * \prod_{i=0}^{2}\mbox{kernel\_size}[i]}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +# With square kernels and equal stride +m <- nn_conv_transpose3d(16, 33, 3, stride=2) +# non-square kernels and unequal stride and with padding +m <- nn_conv_transpose3d(16, 33, c(3, 5, 2), stride=c(2, 1, 1), padding=c(0, 4, 2)) +input <- torch_randn(20, 16, 10, 50, 100) +output <- m(input) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_cross_entropy_loss.html b/reference/nn_cross_entropy_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..3b9ee3842dafd3d016d549435fb906bd5fb35788 --- /dev/null +++ b/reference/nn_cross_entropy_loss.html @@ -0,0 +1,277 @@ + + + + + + + + +CrossEntropyLoss module — nn_cross_entropy_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This criterion combines nn_log_softmax() and nn_nll_loss() in one single class. +It is useful when training a classification problem with C classes.

    +
    + +
    nn_cross_entropy_loss(weight = NULL, ignore_index = -100, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + +
    weight

    (Tensor, optional): a manual rescaling weight given to each class. +If given, has to be a Tensor of size C

    ignore_index

    (int, optional): Specifies a target value that is ignored +and does not contribute to the input gradient. When size_average is +TRUE, the loss is averaged over non-ignored targets.

    reduction

    (string, optional): Specifies the reduction to apply to the output: +'none' | 'mean' | 'sum'. 'none': no reduction will be applied, +'mean': the sum of the output will be divided by the number of +elements in the output, 'sum': the output will be summed. Note: size_average +and reduce are in the process of being deprecated, and in the meantime, +specifying either of those two args will override reduction. Default: 'mean'

    + +

    Details

    + +

    If provided, the optional argument weight should be a 1D Tensor +assigning weight to each of the classes.

    +

    This is particularly useful when you have an unbalanced training set. +The input is expected to contain raw, unnormalized scores for each class. +input has to be a Tensor of size either \((minibatch, C)\) or +\((minibatch, C, d_1, d_2, ..., d_K)\) +with \(K \geq 1\) for the K-dimensional case (described later).

    +

    This criterion expects a class index in the range \([0, C-1]\) as the +target for each value of a 1D tensor of size minibatch; if ignore_index +is specified, this criterion also accepts this class index (this index may not +necessarily be in the class range).

    +

    The loss can be described as: +$$ + \mbox{loss}(x, class) = -\log\left(\frac{\exp(x[class])}{\sum_j \exp(x[j])}\right) += -x[class] + \log\left(\sum_j \exp(x[j])\right) +$$ +or in the case of the weight argument being specified: +$$ + \mbox{loss}(x, class) = weight[class] \left(-x[class] + \log\left(\sum_j \exp(x[j])\right)\right) +$$

    +

    The losses are averaged across observations for each minibatch. +Can also be used for higher dimension inputs, such as 2D images, by providing +an input of size \((minibatch, C, d_1, d_2, ..., d_K)\) with \(K \geq 1\), +where \(K\) is the number of dimensions, and a target of appropriate shape +(see below).

    +

    Shape

    + + + +
      +
    • Input: \((N, C)\) where C = number of classes, or +\((N, C, d_1, d_2, ..., d_K)\) with \(K \geq 1\) +in the case of K-dimensional loss.

    • +
    • Target: \((N)\) where each value is \(0 \leq \mbox{targets}[i] \leq C-1\), or +\((N, d_1, d_2, ..., d_K)\) with \(K \geq 1\) in the case of +K-dimensional loss.

    • +
    • Output: scalar. +If reduction is 'none', then the same size as the target: +\((N)\), or +\((N, d_1, d_2, ..., d_K)\) with \(K \geq 1\) in the case +of K-dimensional loss.

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +loss <- nn_cross_entropy_loss() +input <- torch_randn(3, 5, requires_grad=TRUE) +target <- torch_randint(low = 1, high = 5, size = 3, dtype = torch_long()) +output <- loss(input, target) +output$backward() + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_dropout.html b/reference/nn_dropout.html new file mode 100644 index 0000000000000000000000000000000000000000..9c9e94f18f425fd6ca4d765a7af6729b4ddc4d1c --- /dev/null +++ b/reference/nn_dropout.html @@ -0,0 +1,239 @@ + + + + + + + + +Dropout module — nn_dropout • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    During training, randomly zeroes some of the elements of the input +tensor with probability p using samples from a Bernoulli +distribution. Each channel will be zeroed out independently on every forward +call.

    +
    + +
    nn_dropout(p = 0.5, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    p

    probability of an element to be zeroed. Default: 0.5

    inplace

    If set to TRUE, will do this operation in-place. Default: FALSE.

    + +

    Details

    + +

    This has proven to be an effective technique for regularization and +preventing the co-adaptation of neurons as described in the paper +Improving neural networks by preventing co-adaptation of feature detectors.

    +

    Furthermore, the outputs are scaled by a factor of :math:\frac{1}{1-p} during +training. This means that during evaluation the module simply computes an +identity function.

    +

    Shape

    + + + +
      +
    • Input: \((*)\). Input can be of any shape

    • +
    • Output: \((*)\). Output is of the same shape as input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_dropout(p = 0.2) +input <- torch_randn(20, 16) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_dropout2d.html b/reference/nn_dropout2d.html new file mode 100644 index 0000000000000000000000000000000000000000..d38132d57a3b3f6a558975f7439762871f420ae3 --- /dev/null +++ b/reference/nn_dropout2d.html @@ -0,0 +1,243 @@ + + + + + + + + +Dropout2D module — nn_dropout2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randomly zero out entire channels (a channel is a 2D feature map, +e.g., the \(j\)-th channel of the \(i\)-th sample in the +batched input is a 2D tensor \(\mbox{input}[i, j]\)).

    +
    + +
    nn_dropout2d(p = 0.5, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    p

    (float, optional): probability of an element to be zero-ed.

    inplace

    (bool, optional): If set to TRUE, will do this operation +in-place

    + +

    Details

    + +

    Each channel will be zeroed out independently on every forward call with +probability p using samples from a Bernoulli distribution. +Usually the input comes from nn_conv2d modules.

    +

    As described in the paper +Efficient Object Localization Using Convolutional Networks , +if adjacent pixels within feature maps are strongly correlated +(as is normally the case in early convolution layers) then i.i.d. dropout +will not regularize the activations and will otherwise just result +in an effective learning rate decrease. +In this case, nn_dropout2d will help promote independence between +feature maps and should be used instead.

    +

    Shape

    + + + +
      +
    • Input: \((N, C, H, W)\)

    • +
    • Output: \((N, C, H, W)\) (same shape as input)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_dropout2d(p = 0.2) +input <- torch_randn(20, 16, 32, 32) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_dropout3d.html b/reference/nn_dropout3d.html new file mode 100644 index 0000000000000000000000000000000000000000..cbcbefcb96da8f97d5f0d3f92183defed5af1977 --- /dev/null +++ b/reference/nn_dropout3d.html @@ -0,0 +1,243 @@ + + + + + + + + +Dropout3D module — nn_dropout3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randomly zero out entire channels (a channel is a 3D feature map, +e.g., the \(j\)-th channel of the \(i\)-th sample in the +batched input is a 3D tensor \(\mbox{input}[i, j]\)).

    +
    + +
    nn_dropout3d(p = 0.5, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    p

    (float, optional): probability of an element to be zeroed.

    inplace

    (bool, optional): If set to TRUE, will do this operation +in-place

    + +

    Details

    + +

    Each channel will be zeroed out independently on every forward call with +probability p using samples from a Bernoulli distribution. +Usually the input comes from nn_conv2d modules.

    +

    As described in the paper +Efficient Object Localization Using Convolutional Networks , +if adjacent pixels within feature maps are strongly correlated +(as is normally the case in early convolution layers) then i.i.d. dropout +will not regularize the activations and will otherwise just result +in an effective learning rate decrease.

    +

    In this case, nn_dropout3d will help promote independence between +feature maps and should be used instead.

    +

    Shape

    + + + +
      +
    • Input: \((N, C, D, H, W)\)

    • +
    • Output: \((N, C, D, H, W)\) (same shape as input)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_dropout3d(p = 0.2) +input <- torch_randn(20, 16, 4, 32, 32) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_elu.html b/reference/nn_elu.html new file mode 100644 index 0000000000000000000000000000000000000000..e8ef47c680a67d2fd405622964c3e6df3008dadd --- /dev/null +++ b/reference/nn_elu.html @@ -0,0 +1,231 @@ + + + + + + + + +ELU module — nn_elu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_elu(alpha = 1, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    alpha

    the \(\alpha\) value for the ELU formulation. Default: 1.0

    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    $$ + \mbox{ELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x) - 1)) +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_elu() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_embedding.html b/reference/nn_embedding.html new file mode 100644 index 0000000000000000000000000000000000000000..7f07a8fc721521d81e54f24045495db338a308a7 --- /dev/null +++ b/reference/nn_embedding.html @@ -0,0 +1,294 @@ + + + + + + + + +Embedding module — nn_embedding • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A simple lookup table that stores embeddings of a fixed dictionary and size. +This module is often used to store word embeddings and retrieve them using indices. +The input to the module is a list of indices, and the output is the corresponding +word embeddings.

    +
    + +
    nn_embedding(
    +  num_embeddings,
    +  embedding_dim,
    +  padding_idx = NULL,
    +  max_norm = NULL,
    +  norm_type = 2,
    +  scale_grad_by_freq = FALSE,
    +  sparse = FALSE,
    +  .weight = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    num_embeddings

    (int): size of the dictionary of embeddings

    embedding_dim

    (int): the size of each embedding vector

    padding_idx

    (int, optional): If given, pads the output with the embedding vector at padding_idx +(initialized to zeros) whenever it encounters the index.

    max_norm

    (float, optional): If given, each embedding vector with norm larger than max_norm +is renormalized to have norm max_norm.

    norm_type

    (float, optional): The p of the p-norm to compute for the max_norm option. Default 2.

    scale_grad_by_freq

    (boolean, optional): If given, this will scale gradients by the inverse of frequency of +the words in the mini-batch. Default False.

    sparse

    (bool, optional): If True, gradient w.r.t. weight matrix will be a sparse tensor.

    .weight

    (Tensor) embeddings weights (in case you want to set it manually)

    +

    See Notes for more details regarding sparse gradients.

    + +

    Note

    + +

    Keep in mind that only a limited number of optimizers support +sparse gradients: currently it's optim.SGD (CUDA and CPU), +optim.SparseAdam (CUDA and CPU) and optim.Adagrad (CPU)

    +

    With padding_idx set, the embedding vector at +padding_idx is initialized to all zeros. However, note that this +vector can be modified afterwards, e.g., using a customized +initialization method, and thus changing the vector used to pad the +output. The gradient for this vector from nn_embedding +is always zero.

    +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of the module of shape (num_embeddings, embedding_dim) +initialized from \(\mathcal{N}(0, 1)\)

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((*)\), LongTensor of arbitrary shape containing the indices to extract

    • +
    • Output: \((*, H)\), where * is the input shape and \(H=\mbox{embedding\_dim}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +# an Embedding module containing 10 tensors of size 3 +embedding <- nn_embedding(10, 3) +# a batch of 2 samples of 4 indices each +input <- torch_tensor(rbind(c(1,2,4,5),c(4,3,2,9)), dtype = torch_long()) +embedding(input) +# example with padding_idx +embedding <- nn_embedding(10, 3, padding_idx=1) +input <- torch_tensor(matrix(c(1,3,1,6), nrow = 1), dtype = torch_long()) +embedding(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_fractional_max_pool2d.html b/reference/nn_fractional_max_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..3de0b50dc8c3dd4f8174352ca4203dc78b704ae3 --- /dev/null +++ b/reference/nn_fractional_max_pool2d.html @@ -0,0 +1,243 @@ + + + + + + + + +Applies a 2D fractional max pooling over an input signal composed of several input planes. — nn_fractional_max_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fractional MaxPooling is described in detail in the paper +Fractional MaxPooling by Ben Graham

    +
    + +
    nn_fractional_max_pool2d(
    +  kernel_size,
    +  output_size = NULL,
    +  output_ratio = NULL,
    +  return_indices = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window to take a max over. +Can be a single number k (for a square kernel of k x k) or a tuple (kh, kw)

    output_size

    the target output size of the image of the form oH x oW. +Can be a tuple (oH, oW) or a single number oH for a square image oH x oH

    output_ratio

    If one wants to have an output size as a ratio of the input size, this option can be given. +This has to be a number or tuple in the range (0, 1)

    return_indices

    if TRUE, will return the indices along with the outputs. +Useful to pass to nn_max_unpool2d(). Default: FALSE

    + +

    Details

    + +

    The max-pooling operation is applied in \(kH \times kW\) regions by a stochastic +step size determined by the target output size. +The number of output features is equal to the number of input planes.

    + +

    Examples

    +
    if (torch_is_installed()) { +# pool of square window of size=3, and target output size 13x12 +m = nn_fractional_max_pool2d(3, output_size=c(13, 12)) +# pool of square window and target output size being half of input image size +m = nn_fractional_max_pool2d(3, output_ratio=c(0.5, 0.5)) +input = torch_randn(20, 16, 50, 32) +output = m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_fractional_max_pool3d.html b/reference/nn_fractional_max_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..0a2dce1bc8b36e3956c413cefb6325b6cb4432db --- /dev/null +++ b/reference/nn_fractional_max_pool3d.html @@ -0,0 +1,243 @@ + + + + + + + + +Applies a 3D fractional max pooling over an input signal composed of several input planes. — nn_fractional_max_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fractional MaxPooling is described in detail in the paper +Fractional MaxPooling by Ben Graham

    +
    + +
    nn_fractional_max_pool3d(
    +  kernel_size,
    +  output_size = NULL,
    +  output_ratio = NULL,
    +  return_indices = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window to take a max over. +Can be a single number k (for a square kernel of k x k x k) or a tuple (kt x kh x kw)

    output_size

    the target output size of the image of the form oT x oH x oW. +Can be a tuple (oT, oH, oW) or a single number oH for a square image oH x oH x oH

    output_ratio

    If one wants to have an output size as a ratio of the input size, this option can be given. +This has to be a number or tuple in the range (0, 1)

    return_indices

    if TRUE, will return the indices along with the outputs. +Useful to pass to nn_max_unpool3d(). Default: FALSE

    + +

    Details

    + +

    The max-pooling operation is applied in \(kTxkHxkW\) regions by a stochastic +step size determined by the target output size. +The number of output features is equal to the number of input planes.

    + +

    Examples

    +
    if (torch_is_installed()) { +# pool of cubic window of size=3, and target output size 13x12x11 +m = nn_fractional_max_pool3d(3, output_size=c(13, 12, 11)) +# pool of cubic window and target output size being half of input size +m = nn_fractional_max_pool3d(3, output_ratio=c(0.5, 0.5, 0.5)) +input = torch_randn(20, 16, 50, 32, 16) +output = m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_gelu.html b/reference/nn_gelu.html new file mode 100644 index 0000000000000000000000000000000000000000..c7fd2bb50bf12668c006bb6719d0fb01b54e2011 --- /dev/null +++ b/reference/nn_gelu.html @@ -0,0 +1,219 @@ + + + + + + + + +GELU module — nn_gelu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the Gaussian Error Linear Units function: +$$\mbox{GELU}(x) = x * \Phi(x)$$

    +
    + +
    nn_gelu()
    + + +

    Details

    + +

    where \(\Phi(x)\) is the Cumulative Distribution Function for Gaussian Distribution.

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m = nn_gelu() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_glu.html b/reference/nn_glu.html new file mode 100644 index 0000000000000000000000000000000000000000..f974a5ec1d3005034e19040b970fef1fbf320923 --- /dev/null +++ b/reference/nn_glu.html @@ -0,0 +1,226 @@ + + + + + + + + +GLU module — nn_glu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the gated linear unit function +\({GLU}(a, b)= a \otimes \sigma(b)\) where \(a\) is the first half +of the input matrices and \(b\) is the second half.

    +
    + +
    nn_glu(dim = -1)
    + +

    Arguments

    + + + + + + +
    dim

    (int): the dimension on which to split the input. Default: -1

    + +

    Shape

    + + + +
      +
    • Input: \((\ast_1, N, \ast_2)\) where * means, any number of additional +dimensions

    • +
    • Output: \((\ast_1, M, \ast_2)\) where \(M=N/2\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_glu() +input <- torch_randn(4, 2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_hardshrink.html b/reference/nn_hardshrink.html new file mode 100644 index 0000000000000000000000000000000000000000..c87d2421b4f24612d5eaae8848342f78f6b64f1a --- /dev/null +++ b/reference/nn_hardshrink.html @@ -0,0 +1,233 @@ + + + + + + + + +Hardshwink module — nn_hardshrink • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the hard shrinkage function element-wise:

    +
    + +
    nn_hardshrink(lambd = 0.5)
    + +

    Arguments

    + + + + + + +
    lambd

    the \(\lambda\) value for the Hardshrink formulation. Default: 0.5

    + +

    Details

    + +

    $$ + \mbox{HardShrink}(x) = + \left\{ \begin{array}{ll} +x, & \mbox{ if } x > \lambda \\ +x, & \mbox{ if } x < -\lambda \\ +0, & \mbox{ otherwise } +\end{array} +\right. +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_hardshrink() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_hardsigmoid.html b/reference/nn_hardsigmoid.html new file mode 100644 index 0000000000000000000000000000000000000000..66c1d5854b8103037162947ea089c7198d492e87 --- /dev/null +++ b/reference/nn_hardsigmoid.html @@ -0,0 +1,224 @@ + + + + + + + + +Hardsigmoid module — nn_hardsigmoid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_hardsigmoid()
    + + +

    Details

    + +

    $$ +\mbox{Hardsigmoid}(x) = \left\{ \begin{array}{ll} + 0 & \mbox{if~} x \le -3, \\ + 1 & \mbox{if~} x \ge +3, \\ + x / 6 + 1 / 2 & \mbox{otherwise} +\end{array} +\right. +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_hardsigmoid() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_hardswish.html b/reference/nn_hardswish.html new file mode 100644 index 0000000000000000000000000000000000000000..4fc8aef770840b8abea265ed7d2c25a84fe3a1c1 --- /dev/null +++ b/reference/nn_hardswish.html @@ -0,0 +1,227 @@ + + + + + + + + +Hardswish module — nn_hardswish • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the hardswish function, element-wise, as described in the paper: +Searching for MobileNetV3

    +
    + +
    nn_hardswish()
    + + +

    Details

    + +

    $$ \mbox{Hardswish}(x) = \left\{ + \begin{array}{ll} + 0 & \mbox{if } x \le -3, \\ + x & \mbox{if } x \ge +3, \\ + x \cdot (x + 3)/6 & \mbox{otherwise} + \end{array} + \right. $$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +m <- nn_hardswish() +input <- torch_randn(2) +output <- m(input) +} + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_hardtanh.html b/reference/nn_hardtanh.html new file mode 100644 index 0000000000000000000000000000000000000000..b542ec8392fd0ebdd41d554917a63f32d33e264d --- /dev/null +++ b/reference/nn_hardtanh.html @@ -0,0 +1,244 @@ + + + + + + + + +Hardtanh module — nn_hardtanh • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the HardTanh function element-wise +HardTanh is defined as:

    +
    + +
    nn_hardtanh(min_val = -1, max_val = 1, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    min_val

    minimum value of the linear region range. Default: -1

    max_val

    maximum value of the linear region range. Default: 1

    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    $$ +\mbox{HardTanh}(x) = \left\{ \begin{array}{ll} + 1 & \mbox{ if } x > 1 \\ + -1 & \mbox{ if } x < -1 \\ + x & \mbox{ otherwise } \\ +\end{array} +\right. +$$

    +

    The range of the linear region :math:[-1, 1] can be adjusted using +min_val and max_val.

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_hardtanh(-2, 2) +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_identity.html b/reference/nn_identity.html new file mode 100644 index 0000000000000000000000000000000000000000..b449a9099211e4882c77c4f2b82873664749a787 --- /dev/null +++ b/reference/nn_identity.html @@ -0,0 +1,213 @@ + + + + + + + + +Identity module — nn_identity • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A placeholder identity operator that is argument-insensitive.

    +
    + +
    nn_identity(...)
    + +

    Arguments

    + + + + + + +
    ...

    any arguments (unused)

    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_identity(54, unused_argument1 = 0.1, unused_argument2 = FALSE) +input <- torch_randn(128, 20) +output <- m(input) +print(output$size()) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_calculate_gain.html b/reference/nn_init_calculate_gain.html new file mode 100644 index 0000000000000000000000000000000000000000..46fed83b015faaeb541106856fe07b4bc301f541 --- /dev/null +++ b/reference/nn_init_calculate_gain.html @@ -0,0 +1,209 @@ + + + + + + + + +Calculate gain — nn_init_calculate_gain • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Return the recommended gain value for the given nonlinearity function.

    +
    + +
    nn_init_calculate_gain(nonlinearity, param = NULL)
    + +

    Arguments

    + + + + + + + + + + +
    nonlinearity

    the non-linear function

    param

    optional parameter for the non-linear function

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_constant_.html b/reference/nn_init_constant_.html new file mode 100644 index 0000000000000000000000000000000000000000..a110ffdd7eba8053dbba127ac5da7d6e21021fba --- /dev/null +++ b/reference/nn_init_constant_.html @@ -0,0 +1,215 @@ + + + + + + + + +Constant initialization — nn_init_constant_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with the value val.

    +
    + +
    nn_init_constant_(tensor, val)
    + +

    Arguments

    + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    val

    the value to fill the tensor with

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_constant_(w, 0.3) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_dirac_.html b/reference/nn_init_dirac_.html new file mode 100644 index 0000000000000000000000000000000000000000..e31b08a1d8b58a003f3c7cf7ef610189470af586 --- /dev/null +++ b/reference/nn_init_dirac_.html @@ -0,0 +1,223 @@ + + + + + + + + +Dirac initialization — nn_init_dirac_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the 3, 4, 5-dimensional input Tensor with the Dirac +delta function. Preserves the identity of the inputs in Convolutional +layers, where as many input channels are preserved as possible. In case +of groups>1, each group of channels preserves identity.

    +
    + +
    nn_init_dirac_(tensor, groups = 1)
    + +

    Arguments

    + + + + + + + + + + +
    tensor

    a 3, 4, 5-dimensional torch.Tensor

    groups

    (optional) number of groups in the conv layer (default: 1)

    + + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +w <- torch_empty(3, 16, 5, 5) +nn_init_dirac_(w) +} + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_eye_.html b/reference/nn_init_eye_.html new file mode 100644 index 0000000000000000000000000000000000000000..3e16d7ae9931114b0e62c7b2f5c4eab742890d1a --- /dev/null +++ b/reference/nn_init_eye_.html @@ -0,0 +1,215 @@ + + + + + + + + +Eye initialization — nn_init_eye_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the 2-dimensional input Tensor with the identity matrix. +Preserves the identity of the inputs in Linear layers, where as +many inputs are preserved as possible.

    +
    + +
    nn_init_eye_(tensor)
    + +

    Arguments

    + + + + + + +
    tensor

    a 2-dimensional torch tensor.

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_eye_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_kaiming_normal_.html b/reference/nn_init_kaiming_normal_.html new file mode 100644 index 0000000000000000000000000000000000000000..1c358f8ea8df50db70deffa7232d287b0a51a5f0 --- /dev/null +++ b/reference/nn_init_kaiming_normal_.html @@ -0,0 +1,236 @@ + + + + + + + + +Kaiming normal initialization — nn_init_kaiming_normal_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with values according to the method +described in Delving deep into rectifiers: Surpassing human-level performance on ImageNet classification - He, K. et al. (2015), using a +normal distribution.

    +
    + +
    nn_init_kaiming_normal_(
    +  tensor,
    +  a = 0,
    +  mode = "fan_in",
    +  nonlinearity = "leaky_relu"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    tensor

    an n-dimensional torch.Tensor

    a

    the negative slope of the rectifier used after this layer (only used +with 'leaky_relu')

    mode

    either 'fan_in' (default) or 'fan_out'. Choosing 'fan_in' preserves +the magnitude of the variance of the weights in the forward pass. Choosing +'fan_out' preserves the magnitudes in the backwards pass.

    nonlinearity

    the non-linear function. recommended to use only with 'relu' +or 'leaky_relu' (default).

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_kaiming_normal_(w, mode = "fan_in", nonlinearity = "leaky_relu") + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_kaiming_uniform_.html b/reference/nn_init_kaiming_uniform_.html new file mode 100644 index 0000000000000000000000000000000000000000..329c7bab4fbcf427f9aab53b3c3b32b13d706483 --- /dev/null +++ b/reference/nn_init_kaiming_uniform_.html @@ -0,0 +1,236 @@ + + + + + + + + +Kaiming uniform initialization — nn_init_kaiming_uniform_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with values according to the method +described in Delving deep into rectifiers: Surpassing human-level performance on ImageNet classification - He, K. et al. (2015), using a +uniform distribution.

    +
    + +
    nn_init_kaiming_uniform_(
    +  tensor,
    +  a = 0,
    +  mode = "fan_in",
    +  nonlinearity = "leaky_relu"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    tensor

    an n-dimensional torch.Tensor

    a

    the negative slope of the rectifier used after this layer (only used +with 'leaky_relu')

    mode

    either 'fan_in' (default) or 'fan_out'. Choosing 'fan_in' preserves +the magnitude of the variance of the weights in the forward pass. Choosing +'fan_out' preserves the magnitudes in the backwards pass.

    nonlinearity

    the non-linear function. recommended to use only with 'relu' +or 'leaky_relu' (default).

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_kaiming_uniform_(w, mode = "fan_in", nonlinearity = "leaky_relu") + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_normal_.html b/reference/nn_init_normal_.html new file mode 100644 index 0000000000000000000000000000000000000000..53fe3caa103b0c9ea08021f8888730ba3e7dba74 --- /dev/null +++ b/reference/nn_init_normal_.html @@ -0,0 +1,219 @@ + + + + + + + + +Normal initialization — nn_init_normal_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with values drawn from the normal distribution

    +
    + +
    nn_init_normal_(tensor, mean = 0, std = 1)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    mean

    the mean of the normal distribution

    std

    the standard deviation of the normal distribution

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_normal_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_ones_.html b/reference/nn_init_ones_.html new file mode 100644 index 0000000000000000000000000000000000000000..09948800d80879f5a9e096618af5dfc3588f093f --- /dev/null +++ b/reference/nn_init_ones_.html @@ -0,0 +1,211 @@ + + + + + + + + +Ones initialization — nn_init_ones_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with the scalar value 1

    +
    + +
    nn_init_ones_(tensor)
    + +

    Arguments

    + + + + + + +
    tensor

    an n-dimensional Tensor

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_ones_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_orthogonal_.html b/reference/nn_init_orthogonal_.html new file mode 100644 index 0000000000000000000000000000000000000000..6cf17077c0954cd48c302b76d9f66984c4eb2786 --- /dev/null +++ b/reference/nn_init_orthogonal_.html @@ -0,0 +1,221 @@ + + + + + + + + +Orthogonal initialization — nn_init_orthogonal_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with a (semi) orthogonal matrix, as +described in Exact solutions to the nonlinear dynamics of learning in deep linear neural networks - Saxe, A. et al. (2013). The input tensor must have +at least 2 dimensions, and for tensors with more than 2 dimensions the +trailing dimensions are flattened.

    +
    + +
    nn_init_orthogonal_(tensor, gain = 1)
    + +

    Arguments

    + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    gain

    optional scaling factor

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3,5) +nn_init_orthogonal_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_sparse_.html b/reference/nn_init_sparse_.html new file mode 100644 index 0000000000000000000000000000000000000000..42bca781c1aa5ec7ad15716aada3b1c32e779538 --- /dev/null +++ b/reference/nn_init_sparse_.html @@ -0,0 +1,225 @@ + + + + + + + + +Sparse initialization — nn_init_sparse_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the 2D input Tensor as a sparse matrix, where the +non-zero elements will be drawn from the normal distribution +as described in Deep learning via Hessian-free optimization - Martens, J. (2010).

    +
    + +
    nn_init_sparse_(tensor, sparsity, std = 0.01)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    sparsity

    The fraction of elements in each column to be set to zero

    std

    the standard deviation of the normal distribution used to generate +the non-zero values

    + + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +w <- torch_empty(3, 5) +nn_init_sparse_(w, sparsity = 0.1) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_trunc_normal_.html b/reference/nn_init_trunc_normal_.html new file mode 100644 index 0000000000000000000000000000000000000000..3620b5d771d191b43dec8e0515d61003a8edaf35 --- /dev/null +++ b/reference/nn_init_trunc_normal_.html @@ -0,0 +1,229 @@ + + + + + + + + +Truncated normal initialization — nn_init_trunc_normal_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with values drawn from a truncated +normal distribution.

    +
    + +
    nn_init_trunc_normal_(tensor, mean = 0, std = 1, a = -2, b = -2)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    mean

    the mean of the normal distribution

    std

    the standard deviation of the normal distribution

    a

    the minimum cutoff value

    b

    the maximum cutoff value

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_trunc_normal_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_uniform_.html b/reference/nn_init_uniform_.html new file mode 100644 index 0000000000000000000000000000000000000000..ea5126a63cbaccbbe7457cc093c2d6ae4cb3afe0 --- /dev/null +++ b/reference/nn_init_uniform_.html @@ -0,0 +1,219 @@ + + + + + + + + +Uniform initialization — nn_init_uniform_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with values drawn from the uniform distribution

    +
    + +
    nn_init_uniform_(tensor, a = 0, b = 1)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    a

    the lower bound of the uniform distribution

    b

    the upper bound of the uniform distribution

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_uniform_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_xavier_normal_.html b/reference/nn_init_xavier_normal_.html new file mode 100644 index 0000000000000000000000000000000000000000..5e4a989133bb31f7d986f3b644c068e2c14decee --- /dev/null +++ b/reference/nn_init_xavier_normal_.html @@ -0,0 +1,219 @@ + + + + + + + + +Xavier normal initialization — nn_init_xavier_normal_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with values according to the method +described in Understanding the difficulty of training deep feedforward neural networks - Glorot, X. & Bengio, Y. (2010), using a normal +distribution.

    +
    + +
    nn_init_xavier_normal_(tensor, gain = 1)
    + +

    Arguments

    + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    gain

    an optional scaling factor

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_xavier_normal_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_xavier_uniform_.html b/reference/nn_init_xavier_uniform_.html new file mode 100644 index 0000000000000000000000000000000000000000..e9881ecfa117c126605de24415b381511073544b --- /dev/null +++ b/reference/nn_init_xavier_uniform_.html @@ -0,0 +1,219 @@ + + + + + + + + +Xavier uniform initialization — nn_init_xavier_uniform_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with values according to the method +described in Understanding the difficulty of training deep feedforward neural networks - Glorot, X. & Bengio, Y. (2010), using a uniform +distribution.

    +
    + +
    nn_init_xavier_uniform_(tensor, gain = 1)
    + +

    Arguments

    + + + + + + + + + + +
    tensor

    an n-dimensional Tensor

    gain

    an optional scaling factor

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_xavier_uniform_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_init_zeros_.html b/reference/nn_init_zeros_.html new file mode 100644 index 0000000000000000000000000000000000000000..c2b52ca1463f65f5653596df19a64a9f5e714e54 --- /dev/null +++ b/reference/nn_init_zeros_.html @@ -0,0 +1,211 @@ + + + + + + + + +Zeros initialization — nn_init_zeros_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fills the input Tensor with the scalar value 0

    +
    + +
    nn_init_zeros_(tensor)
    + +

    Arguments

    + + + + + + +
    tensor

    an n-dimensional tensor

    + + +

    Examples

    +
    if (torch_is_installed()) { +w <- torch_empty(3, 5) +nn_init_zeros_(w) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_leaky_relu.html b/reference/nn_leaky_relu.html new file mode 100644 index 0000000000000000000000000000000000000000..8ec4f53a9ed614bed6083a162f1f0f433b3798f7 --- /dev/null +++ b/reference/nn_leaky_relu.html @@ -0,0 +1,240 @@ + + + + + + + + +LeakyReLU module — nn_leaky_relu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_leaky_relu(negative_slope = 0.01, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    negative_slope

    Controls the angle of the negative slope. Default: 1e-2

    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    $$ + \mbox{LeakyReLU}(x) = \max(0, x) + \mbox{negative\_slope} * \min(0, x) +$$ +or

    +

    $$ + \mbox{LeakyRELU}(x) = + \left\{ \begin{array}{ll} +x, & \mbox{ if } x \geq 0 \\ +\mbox{negative\_slope} \times x, & \mbox{ otherwise } +\end{array} +\right. +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_leaky_relu(0.1) +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_linear.html b/reference/nn_linear.html new file mode 100644 index 0000000000000000000000000000000000000000..c6566de908f1afec0ab9a3d91b420241c4d17d00 --- /dev/null +++ b/reference/nn_linear.html @@ -0,0 +1,248 @@ + + + + + + + + +Linear module — nn_linear • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a linear transformation to the incoming data: y = xA^T + b

    +
    + +
    nn_linear(in_features, out_features, bias = TRUE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    in_features

    size of each input sample

    out_features

    size of each output sample

    bias

    If set to FALSE, the layer will not learn an additive bias. +Default: TRUE

    + +

    Shape

    + + + +
      +
    • Input: (N, *, H_in) where * means any number of +additional dimensions and H_in = in_features.

    • +
    • Output: (N, *, H_out) where all but the last dimension +are the same shape as the input and :math:H_out = out_features.

    • +
    + +

    Attributes

    + + + +
      +
    • weight: the learnable weights of the module of shape +(out_features, in_features). The values are +initialized from \(U(-\sqrt{k}, \sqrt{k})\)s, where +\(k = \frac{1}{\mbox{in\_features}}\)

    • +
    • bias: the learnable bias of the module of shape \((\mbox{out\_features})\). +If bias is TRUE, the values are initialized from +\(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where +\(k = \frac{1}{\mbox{in\_features}}\)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_linear(20, 30) +input <- torch_randn(128, 20) +output <- m(input) +print(output$size()) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_log_sigmoid.html b/reference/nn_log_sigmoid.html new file mode 100644 index 0000000000000000000000000000000000000000..b7b012c3da73225c1688e977e57c56dea06ef0d6 --- /dev/null +++ b/reference/nn_log_sigmoid.html @@ -0,0 +1,220 @@ + + + + + + + + +LogSigmoid module — nn_log_sigmoid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function: +$$ + \mbox{LogSigmoid}(x) = \log\left(\frac{ 1 }{ 1 + \exp(-x)}\right) + $$

    +
    + +
    nn_log_sigmoid()
    + + +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_log_sigmoid() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_log_softmax.html b/reference/nn_log_softmax.html new file mode 100644 index 0000000000000000000000000000000000000000..40c4a6f712ef6a4f2f6b4bd0a45db69eec319638 --- /dev/null +++ b/reference/nn_log_softmax.html @@ -0,0 +1,233 @@ + + + + + + + + +LogSoftmax module — nn_log_softmax • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the \(\log(\mbox{Softmax}(x))\) function to an n-dimensional +input Tensor. The LogSoftmax formulation can be simplified as:

    +
    + +
    nn_log_softmax(dim)
    + +

    Arguments

    + + + + + + +
    dim

    (int): A dimension along which LogSoftmax will be computed.

    + +

    Value

    + +

    a Tensor of the same dimension and shape as the input with +values in the range [-inf, 0)

    +

    Details

    + +

    $$ + \mbox{LogSoftmax}(x_{i}) = \log\left(\frac{\exp(x_i) }{ \sum_j \exp(x_j)} \right) +$$

    +

    Shape

    + + + +
      +
    • Input: \((*)\) where * means, any number of additional +dimensions

    • +
    • Output: \((*)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_log_softmax(1) +input <- torch_randn(2, 3) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_lp_pool1d.html b/reference/nn_lp_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..73b9a712a08ab678d6a4bd82c05d5562d2fba27a --- /dev/null +++ b/reference/nn_lp_pool1d.html @@ -0,0 +1,259 @@ + + + + + + + + +Applies a 1D power-average pooling over an input signal composed of several input +planes. — nn_lp_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    On each window, the function computed is:

    +

    $$ + f(X) = \sqrt[p]{\sum_{x \in X} x^{p}} +$$

    +
    + +
    nn_lp_pool1d(norm_type, kernel_size, stride = NULL, ceil_mode = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    norm_type

    if inf than one gets max pooling if 0 you get sum pooling ( +proportional to the avg pooling)

    kernel_size

    a single int, the size of the window

    stride

    a single int, the stride of the window. Default value is kernel_size

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    + +

    Details

    + + +
      +
    • At p = \(\infty\), one gets Max Pooling

    • +
    • At p = 1, one gets Sum Pooling (which is proportional to Average Pooling)

    • +
    + +

    Note

    + +

    If the sum to the power of p is zero, the gradient of this function is +not defined. This implementation will set the gradient to zero in this case.

    +

    Shape

    + + + +
      +
    • Input: \((N, C, L_{in})\)

    • +
    • Output: \((N, C, L_{out})\), where

    • +
    + +

    $$ + L_{out} = \left\lfloor\frac{L_{in} - \text{kernel\_size}}{\text{stride}} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +# power-2 pool of window of length 3, with stride 2. +m <- nn_lp_pool1d(2, 3, stride=2) +input <- torch_randn(20, 16, 50) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_lp_pool2d.html b/reference/nn_lp_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..fff72bbb21ec7a93d0a12008fafbee6545f1a6e1 --- /dev/null +++ b/reference/nn_lp_pool2d.html @@ -0,0 +1,271 @@ + + + + + + + + +Applies a 2D power-average pooling over an input signal composed of several input +planes. — nn_lp_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    On each window, the function computed is:

    +

    $$ + f(X) = \sqrt[p]{\sum_{x \in X} x^{p}} +$$

    +
    + +
    nn_lp_pool2d(norm_type, kernel_size, stride = NULL, ceil_mode = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    norm_type

    if inf than one gets max pooling if 0 you get sum pooling ( +proportional to the avg pooling)

    kernel_size

    the size of the window

    stride

    the stride of the window. Default value is kernel_size

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    + +

    Details

    + + +
      +
    • At p = \(\infty\), one gets Max Pooling

    • +
    • At p = 1, one gets Sum Pooling (which is proportional to average pooling)

    • +
    + +

    The parameters kernel_size, stride can either be:

      +
    • a single int -- in which case the same value is used for the height and width dimension

    • +
    • a tuple of two ints -- in which case, the first int is used for the height dimension, +and the second int for the width dimension

    • +
    + +

    Note

    + +

    If the sum to the power of p is zero, the gradient of this function is +not defined. This implementation will set the gradient to zero in this case.

    +

    Shape

    + + + +
      +
    • Input: \((N, C, H_{in}, W_{in})\)

    • +
    • Output: \((N, C, H_{out}, W_{out})\), where

    • +
    + +

    $$ + H_{out} = \left\lfloor\frac{H_{in} - \text{kernel\_size}[0]}{\text{stride}[0]} + 1\right\rfloor +$$ +$$ + W_{out} = \left\lfloor\frac{W_{in} - \text{kernel\_size}[1]}{\text{stride}[1]} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +# power-2 pool of square window of size=3, stride=2 +m <- nn_lp_pool2d(2, 3, stride=2) +# pool of non-square window of power 1.2 +m <- nn_lp_pool2d(1.2, c(3, 2), stride=c(2, 1)) +input <- torch_randn(20, 16, 50, 32) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_max_pool1d.html b/reference/nn_max_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..57640936a1995401f3a4b6451c321430159f333b --- /dev/null +++ b/reference/nn_max_pool1d.html @@ -0,0 +1,268 @@ + + + + + + + + +MaxPool1D module — nn_max_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D max pooling over an input signal composed of several input +planes.

    +
    + +
    nn_max_pool1d(
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  dilation = 1,
    +  return_indices = FALSE,
    +  ceil_mode = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window to take a max over

    stride

    the stride of the window. Default value is kernel_size

    padding

    implicit zero padding to be added on both sides

    dilation

    a parameter that controls the stride of elements in the window

    return_indices

    if TRUE, will return the max indices along with the outputs. +Useful for nn_max_unpool1d() later.

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    + +

    Details

    + +

    In the simplest case, the output value of the layer with input size \((N, C, L)\) +and output \((N, C, L_{out})\) can be precisely described as:

    +

    $$ + out(N_i, C_j, k) = \max_{m=0, \ldots, \mbox{kernel\_size} - 1} +input(N_i, C_j, stride \times k + m) +$$

    +

    If padding is non-zero, then the input is implicitly zero-padded on both sides +for padding number of points. dilation controls the spacing between the kernel points. +It is harder to describe, but this link +has a nice visualization of what dilation does.

    +

    Shape

    + + + +
      +
    • Input: \((N, C, L_{in})\)

    • +
    • Output: \((N, C, L_{out})\), where

    • +
    + +

    $$ + L_{out} = \left\lfloor \frac{L_{in} + 2 \times \mbox{padding} - \mbox{dilation} + \times (\mbox{kernel\_size} - 1) - 1}{\mbox{stride}} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +# pool of size=3, stride=2 +m <- nn_max_pool1d(3, stride=2) +input <- torch_randn(20, 16, 50) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_max_pool2d.html b/reference/nn_max_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..ea5dc77466aba10d2d98523cf7c2080591145994 --- /dev/null +++ b/reference/nn_max_pool2d.html @@ -0,0 +1,283 @@ + + + + + + + + +MaxPool2D module — nn_max_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D max pooling over an input signal composed of several input +planes.

    +
    + +
    nn_max_pool2d(
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  dilation = 1,
    +  return_indices = FALSE,
    +  ceil_mode = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window to take a max over

    stride

    the stride of the window. Default value is kernel_size

    padding

    implicit zero padding to be added on both sides

    dilation

    a parameter that controls the stride of elements in the window

    return_indices

    if TRUE, will return the max indices along with the outputs. +Useful for nn_max_unpool2d() later.

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    + +

    Details

    + +

    In the simplest case, the output value of the layer with input size \((N, C, H, W)\), +output \((N, C, H_{out}, W_{out})\) and kernel_size \((kH, kW)\) +can be precisely described as:

    +

    $$ + \begin{array}{ll} +out(N_i, C_j, h, w) ={} & \max_{m=0, \ldots, kH-1} \max_{n=0, \ldots, kW-1} \\ +& \mbox{input}(N_i, C_j, \mbox{stride[0]} \times h + m, + \mbox{stride[1]} \times w + n) +\end{array} +$$

    +

    If padding is non-zero, then the input is implicitly zero-padded on both sides +for padding number of points. dilation controls the spacing between the kernel points. +It is harder to describe, but this link has a nice visualization of what dilation does.

    +

    The parameters kernel_size, stride, padding, dilation can either be:

      +
    • a single int -- in which case the same value is used for the height and width dimension

    • +
    • a tuple of two ints -- in which case, the first int is used for the height dimension, +and the second int for the width dimension

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((N, C, H_{in}, W_{in})\)

    • +
    • Output: \((N, C, H_{out}, W_{out})\), where

    • +
    + +

    $$ + H_{out} = \left\lfloor\frac{H_{in} + 2 * \mbox{padding[0]} - \mbox{dilation[0]} + \times (\mbox{kernel\_size[0]} - 1) - 1}{\mbox{stride[0]}} + 1\right\rfloor +$$

    +

    $$ + W_{out} = \left\lfloor\frac{W_{in} + 2 * \mbox{padding[1]} - \mbox{dilation[1]} + \times (\mbox{kernel\_size[1]} - 1) - 1}{\mbox{stride[1]}} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +# pool of square window of size=3, stride=2 +m <- nn_max_pool2d(3, stride=2) +# pool of non-square window +m <- nn_max_pool2d(c(3, 2), stride=c(2, 1)) +input <- torch_randn(20, 16, 50, 32) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_max_pool3d.html b/reference/nn_max_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..8f8a3f6b5bdb4866a40e26b64b2d8e95215d74fe --- /dev/null +++ b/reference/nn_max_pool3d.html @@ -0,0 +1,289 @@ + + + + + + + + +Applies a 3D max pooling over an input signal composed of several input +planes. — nn_max_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    In the simplest case, the output value of the layer with input size \((N, C, D, H, W)\), +output \((N, C, D_{out}, H_{out}, W_{out})\) and kernel_size \((kD, kH, kW)\) +can be precisely described as:

    +
    + +
    nn_max_pool3d(
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  dilation = 1,
    +  return_indices = FALSE,
    +  ceil_mode = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    kernel_size

    the size of the window to take a max over

    stride

    the stride of the window. Default value is kernel_size

    padding

    implicit zero padding to be added on all three sides

    dilation

    a parameter that controls the stride of elements in the window

    return_indices

    if TRUE, will return the max indices along with the outputs. +Useful for torch_nn.MaxUnpool3d later

    ceil_mode

    when TRUE, will use ceil instead of floor to compute the output shape

    + +

    Details

    + +

    $$ + \begin{aligned} +\text{out}(N_i, C_j, d, h, w) ={} & \max_{k=0, \ldots, kD-1} \max_{m=0, \ldots, kH-1} \max_{n=0, \ldots, kW-1} \\ +& \text{input}(N_i, C_j, \text{stride[0]} \times d + k, + \text{stride[1]} \times h + m, \text{stride[2]} \times w + n) +\end{aligned} +$$

    +

    If padding is non-zero, then the input is implicitly zero-padded on both sides +for padding number of points. dilation controls the spacing between the kernel points. +It is harder to describe, but this link_ has a nice visualization of what dilation does. +The parameters kernel_size, stride, padding, dilation can either be:

      +
    • a single int -- in which case the same value is used for the depth, height and width dimension

    • +
    • a tuple of three ints -- in which case, the first int is used for the depth dimension, +the second int for the height dimension and the third int for the width dimension

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((N, C, D_{in}, H_{in}, W_{in})\)

    • +
    • Output: \((N, C, D_{out}, H_{out}, W_{out})\), where +$$ + D_{out} = \left\lfloor\frac{D_{in} + 2 \times \text{padding}[0] - \text{dilation}[0] \times + (\text{kernel\_size}[0] - 1) - 1}{\text{stride}[0]} + 1\right\rfloor +$$

    • +
    + +

    $$ + H_{out} = \left\lfloor\frac{H_{in} + 2 \times \text{padding}[1] - \text{dilation}[1] \times + (\text{kernel\_size}[1] - 1) - 1}{\text{stride}[1]} + 1\right\rfloor +$$

    +

    $$ + W_{out} = \left\lfloor\frac{W_{in} + 2 \times \text{padding}[2] - \text{dilation}[2] \times + (\text{kernel\_size}[2] - 1) - 1}{\text{stride}[2]} + 1\right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +# pool of square window of size=3, stride=2 +m <- nn_max_pool3d(3, stride=2) +# pool of non-square window +m <- nn_max_pool3d(c(3, 2, 2), stride=c(2, 1, 2)) +input <- torch_randn(20, 16, 50,44, 31) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_max_unpool1d.html b/reference/nn_max_unpool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..ade5e686d524349416c3b9aca795ef889d577384 --- /dev/null +++ b/reference/nn_max_unpool1d.html @@ -0,0 +1,266 @@ + + + + + + + + +Computes a partial inverse of <code>MaxPool1d</code>. — nn_max_unpool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    MaxPool1d is not fully invertible, since the non-maximal values are lost. +MaxUnpool1d takes in as input the output of MaxPool1d +including the indices of the maximal values and computes a partial inverse +in which all non-maximal values are set to zero.

    +
    + +
    nn_max_unpool1d(kernel_size, stride = NULL, padding = 0)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    kernel_size

    (int or tuple): Size of the max pooling window.

    stride

    (int or tuple): Stride of the max pooling window. +It is set to kernel_size by default.

    padding

    (int or tuple): Padding that was added to the input

    + +

    Note

    + +

    MaxPool1d can map several input sizes to the same output +sizes. Hence, the inversion process can get ambiguous. +To accommodate this, you can provide the needed output size +as an additional argument output_size in the forward call. +See the Inputs and Example below.

    +

    Inputs

    + + + +
      +
    • input: the input Tensor to invert

    • +
    • indices: the indices given out by nn_max_pool1d()

    • +
    • output_size (optional): the targeted output size

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((N, C, H_{in})\)

    • +
    • Output: \((N, C, H_{out})\), where +$$ + H_{out} = (H_{in} - 1) \times \text{stride}[0] - 2 \times \text{padding}[0] + \text{kernel\_size}[0] +$$ +or as given by output_size in the call operator

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +pool <- nn_max_pool1d(2, stride=2, return_indices=TRUE) +unpool <- nn_max_unpool1d(2, stride=2) + +input <- torch_tensor(array(1:8/1, dim = c(1,1,8))) +out <- pool(input) +unpool(out[[1]], out[[2]]) + +# Example showcasing the use of output_size +input <- torch_tensor(array(1:8/1, dim = c(1,1,8))) +out <- pool(input) +unpool(out[[1]], out[[2]], output_size=input$size()) +unpool(out[[1]], out[[2]]) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_max_unpool2d.html b/reference/nn_max_unpool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..89c4c0023a989e519012e05dc9ce9bc5245f0c83 --- /dev/null +++ b/reference/nn_max_unpool2d.html @@ -0,0 +1,266 @@ + + + + + + + + +Computes a partial inverse of <code>MaxPool2d</code>. — nn_max_unpool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    MaxPool2d is not fully invertible, since the non-maximal values are lost. +MaxUnpool2d takes in as input the output of MaxPool2d +including the indices of the maximal values and computes a partial inverse +in which all non-maximal values are set to zero.

    +
    + +
    nn_max_unpool2d(kernel_size, stride = NULL, padding = 0)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    kernel_size

    (int or tuple): Size of the max pooling window.

    stride

    (int or tuple): Stride of the max pooling window. +It is set to kernel_size by default.

    padding

    (int or tuple): Padding that was added to the input

    + +

    Note

    + +

    MaxPool2d can map several input sizes to the same output +sizes. Hence, the inversion process can get ambiguous. +To accommodate this, you can provide the needed output size +as an additional argument output_size in the forward call. +See the Inputs and Example below.

    +

    Inputs

    + + + +
      +
    • input: the input Tensor to invert

    • +
    • indices: the indices given out by nn_max_pool2d()

    • +
    • output_size (optional): the targeted output size

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((N, C, H_{in}, W_{in})\)

    • +
    • Output: \((N, C, H_{out}, W_{out})\), where +$$ + H_{out} = (H_{in} - 1) \times \text{stride[0]} - 2 \times \text{padding[0]} + \text{kernel\_size[0]} +$$ +$$ + W_{out} = (W_{in} - 1) \times \text{stride[1]} - 2 \times \text{padding[1]} + \text{kernel\_size[1]} +$$ +or as given by output_size in the call operator

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { + +pool <- nn_max_pool2d(2, stride=2, return_indices=TRUE) +unpool <- nn_max_unpool2d(2, stride=2) +input <- torch_randn(1,1,4,4) +out <- pool(input) +unpool(out[[1]], out[[2]]) + +# specify a different output size than input size +unpool(out[[1]], out[[2]], output_size=c(1, 1, 5, 5)) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_max_unpool3d.html b/reference/nn_max_unpool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..472375f0c847bbbfe4cc0f4886d7f8d25567178e --- /dev/null +++ b/reference/nn_max_unpool3d.html @@ -0,0 +1,267 @@ + + + + + + + + +Computes a partial inverse of <code>MaxPool3d</code>. — nn_max_unpool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    MaxPool3d is not fully invertible, since the non-maximal values are lost. +MaxUnpool3d takes in as input the output of MaxPool3d +including the indices of the maximal values and computes a partial inverse +in which all non-maximal values are set to zero.

    +
    + +
    nn_max_unpool3d(kernel_size, stride = NULL, padding = 0)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    kernel_size

    (int or tuple): Size of the max pooling window.

    stride

    (int or tuple): Stride of the max pooling window. +It is set to kernel_size by default.

    padding

    (int or tuple): Padding that was added to the input

    + +

    Note

    + +

    MaxPool3d can map several input sizes to the same output +sizes. Hence, the inversion process can get ambiguous. +To accommodate this, you can provide the needed output size +as an additional argument output_size in the forward call. +See the Inputs section below.

    +

    Inputs

    + + + +
      +
    • input: the input Tensor to invert

    • +
    • indices: the indices given out by nn_max_pool3d()

    • +
    • output_size (optional): the targeted output size

    • +
    + +

    Shape

    + + + +
      +
    • Input: \((N, C, D_{in}, H_{in}, W_{in})\)

    • +
    • Output: \((N, C, D_{out}, H_{out}, W_{out})\), where

    • +
    + +

    $$ + D_{out} = (D_{in} - 1) \times \text{stride[0]} - 2 \times \text{padding[0]} + \text{kernel\_size[0]} +$$ +$$ + H_{out} = (H_{in} - 1) \times \text{stride[1]} - 2 \times \text{padding[1]} + \text{kernel\_size[1]} +$$ +$$ + W_{out} = (W_{in} - 1) \times \text{stride[2]} - 2 \times \text{padding[2]} + \text{kernel\_size[2]} +$$

    +

    or as given by output_size in the call operator

    + +

    Examples

    +
    if (torch_is_installed()) { + +# pool of square window of size=3, stride=2 +pool <- nn_max_pool3d(3, stride=2, return_indices=TRUE) +unpool <- nn_max_unpool3d(3, stride=2) +out <- pool(torch_randn(20, 16, 51, 33, 15)) +unpooled_output <- unpool(out[[1]], out[[2]]) +unpooled_output$size() + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_module.html b/reference/nn_module.html new file mode 100644 index 0000000000000000000000000000000000000000..9fe97c96109bf99e72d5acbc5a1e8919a360f4c1 --- /dev/null +++ b/reference/nn_module.html @@ -0,0 +1,234 @@ + + + + + + + + +Base class for all neural network modules. — nn_module • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Your models should also subclass this class.

    +
    + +
    nn_module(classname = NULL, inherit = nn_Module, ...)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    classname

    an optional name for the module

    inherit

    an optional module to inherit from

    ...

    methods implementation

    + +

    Details

    + +

    Modules can also contain other Modules, allowing to nest them in a tree +structure. You can assign the submodules as regular attributes.

    + +

    Examples

    +
    if (torch_is_installed()) { +model <- nn_module( + initialize = function() { + self$conv1 <- nn_conv2d(1, 20, 5) + self$conv2 <- nn_conv2d(20, 20, 5) + }, + forward = function(input) { + input <- self$conv1(input) + input <- nnf_relu(input) + input <- self$conv2(input) + input <- nnf_relu(input) + input + } +) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_module_list.html b/reference/nn_module_list.html new file mode 100644 index 0000000000000000000000000000000000000000..22d7717b355e716ab2b3b7c7c9754eba4c4b2607 --- /dev/null +++ b/reference/nn_module_list.html @@ -0,0 +1,224 @@ + + + + + + + + +Holds submodules in a list. — nn_module_list • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    nn_module_list can be indexed like a regular R list, but +modules it contains are properly registered, and will be visible by all +nn_module methods.

    +
    + +
    nn_module_list(modules = list())
    + +

    Arguments

    + + + + + + +
    modules

    a list of modules to add

    + + +

    Examples

    +
    if (torch_is_installed()) { + +my_module <- nn_module( + initialize = function() { + self$linears <- nn_module_list(lapply(1:10, function(x) nn_linear(10, 10))) + }, + forward = function(x) { + for (i in 1:length(self$linears)) + x <- self$linears[[i]](x) + x + } +) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_multihead_attention.html b/reference/nn_multihead_attention.html new file mode 100644 index 0000000000000000000000000000000000000000..6a2d1fcdb6a04349e66829c39b5e5d7c466f642a --- /dev/null +++ b/reference/nn_multihead_attention.html @@ -0,0 +1,297 @@ + + + + + + + + +MultiHead attention — nn_multihead_attention • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Allows the model to jointly attend to information +from different representation subspaces. +See reference: Attention Is All You Need

    +
    + +
    nn_multihead_attention(
    +  embed_dim,
    +  num_heads,
    +  dropout = 0,
    +  bias = TRUE,
    +  add_bias_kv = FALSE,
    +  add_zero_attn = FALSE,
    +  kdim = NULL,
    +  vdim = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    embed_dim

    total dimension of the model.

    num_heads

    parallel attention heads.

    dropout

    a Dropout layer on attn_output_weights. Default: 0.0.

    bias

    add bias as module parameter. Default: True.

    add_bias_kv

    add bias to the key and value sequences at dim=0.

    add_zero_attn

    add a new batch of zeros to the key and +value sequences at dim=1.

    kdim

    total number of features in key. Default: NULL

    vdim

    total number of features in value. Default: NULL. +Note: if kdim and vdim are NULL, they will be set to embed_dim such that +query, key, and value have the same number of features.

    + +

    Details

    + +

    $$ + \mbox{MultiHead}(Q, K, V) = \mbox{Concat}(head_1,\dots,head_h)W^O +\mbox{where} head_i = \mbox{Attention}(QW_i^Q, KW_i^K, VW_i^V) +$$

    +

    Shape

    + + + + +

    Inputs:

      +
    • query: \((L, N, E)\) where L is the target sequence length, N is the batch size, E is +the embedding dimension.

    • +
    • key: \((S, N, E)\), where S is the source sequence length, N is the batch size, E is +the embedding dimension.

    • +
    • value: \((S, N, E)\) where S is the source sequence length, N is the batch size, E is +the embedding dimension.

    • +
    • key_padding_mask: \((N, S)\) where N is the batch size, S is the source sequence length. +If a ByteTensor is provided, the non-zero positions will be ignored while the position +with the zero positions will be unchanged. If a BoolTensor is provided, the positions with the +value of True will be ignored while the position with the value of False will be unchanged.

    • +
    • attn_mask: 2D mask \((L, S)\) where L is the target sequence length, S is the source sequence length. +3D mask \((N*num_heads, L, S)\) where N is the batch size, L is the target sequence length, +S is the source sequence length. attn_mask ensure that position i is allowed to attend the unmasked +positions. If a ByteTensor is provided, the non-zero positions are not allowed to attend +while the zero positions will be unchanged. If a BoolTensor is provided, positions with True +is not allowed to attend while False values will be unchanged. If a FloatTensor +is provided, it will be added to the attention weight.

    • +
    + +

    Outputs:

      +
    • attn_output: \((L, N, E)\) where L is the target sequence length, N is the batch size, +E is the embedding dimension.

    • +
    • attn_output_weights: \((N, L, S)\) where N is the batch size, +L is the target sequence length, S is the source sequence length.

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +multihead_attn = nn_multihead_attention(embed_dim, num_heads) +out <- multihead_attn(query, key, value) +attn_output <- out[[1]] +attn_output_weights <- out[[2]] +} + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_prelu.html b/reference/nn_prelu.html new file mode 100644 index 0000000000000000000000000000000000000000..2eeaaa8188b8ec90d97f7afa9bbb264c9183fb01 --- /dev/null +++ b/reference/nn_prelu.html @@ -0,0 +1,270 @@ + + + + + + + + +PReLU module — nn_prelu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function: +$$ + \mbox{PReLU}(x) = \max(0,x) + a * \min(0,x) +$$ +or +$$ + \mbox{PReLU}(x) = + \left\{ \begin{array}{ll} +x, & \mbox{ if } x \geq 0 \\ +ax, & \mbox{ otherwise } +\end{array} +\right. +$$

    +
    + +
    nn_prelu(num_parameters = 1, init = 0.25)
    + +

    Arguments

    + + + + + + + + + + +
    num_parameters

    (int): number of \(a\) to learn. +Although it takes an int as input, there is only two values are legitimate: +1, or the number of channels at input. Default: 1

    init

    (float): the initial value of \(a\). Default: 0.25

    + +

    Details

    + +

    Here \(a\) is a learnable parameter. When called without arguments, nn.prelu() uses a single +parameter \(a\) across all input channels. If called with nn_prelu(nChannels), +a separate \(a\) is used for each input channel.

    +

    Note

    + +

    weight decay should not be used when learning \(a\) for good performance.

    +

    Channel dim is the 2nd dim of input. When input has dims < 2, then there is +no channel dim and the number of channels = 1.

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + +

    Attributes

    + + + +
      +
    • weight (Tensor): the learnable weights of shape (num_parameters).

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_prelu() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_relu.html b/reference/nn_relu.html new file mode 100644 index 0000000000000000000000000000000000000000..a63d7980d2bde5ad7c50232d9ccceab7268384b1 --- /dev/null +++ b/reference/nn_relu.html @@ -0,0 +1,224 @@ + + + + + + + + +ReLU module — nn_relu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the rectified linear unit function element-wise +$$\mbox{ReLU}(x) = (x)^+ = \max(0, x)$$

    +
    + +
    nn_relu(inplace = FALSE)
    + +

    Arguments

    + + + + + + +
    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_relu() +input <- torch_randn(2) +m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_relu6.html b/reference/nn_relu6.html new file mode 100644 index 0000000000000000000000000000000000000000..0533d5b458fc4c0c36fb538d1a3e6b92082597c5 --- /dev/null +++ b/reference/nn_relu6.html @@ -0,0 +1,227 @@ + + + + + + + + +ReLu6 module — nn_relu6 • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_relu6(inplace = FALSE)
    + +

    Arguments

    + + + + + + +
    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    $$ + \mbox{ReLU6}(x) = \min(\max(0,x), 6) +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_relu6() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_rnn.html b/reference/nn_rnn.html new file mode 100644 index 0000000000000000000000000000000000000000..dcecf185d48de86bc4ec6a5af52c0cf79e7e4a53 --- /dev/null +++ b/reference/nn_rnn.html @@ -0,0 +1,350 @@ + + + + + + + + +RNN module — nn_rnn • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a multi-layer Elman RNN with \(\tanh\) or \(\mbox{ReLU}\) non-linearity +to an input sequence.

    +
    + +
    nn_rnn(
    +  input_size,
    +  hidden_size,
    +  num_layers = 1,
    +  nonlinearity = NULL,
    +  bias = TRUE,
    +  batch_first = FALSE,
    +  dropout = 0,
    +  bidirectional = FALSE,
    +  ...
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input_size

    The number of expected features in the input x

    hidden_size

    The number of features in the hidden state h

    num_layers

    Number of recurrent layers. E.g., setting num_layers=2 +would mean stacking two RNNs together to form a stacked RNN, +with the second RNN taking in outputs of the first RNN and +computing the final results. Default: 1

    nonlinearity

    The non-linearity to use. Can be either 'tanh' or +'relu'. Default: 'tanh'

    bias

    If FALSE, then the layer does not use bias weights b_ih and +b_hh. Default: TRUE

    batch_first

    If TRUE, then the input and output tensors are provided +as (batch, seq, feature). Default: FALSE

    dropout

    If non-zero, introduces a Dropout layer on the outputs of each +RNN layer except the last layer, with dropout probability equal to +dropout. Default: 0

    bidirectional

    If TRUE, becomes a bidirectional RNN. Default: FALSE

    ...

    other arguments that can be passed to the super class.

    + +

    Details

    + +

    For each element in the input sequence, each layer computes the following +function:

    +

    $$ +h_t = \tanh(W_{ih} x_t + b_{ih} + W_{hh} h_{(t-1)} + b_{hh}) +$$

    +

    where \(h_t\) is the hidden state at time t, \(x_t\) is +the input at time t, and \(h_{(t-1)}\) is the hidden state of the +previous layer at time t-1 or the initial hidden state at time 0. +If nonlinearity is 'relu', then \(\mbox{ReLU}\) is used instead of +\(\tanh\).

    +

    Inputs

    + + + +
      +
    • input of shape (seq_len, batch, input_size): tensor containing the features +of the input sequence. The input can also be a packed variable length +sequence.

    • +
    • h_0 of shape (num_layers * num_directions, batch, hidden_size): tensor +containing the initial hidden state for each element in the batch. +Defaults to zero if not provided. If the RNN is bidirectional, +num_directions should be 2, else it should be 1.

    • +
    + +

    Outputs

    + + + +
      +
    • output of shape (seq_len, batch, num_directions * hidden_size): tensor +containing the output features (h_t) from the last layer of the RNN, +for each t. If a :class:nn_packed_sequence has +been given as the input, the output will also be a packed sequence. +For the unpacked case, the directions can be separated +using output$view(seq_len, batch, num_directions, hidden_size), +with forward and backward being direction 0 and 1 respectively. +Similarly, the directions can be separated in the packed case.

    • +
    • h_n of shape (num_layers * num_directions, batch, hidden_size): tensor +containing the hidden state for t = seq_len. +Like output, the layers can be separated using +h_n$view(num_layers, num_directions, batch, hidden_size).

    • +
    + +

    Shape

    + + + +
      +
    • Input1: \((L, N, H_{in})\) tensor containing input features where +\(H_{in}=\mbox{input\_size}\) and L represents a sequence length.

    • +
    • Input2: \((S, N, H_{out})\) tensor +containing the initial hidden state for each element in the batch. +\(H_{out}=\mbox{hidden\_size}\) +Defaults to zero if not provided. where \(S=\mbox{num\_layers} * \mbox{num\_directions}\) +If the RNN is bidirectional, num_directions should be 2, else it should be 1.

    • +
    • Output1: \((L, N, H_{all})\) where \(H_{all}=\mbox{num\_directions} * \mbox{hidden\_size}\)

    • +
    • Output2: \((S, N, H_{out})\) tensor containing the next hidden state +for each element in the batch

    • +
    + +

    Attributes

    + + + +
      +
    • weight_ih_l[k]: the learnable input-hidden weights of the k-th layer, +of shape (hidden_size, input_size) for k = 0. Otherwise, the shape is +(hidden_size, num_directions * hidden_size)

    • +
    • weight_hh_l[k]: the learnable hidden-hidden weights of the k-th layer, +of shape (hidden_size, hidden_size)

    • +
    • bias_ih_l[k]: the learnable input-hidden bias of the k-th layer, +of shape (hidden_size)

    • +
    • bias_hh_l[k]: the learnable hidden-hidden bias of the k-th layer, +of shape (hidden_size)

    • +
    + +

    Note

    + + + + +

    All the weights and biases are initialized from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) +where \(k = \frac{1}{\mbox{hidden\_size}}\)

    + +

    Examples

    +
    if (torch_is_installed()) { +rnn <- nn_rnn(10, 20, 2) +input <- torch_randn(5, 3, 10) +h0 <- torch_randn(2, 3, 20) +rnn(input, h0) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_rrelu.html b/reference/nn_rrelu.html new file mode 100644 index 0000000000000000000000000000000000000000..e284b2afb1cada640ccd27271649d281c8a1ab7b --- /dev/null +++ b/reference/nn_rrelu.html @@ -0,0 +1,247 @@ + + + + + + + + +RReLU module — nn_rrelu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the randomized leaky rectified liner unit function, element-wise, +as described in the paper:

    +
    + +
    nn_rrelu(lower = 1/8, upper = 1/3, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    lower

    lower bound of the uniform distribution. Default: \(\frac{1}{8}\)

    upper

    upper bound of the uniform distribution. Default: \(\frac{1}{3}\)

    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    Empirical Evaluation of Rectified Activations in Convolutional Network.

    +

    The function is defined as:

    +

    $$ +\mbox{RReLU}(x) = +\left\{ \begin{array}{ll} +x & \mbox{if } x \geq 0 \\ +ax & \mbox{ otherwise } +\end{array} +\right. +$$

    +

    where \(a\) is randomly sampled from uniform distribution +\(\mathcal{U}(\mbox{lower}, \mbox{upper})\). +See: https://arxiv.org/pdf/1505.00853.pdf

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_rrelu(0.1, 0.3) +input <- torch_randn(2) +m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_selu.html b/reference/nn_selu.html new file mode 100644 index 0000000000000000000000000000000000000000..3938a6f09babd94f41f6dce62b952ea872fb0ec3 --- /dev/null +++ b/reference/nn_selu.html @@ -0,0 +1,231 @@ + + + + + + + + +SELU module — nn_selu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applied element-wise, as:

    +
    + +
    nn_selu(inplace = FALSE)
    + +

    Arguments

    + + + + + + +
    inplace

    (bool, optional): can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    $$ + \mbox{SELU}(x) = \mbox{scale} * (\max(0,x) + \min(0, \alpha * (\exp(x) - 1))) +$$

    +

    with \(\alpha = 1.6732632423543772848170429916717\) and +\(\mbox{scale} = 1.0507009873554804934193349852946\).

    +

    More details can be found in the paper +Self-Normalizing Neural Networks.

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_selu() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_sequential.html b/reference/nn_sequential.html new file mode 100644 index 0000000000000000000000000000000000000000..36b36bda2802750a9621592e10e0d96ea426c9b3 --- /dev/null +++ b/reference/nn_sequential.html @@ -0,0 +1,226 @@ + + + + + + + + +A sequential container — nn_sequential • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A sequential container. +Modules will be added to it in the order they are passed in the constructor. +See examples.

    +
    + +
    nn_sequential(..., name = NULL)
    + +

    Arguments

    + + + + + + + + + + +
    ...

    sequence of modules to be added

    name

    optional name for the generated module.

    + + +

    Examples

    +
    if (torch_is_installed()) { + +model <- nn_sequential( + nn_conv2d(1, 20, 5), + nn_relu(), + nn_conv2d(20, 64, 5), + nn_relu() +) +input <- torch_randn(32, 1, 28, 28) +output <- model(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_sigmoid.html b/reference/nn_sigmoid.html new file mode 100644 index 0000000000000000000000000000000000000000..68af7554aa14eb305cb84fe58ebef0882e68f35c --- /dev/null +++ b/reference/nn_sigmoid.html @@ -0,0 +1,219 @@ + + + + + + + + +Sigmoid module — nn_sigmoid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_sigmoid()
    + + +

    Details

    + +

    $$ + \mbox{Sigmoid}(x) = \sigma(x) = \frac{1}{1 + \exp(-x)} +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_sigmoid() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_softmax.html b/reference/nn_softmax.html new file mode 100644 index 0000000000000000000000000000000000000000..6d331fe1502f45ef97b375fda905b8c7c4dae46e --- /dev/null +++ b/reference/nn_softmax.html @@ -0,0 +1,246 @@ + + + + + + + + +Softmax module — nn_softmax • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the Softmax function to an n-dimensional input Tensor +rescaling them so that the elements of the n-dimensional output Tensor +lie in the range [0,1] and sum to 1. +Softmax is defined as:

    +
    + +
    nn_softmax(dim)
    + +

    Arguments

    + + + + + + +
    dim

    (int): A dimension along which Softmax will be computed (so every slice +along dim will sum to 1).

    + +

    Value

    + +

    : +a Tensor of the same dimension and shape as the input with +values in the range [0, 1]

    +

    Details

    + +

    $$ + \mbox{Softmax}(x_{i}) = \frac{\exp(x_i)}{\sum_j \exp(x_j)} +$$

    +

    When the input Tensor is a sparse tensor then the unspecifed +values are treated as -Inf.

    +

    Note

    + +

    This module doesn't work directly with NLLLoss, +which expects the Log to be computed between the Softmax and itself. +Use LogSoftmax instead (it's faster and has better numerical properties).

    +

    Shape

    + + + +
      +
    • Input: \((*)\) where * means, any number of additional +dimensions

    • +
    • Output: \((*)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_softmax(1) +input <- torch_randn(2, 3) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_softmax2d.html b/reference/nn_softmax2d.html new file mode 100644 index 0000000000000000000000000000000000000000..756eef17f2d7895afe195c191fbf7417c8f222f6 --- /dev/null +++ b/reference/nn_softmax2d.html @@ -0,0 +1,221 @@ + + + + + + + + +Softmax2d module — nn_softmax2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies SoftMax over features to each spatial location. +When given an image of Channels x Height x Width, it will +apply Softmax to each location \((Channels, h_i, w_j)\)

    +
    + +
    nn_softmax2d()
    + + +

    Value

    + +

    a Tensor of the same dimension and shape as the input with +values in the range [0, 1]

    +

    Shape

    + + + +
      +
    • Input: \((N, C, H, W)\)

    • +
    • Output: \((N, C, H, W)\) (same shape as input)

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_softmax2d() +input <- torch_randn(2, 3, 12, 13) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_softmin.html b/reference/nn_softmin.html new file mode 100644 index 0000000000000000000000000000000000000000..fc5b789c1dc4a7e2b7b609141d973a7395802d70 --- /dev/null +++ b/reference/nn_softmin.html @@ -0,0 +1,238 @@ + + + + + + + + +Softmin — nn_softmin • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the Softmin function to an n-dimensional input Tensor +rescaling them so that the elements of the n-dimensional output Tensor +lie in the range [0, 1] and sum to 1. +Softmin is defined as:

    +
    + +
    nn_softmin(dim)
    + +

    Arguments

    + + + + + + +
    dim

    (int): A dimension along which Softmin will be computed (so every slice +along dim will sum to 1).

    + +

    Value

    + +

    a Tensor of the same dimension and shape as the input, with +values in the range [0, 1].

    +

    Details

    + +

    $$ + \mbox{Softmin}(x_{i}) = \frac{\exp(-x_i)}{\sum_j \exp(-x_j)} +$$

    +

    Shape

    + + + +
      +
    • Input: \((*)\) where * means, any number of additional +dimensions

    • +
    • Output: \((*)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_softmin(dim = 1) +input <- torch_randn(2, 2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_softplus.html b/reference/nn_softplus.html new file mode 100644 index 0000000000000000000000000000000000000000..08611b2e0e104753045565f59d20be98a330a187 --- /dev/null +++ b/reference/nn_softplus.html @@ -0,0 +1,238 @@ + + + + + + + + +Softplus module — nn_softplus • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function: +$$ + \mbox{Softplus}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x)) +$$

    +
    + +
    nn_softplus(beta = 1, threshold = 20)
    + +

    Arguments

    + + + + + + + + + + +
    beta

    the \(\beta\) value for the Softplus formulation. Default: 1

    threshold

    values above this revert to a linear function. Default: 20

    + +

    Details

    + +

    SoftPlus is a smooth approximation to the ReLU function and can be used +to constrain the output of a machine to always be positive. +For numerical stability the implementation reverts to the linear function +when \(input \times \beta > threshold\).

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_softplus() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_softshrink.html b/reference/nn_softshrink.html new file mode 100644 index 0000000000000000000000000000000000000000..beccd43aeb6f5547e93ea7529a939ad1b64c41a2 --- /dev/null +++ b/reference/nn_softshrink.html @@ -0,0 +1,233 @@ + + + + + + + + +Softshrink module — nn_softshrink • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the soft shrinkage function elementwise:

    +
    + +
    nn_softshrink(lambd = 0.5)
    + +

    Arguments

    + + + + + + +
    lambd

    the \(\lambda\) (must be no less than zero) value for the Softshrink formulation. Default: 0.5

    + +

    Details

    + +

    $$ + \mbox{SoftShrinkage}(x) = + \left\{ \begin{array}{ll} +x - \lambda, & \mbox{ if } x > \lambda \\ +x + \lambda, & \mbox{ if } x < -\lambda \\ +0, & \mbox{ otherwise } +\end{array} +\right. +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_softshrink() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_softsign.html b/reference/nn_softsign.html new file mode 100644 index 0000000000000000000000000000000000000000..098107d41b0bd99c031dcefdf21f65d303e04de3 --- /dev/null +++ b/reference/nn_softsign.html @@ -0,0 +1,220 @@ + + + + + + + + +Softsign module — nn_softsign • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function: +$$ + \mbox{SoftSign}(x) = \frac{x}{ 1 + |x|} +$$

    +
    + +
    nn_softsign()
    + + +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_softsign() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_tanh.html b/reference/nn_tanh.html new file mode 100644 index 0000000000000000000000000000000000000000..2bb3c05116184792ef6521f4ee6035a41b78f75a --- /dev/null +++ b/reference/nn_tanh.html @@ -0,0 +1,219 @@ + + + + + + + + +Tanh module — nn_tanh • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_tanh()
    + + +

    Details

    + +

    $$ + \mbox{Tanh}(x) = \tanh(x) = \frac{\exp(x) - \exp(-x)} {\exp(x) + \exp(-x)} +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_tanh() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_tanhshrink.html b/reference/nn_tanhshrink.html new file mode 100644 index 0000000000000000000000000000000000000000..36e3a0417ffd52f809f34863ce6dda10439c1c99 --- /dev/null +++ b/reference/nn_tanhshrink.html @@ -0,0 +1,219 @@ + + + + + + + + +Tanhshrink module — nn_tanhshrink • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function:

    +
    + +
    nn_tanhshrink()
    + + +

    Details

    + +

    $$ + \mbox{Tanhshrink}(x) = x - \tanh(x) +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_tanhshrink() +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_threshold.html b/reference/nn_threshold.html new file mode 100644 index 0000000000000000000000000000000000000000..d17d7f4ee78c4c44d53d801f05f9d54518724622 --- /dev/null +++ b/reference/nn_threshold.html @@ -0,0 +1,241 @@ + + + + + + + + +Threshoold module — nn_threshold • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Thresholds each element of the input Tensor.

    +
    + +
    nn_threshold(threshold, value, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    threshold

    The value to threshold at

    value

    The value to replace with

    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    Threshold is defined as: +$$ + y = + \left\{ \begin{array}{ll} + x, &\mbox{ if } x > \mbox{threshold} \\ + \mbox{value}, &\mbox{ otherwise } + \end{array} + \right. +$$

    +

    Shape

    + + + +
      +
    • Input: \((N, *)\) where * means, any number of additional +dimensions

    • +
    • Output: \((N, *)\), same shape as the input

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { +m <- nn_threshold(0.1, 20) +input <- torch_randn(2) +output <- m(input) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_utils_rnn_pack_padded_sequence.html b/reference/nn_utils_rnn_pack_padded_sequence.html new file mode 100644 index 0000000000000000000000000000000000000000..6b03c42af0b26aedd512cf0538eeac41122cff09 --- /dev/null +++ b/reference/nn_utils_rnn_pack_padded_sequence.html @@ -0,0 +1,246 @@ + + + + + + + + +Packs a Tensor containing padded sequences of variable length. — nn_utils_rnn_pack_padded_sequence • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    input can be of size T x B x * where T is the length of the +longest sequence (equal to lengths[1]), B is the batch size, and +* is any number of dimensions (including 0). If batch_first is +TRUE, B x T x * input is expected.

    +
    + +
    nn_utils_rnn_pack_padded_sequence(
    +  input,
    +  lengths,
    +  batch_first = FALSE,
    +  enforce_sorted = TRUE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor): padded batch of variable length sequences.

    lengths

    (Tensor): list of sequences lengths of each batch element.

    batch_first

    (bool, optional): if TRUE, the input is expected in B x T x * +format.

    enforce_sorted

    (bool, optional): if TRUE, the input is expected to +contain sequences sorted by length in a decreasing order. If +FALSE, the input will get sorted unconditionally. Default: TRUE.

    + +

    Value

    + +

    a PackedSequence object

    +

    Details

    + +

    For unsorted sequences, use enforce_sorted = FALSE. If enforce_sorted is +TRUE, the sequences should be sorted by length in a decreasing order, i.e. +input[,1] should be the longest sequence, and input[,B] the shortest +one. enforce_sorted = TRUE is only necessary for ONNX export.

    +

    Note

    + +

    This function accepts any input that has at least two dimensions. You +can apply it to pack the labels, and use the output of the RNN with +them to compute the loss directly. A Tensor can be retrieved from +a PackedSequence object by accessing its .data attribute.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_utils_rnn_pack_sequence.html b/reference/nn_utils_rnn_pack_sequence.html new file mode 100644 index 0000000000000000000000000000000000000000..3bad58b3320177adbd22936cbb4af7acf289eb64 --- /dev/null +++ b/reference/nn_utils_rnn_pack_sequence.html @@ -0,0 +1,232 @@ + + + + + + + + +Packs a list of variable length Tensors — nn_utils_rnn_pack_sequence • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    sequences should be a list of Tensors of size L x *, where L is +the length of a sequence and * is any number of trailing dimensions, +including zero.

    +
    + +
    nn_utils_rnn_pack_sequence(sequences, enforce_sorted = TRUE)
    + +

    Arguments

    + + + + + + + + + + +
    sequences

    (list[Tensor]): A list of sequences of decreasing length.

    enforce_sorted

    (bool, optional): if TRUE, checks that the input +contains sequences sorted by length in a decreasing order. If +FALSE, this condition is not checked. Default: TRUE.

    + +

    Value

    + +

    a PackedSequence object

    +

    Details

    + +

    For unsorted sequences, use enforce_sorted = FALSE. If enforce_sorted +is TRUE, the sequences should be sorted in the order of decreasing length. +enforce_sorted = TRUE is only necessary for ONNX export.

    + +

    Examples

    +
    if (torch_is_installed()) { +x <- torch_tensor(c(1,2,3), dtype = torch_long()) +y <- torch_tensor(c(4, 5), dtype = torch_long()) +z <- torch_tensor(c(6), dtype = torch_long()) + +p <- nn_utils_rnn_pack_sequence(list(x, y, z)) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_utils_rnn_pad_packed_sequence.html b/reference/nn_utils_rnn_pad_packed_sequence.html new file mode 100644 index 0000000000000000000000000000000000000000..b2ab19a7f40d617d9e424d0801e1690f19ec6924 --- /dev/null +++ b/reference/nn_utils_rnn_pad_packed_sequence.html @@ -0,0 +1,253 @@ + + + + + + + + +Pads a packed batch of variable length sequences. — nn_utils_rnn_pad_packed_sequence • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    It is an inverse operation to nn_utils_rnn_pack_padded_sequence().

    +
    + +
    nn_utils_rnn_pad_packed_sequence(
    +  sequence,
    +  batch_first = FALSE,
    +  padding_value = 0,
    +  total_length = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    sequence

    (PackedSequence): batch to pad

    batch_first

    (bool, optional): if True, the output will be in ``B x T x *` +format.

    padding_value

    (float, optional): values for padded elements.

    total_length

    (int, optional): if not NULL, the output will be padded to +have length total_length. This method will throw ValueError +if total_length is less than the max sequence length in +sequence.

    + +

    Value

    + +

    Tuple of Tensor containing the padded sequence, and a Tensor +containing the list of lengths of each sequence in the batch. +Batch elements will be re-ordered as they were ordered originally when +the batch was passed to nn_utils_rnn_pack_padded_sequence() or +nn_utils_rnn_pack_sequence().

    +

    Details

    + +

    The returned Tensor's data will be of size T x B x *, where T is the length +of the longest sequence and B is the batch size. If batch_first is TRUE, +the data will be transposed into B x T x * format.

    +

    Note

    + +

    total_length is useful to implement the +pack sequence -> recurrent network -> unpack sequence pattern in a +nn_module wrapped in ~torch.nn.DataParallel.

    + +

    Examples

    +
    if (torch_is_installed()) { +seq <- torch_tensor(rbind(c(1,2,0), c(3,0,0), c(4,5,6))) +lens <- c(2,1,3) +packed <- nn_utils_rnn_pack_padded_sequence(seq, lens, batch_first = TRUE, + enforce_sorted = FALSE) +packed +nn_utils_rnn_pad_packed_sequence(packed, batch_first=TRUE) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nn_utils_rnn_pad_sequence.html b/reference/nn_utils_rnn_pad_sequence.html new file mode 100644 index 0000000000000000000000000000000000000000..abca9016691282201b920a0d8e6d2aa9ac6bd834 --- /dev/null +++ b/reference/nn_utils_rnn_pad_sequence.html @@ -0,0 +1,243 @@ + + + + + + + + +Pad a list of variable length Tensors with <code>padding_value</code> — nn_utils_rnn_pad_sequence • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    pad_sequence stacks a list of Tensors along a new dimension, +and pads them to equal length. For example, if the input is list of +sequences with size L x * and if batch_first is False, and T x B x * +otherwise.

    +
    + +
    nn_utils_rnn_pad_sequence(sequences, batch_first = FALSE, padding_value = 0)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    sequences

    (list[Tensor]): list of variable length sequences.

    batch_first

    (bool, optional): output will be in B x T x * if TRUE, +or in T x B x * otherwise

    padding_value

    (float, optional): value for padded elements. Default: 0.

    + +

    Value

    + +

    Tensor of size T x B x * if batch_first is FALSE. +Tensor of size B x T x * otherwise

    +

    Details

    + +

    B is batch size. It is equal to the number of elements in sequences. +T is length of the longest sequence. +L is length of the sequence. +* is any number of trailing dimensions, including none.

    +

    Note

    + +

    This function returns a Tensor of size T x B x * or B x T x * +where T is the length of the longest sequence. This function assumes +trailing dimensions and type of all the Tensors in sequences are same.

    + +

    Examples

    +
    if (torch_is_installed()) { +a <- torch_ones(25, 300) +b <- torch_ones(22, 300) +c <- torch_ones(15, 300) +nn_utils_rnn_pad_sequence(list(a, b, c))$size() + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_adaptive_avg_pool1d.html b/reference/nnf_adaptive_avg_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..f7a8edb7ad485bd3a83f36033907ca5664c42d43 --- /dev/null +++ b/reference/nnf_adaptive_avg_pool1d.html @@ -0,0 +1,211 @@ + + + + + + + + +Adaptive_avg_pool1d — nnf_adaptive_avg_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D adaptive average pooling over an input signal composed of +several input planes.

    +
    + +
    nnf_adaptive_avg_pool1d(input, output_size)
    + +

    Arguments

    + + + + + + + + + + +
    input

    input tensor of shape (minibatch , in_channels , iW)

    output_size

    the target output size (single integer)

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_adaptive_avg_pool2d.html b/reference/nnf_adaptive_avg_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..19bf51abc1493d92ca26cd891a562946936976b5 --- /dev/null +++ b/reference/nnf_adaptive_avg_pool2d.html @@ -0,0 +1,211 @@ + + + + + + + + +Adaptive_avg_pool2d — nnf_adaptive_avg_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D adaptive average pooling over an input signal composed of +several input planes.

    +
    + +
    nnf_adaptive_avg_pool2d(input, output_size)
    + +

    Arguments

    + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iH , iW)

    output_size

    the target output size (single integer or double-integer tuple)

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_adaptive_avg_pool3d.html b/reference/nnf_adaptive_avg_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..aa74106b7aefbfb2bf9931ced4104c28f378c627 --- /dev/null +++ b/reference/nnf_adaptive_avg_pool3d.html @@ -0,0 +1,211 @@ + + + + + + + + +Adaptive_avg_pool3d — nnf_adaptive_avg_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 3D adaptive average pooling over an input signal composed of +several input planes.

    +
    + +
    nnf_adaptive_avg_pool3d(input, output_size)
    + +

    Arguments

    + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iT * iH , iW)

    output_size

    the target output size (single integer or triple-integer tuple)

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_adaptive_max_pool1d.html b/reference/nnf_adaptive_max_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..1e28c4672764c593d2614f6a56be7939f9de8bd2 --- /dev/null +++ b/reference/nnf_adaptive_max_pool1d.html @@ -0,0 +1,215 @@ + + + + + + + + +Adaptive_max_pool1d — nnf_adaptive_max_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D adaptive max pooling over an input signal composed of +several input planes.

    +
    + +
    nnf_adaptive_max_pool1d(input, output_size, return_indices = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch , in_channels , iW)

    output_size

    the target output size (single integer)

    return_indices

    whether to return pooling indices. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_adaptive_max_pool2d.html b/reference/nnf_adaptive_max_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..fccf8d1795a7bb8887e0ae4a615a6f4b88a205da --- /dev/null +++ b/reference/nnf_adaptive_max_pool2d.html @@ -0,0 +1,215 @@ + + + + + + + + +Adaptive_max_pool2d — nnf_adaptive_max_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D adaptive max pooling over an input signal composed of +several input planes.

    +
    + +
    nnf_adaptive_max_pool2d(input, output_size, return_indices = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iH , iW)

    output_size

    the target output size (single integer or double-integer tuple)

    return_indices

    whether to return pooling indices. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_adaptive_max_pool3d.html b/reference/nnf_adaptive_max_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..2e3373ed2e8ca302988f3813a64287fb8966ad0a --- /dev/null +++ b/reference/nnf_adaptive_max_pool3d.html @@ -0,0 +1,215 @@ + + + + + + + + +Adaptive_max_pool3d — nnf_adaptive_max_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 3D adaptive max pooling over an input signal composed of +several input planes.

    +
    + +
    nnf_adaptive_max_pool3d(input, output_size, return_indices = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iT * iH , iW)

    output_size

    the target output size (single integer or triple-integer tuple)

    return_indices

    whether to return pooling indices. Default:FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_affine_grid.html b/reference/nnf_affine_grid.html new file mode 100644 index 0000000000000000000000000000000000000000..e32efe5428b076df005f1a6a23649137a575b4eb --- /dev/null +++ b/reference/nnf_affine_grid.html @@ -0,0 +1,229 @@ + + + + + + + + +Affine_grid — nnf_affine_grid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Generates a 2D or 3D flow field (sampling grid), given a batch of +affine matrices theta.

    +
    + +
    nnf_affine_grid(theta, size, align_corners = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    theta

    (Tensor) input batch of affine matrices with shape +(\(N \times 2 \times 3\)) for 2D or (\(N \times 3 \times 4\)) for 3D

    size

    (torch.Size) the target output image size. (\(N \times C \times H \times W\) +for 2D or \(N \times C \times D \times H \times W\) for 3D) +Example: torch.Size((32, 3, 24, 24))

    align_corners

    (bool, optional) if True, consider -1 and 1 +to refer to the centers of the corner pixels rather than the image corners. +Refer to nnf_grid_sample() for a more complete description. A grid generated by +nnf_affine_grid() should be passed to nnf_grid_sample() with the same setting for +this option. Default: False

    + +

    Note

    + + + + +

    This function is often used in conjunction with nnf_grid_sample() +to build Spatial Transformer Networks_ .

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_alpha_dropout.html b/reference/nnf_alpha_dropout.html new file mode 100644 index 0000000000000000000000000000000000000000..95c5bcd4ec1e6629fac7dcbd01abd5de89f45765 --- /dev/null +++ b/reference/nnf_alpha_dropout.html @@ -0,0 +1,218 @@ + + + + + + + + +Alpha_dropout — nnf_alpha_dropout • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies alpha dropout to the input.

    +
    + +
    nnf_alpha_dropout(input, p = 0.5, training = FALSE, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    p

    probability of an element to be zeroed. Default: 0.5

    training

    apply dropout if is TRUE. Default: TRUE

    inplace

    If set to TRUE, will do this operation in-place. +Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_avg_pool1d.html b/reference/nnf_avg_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..4c3b3bf0d2288b8bff01dc6ee60a4e867943735a --- /dev/null +++ b/reference/nnf_avg_pool1d.html @@ -0,0 +1,239 @@ + + + + + + + + +Avg_pool1d — nnf_avg_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D average pooling over an input signal composed of several +input planes.

    +
    + +
    nnf_avg_pool1d(
    +  input,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  ceil_mode = FALSE,
    +  count_include_pad = TRUE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch , in_channels , iW)

    kernel_size

    the size of the window. Can be a single number or a +tuple (kW,).

    stride

    the stride of the window. Can be a single number or a tuple +(sW,). Default: kernel_size

    padding

    implicit zero paddings on both sides of the input. Can be a +single number or a tuple (padW,). Default: 0

    ceil_mode

    when True, will use ceil instead of floor to compute the +output shape. Default: FALSE

    count_include_pad

    when True, will include the zero-padding in the +averaging calculation. Default: TRUE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_avg_pool2d.html b/reference/nnf_avg_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..85e95aa148f9bd14d55157cb9801f99948e93c08 --- /dev/null +++ b/reference/nnf_avg_pool2d.html @@ -0,0 +1,247 @@ + + + + + + + + +Avg_pool2d — nnf_avg_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies 2D average-pooling operation in \(kH * kW\) regions by step size +\(sH * sW\) steps. The number of output features is equal to the number of +input planes.

    +
    + +
    nnf_avg_pool2d(
    +  input,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  ceil_mode = FALSE,
    +  count_include_pad = TRUE,
    +  divisor_override = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iH , iW)

    kernel_size

    size of the pooling region. Can be a single number or a +tuple (kH, kW)

    stride

    stride of the pooling operation. Can be a single number or a +tuple (sH, sW). Default: kernel_size

    padding

    implicit zero paddings on both sides of the input. Can be a +single number or a tuple (padH, padW). Default: 0

    ceil_mode

    when True, will use ceil instead of floor in the formula +to compute the output shape. Default: FALSE

    count_include_pad

    when True, will include the zero-padding in the +averaging calculation. Default: TRUE

    divisor_override

    if specified, it will be used as divisor, otherwise +size of the pooling region will be used. Default: NULL

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_avg_pool3d.html b/reference/nnf_avg_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..c4cdcd91105fa0a49c7a697acba526753a8c760a --- /dev/null +++ b/reference/nnf_avg_pool3d.html @@ -0,0 +1,247 @@ + + + + + + + + +Avg_pool3d — nnf_avg_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies 3D average-pooling operation in \(kT * kH * kW\) regions by step +size \(sT * sH * sW\) steps. The number of output features is equal to +\(\lfloor \frac{ \mbox{input planes} }{sT} \rfloor\).

    +
    + +
    nnf_avg_pool3d(
    +  input,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  ceil_mode = FALSE,
    +  count_include_pad = TRUE,
    +  divisor_override = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iT * iH , iW)

    kernel_size

    size of the pooling region. Can be a single number or a +tuple (kT, kH, kW)

    stride

    stride of the pooling operation. Can be a single number or a +tuple (sT, sH, sW). Default: kernel_size

    padding

    implicit zero paddings on both sides of the input. Can be a +single number or a tuple (padT, padH, padW), Default: 0

    ceil_mode

    when True, will use ceil instead of floor in the formula +to compute the output shape

    count_include_pad

    when True, will include the zero-padding in the +averaging calculation

    divisor_override

    NA if specified, it will be used as divisor, otherwise +size of the pooling region will be used. Default: NULL

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_batch_norm.html b/reference/nnf_batch_norm.html new file mode 100644 index 0000000000000000000000000000000000000000..2bf2e8709993421c77ac877a4225970f5b625860 --- /dev/null +++ b/reference/nnf_batch_norm.html @@ -0,0 +1,243 @@ + + + + + + + + +Batch_norm — nnf_batch_norm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies Batch Normalization for each channel across a batch of data.

    +
    + +
    nnf_batch_norm(
    +  input,
    +  running_mean,
    +  running_var,
    +  weight = NULL,
    +  bias = NULL,
    +  training = FALSE,
    +  momentum = 0.1,
    +  eps = 1e-05
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor

    running_mean

    the running_mean tensor

    running_var

    the running_var tensor

    weight

    the weight tensor

    bias

    the bias tensor

    training

    bool wether it's training. Default: FALSE

    momentum

    the value used for the running_mean and running_var computation. +Can be set to None for cumulative moving average (i.e. simple average). Default: 0.1

    eps

    a value added to the denominator for numerical stability. Default: 1e-5

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_bilinear.html b/reference/nnf_bilinear.html new file mode 100644 index 0000000000000000000000000000000000000000..b82e4228f177a87edf1bd9fcb6f4302a23831abc --- /dev/null +++ b/reference/nnf_bilinear.html @@ -0,0 +1,226 @@ + + + + + + + + +Bilinear — nnf_bilinear • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a bilinear transformation to the incoming data: +\(y = x_1 A x_2 + b\)

    +
    + +
    nnf_bilinear(input1, input2, weight, bias = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input1

    \((N, *, H_{in1})\) where \(H_{in1}=\mbox{in1\_features}\) +and \(*\) means any number of additional dimensions. +All but the last dimension of the inputs should be the same.

    input2

    \((N, *, H_{in2})\) where \(H_{in2}=\mbox{in2\_features}\)

    weight

    \((\mbox{out\_features}, \mbox{in1\_features}, +\mbox{in2\_features})\)

    bias

    \((\mbox{out\_features})\)

    + +

    Value

    + +

    output \((N, *, H_{out})\) where \(H_{out}=\mbox{out\_features}\) +and all but the last dimension are the same shape as the input.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_binary_cross_entropy.html b/reference/nnf_binary_cross_entropy.html new file mode 100644 index 0000000000000000000000000000000000000000..2a0119d7eacc46c9b875eee525fe7ceb221cca72 --- /dev/null +++ b/reference/nnf_binary_cross_entropy.html @@ -0,0 +1,227 @@ + + + + + + + + +Binary_cross_entropy — nnf_binary_cross_entropy • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Function that measures the Binary Cross Entropy +between the target and the output.

    +
    + +
    nnf_binary_cross_entropy(
    +  input,
    +  target,
    +  weight = NULL,
    +  reduction = c("mean", "sum", "none")
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    weight

    (tensor) weight for each value.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_binary_cross_entropy_with_logits.html b/reference/nnf_binary_cross_entropy_with_logits.html new file mode 100644 index 0000000000000000000000000000000000000000..5a9654c18a20920667ef2ca2723b40b7fcde8087 --- /dev/null +++ b/reference/nnf_binary_cross_entropy_with_logits.html @@ -0,0 +1,234 @@ + + + + + + + + +Binary_cross_entropy_with_logits — nnf_binary_cross_entropy_with_logits • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Function that measures Binary Cross Entropy between target and output +logits.

    +
    + +
    nnf_binary_cross_entropy_with_logits(
    +  input,
    +  target,
    +  weight = NULL,
    +  reduction = c("mean", "sum", "none"),
    +  pos_weight = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    Tensor of arbitrary shape

    target

    Tensor of the same shape as input

    weight

    (Tensor, optional) a manual rescaling weight if provided it's +repeated to match input tensor shape.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    pos_weight

    (Tensor, optional) a weight of positive examples. +Must be a vector with length equal to the number of classes.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_celu.html b/reference/nnf_celu.html new file mode 100644 index 0000000000000000000000000000000000000000..974caf0d655e74659b0934c487eb3793b3c4aaf2 --- /dev/null +++ b/reference/nnf_celu.html @@ -0,0 +1,216 @@ + + + + + + + + +Celu — nnf_celu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise, \(CELU(x) = max(0,x) + min(0, \alpha * (exp(x \alpha) - 1))\).

    +
    + +
    nnf_celu(input, alpha = 1, inplace = FALSE)
    +
    +nnf_celu_(input, alpha = 1)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    alpha

    the alpha value for the CELU formulation. Default: 1.0

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_conv1d.html b/reference/nnf_conv1d.html new file mode 100644 index 0000000000000000000000000000000000000000..2c0eb8fcf6de5a0f680eea9b4b04c12fed4b5961 --- /dev/null +++ b/reference/nnf_conv1d.html @@ -0,0 +1,243 @@ + + + + + + + + +Conv1d — nnf_conv1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D convolution over an input signal composed of several input +planes.

    +
    + +
    nnf_conv1d(
    +  input,
    +  weight,
    +  bias = NULL,
    +  stride = 1,
    +  padding = 0,
    +  dilation = 1,
    +  groups = 1
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch, in_channels , iW)

    weight

    filters of shape (out_channels, in_channels/groups , kW)

    bias

    optional bias of shape (out_channels). Default: NULL

    stride

    the stride of the convolving kernel. Can be a single number or +a one-element tuple (sW,). Default: 1

    padding

    implicit paddings on both sides of the input. Can be a +single number or a one-element tuple (padW,). Default: 0

    dilation

    the spacing between kernel elements. Can be a single number or +a one-element tuple (dW,). Default: 1

    groups

    split input into groups, in_channels should be divisible by +the number of groups. Default: 1

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_conv2d.html b/reference/nnf_conv2d.html new file mode 100644 index 0000000000000000000000000000000000000000..be24912fccaf46b75e87978015a8346840772880 --- /dev/null +++ b/reference/nnf_conv2d.html @@ -0,0 +1,243 @@ + + + + + + + + +Conv2d — nnf_conv2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D convolution over an input image composed of several input +planes.

    +
    + +
    nnf_conv2d(
    +  input,
    +  weight,
    +  bias = NULL,
    +  stride = 1,
    +  padding = 0,
    +  dilation = 1,
    +  groups = 1
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch, in_channels, iH , iW)

    weight

    filters of shape (out_channels , in_channels/groups, kH , kW)

    bias

    optional bias tensor of shape (out_channels). Default: NULL

    stride

    the stride of the convolving kernel. Can be a single number or a +tuple (sH, sW). Default: 1

    padding

    implicit paddings on both sides of the input. Can be a +single number or a tuple (padH, padW). Default: 0

    dilation

    the spacing between kernel elements. Can be a single number or +a tuple (dH, dW). Default: 1

    groups

    split input into groups, in_channels should be divisible by the +number of groups. Default: 1

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_conv3d.html b/reference/nnf_conv3d.html new file mode 100644 index 0000000000000000000000000000000000000000..80331ef63f553326c6bcbbf94dbb45e4bd65eeb3 --- /dev/null +++ b/reference/nnf_conv3d.html @@ -0,0 +1,243 @@ + + + + + + + + +Conv3d — nnf_conv3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 3D convolution over an input image composed of several input +planes.

    +
    + +
    nnf_conv3d(
    +  input,
    +  weight,
    +  bias = NULL,
    +  stride = 1,
    +  padding = 0,
    +  dilation = 1,
    +  groups = 1
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch, in_channels , iT , iH , iW)

    weight

    filters of shape (out_channels , in_channels/groups, kT , kH , kW)

    bias

    optional bias tensor of shape (out_channels). Default: NULL

    stride

    the stride of the convolving kernel. Can be a single number or a +tuple (sT, sH, sW). Default: 1

    padding

    implicit paddings on both sides of the input. Can be a +single number or a tuple (padT, padH, padW). Default: 0

    dilation

    the spacing between kernel elements. Can be a single number or +a tuple (dT, dH, dW). Default: 1

    groups

    split input into groups, in_channels should be divisible by +the number of groups. Default: 1

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_conv_tbc.html b/reference/nnf_conv_tbc.html new file mode 100644 index 0000000000000000000000000000000000000000..04bc578039a79ab4583ef2828825125eb7ea27f3 --- /dev/null +++ b/reference/nnf_conv_tbc.html @@ -0,0 +1,221 @@ + + + + + + + + +Conv_tbc — nnf_conv_tbc • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1-dimensional sequence convolution over an input sequence. +Input and output dimensions are (Time, Batch, Channels) - hence TBC.

    +
    + +
    nnf_conv_tbc(input, weight, bias, pad = 0)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape \((\mbox{sequence length} \times +batch \times \mbox{in\_channels})\)

    weight

    filter of shape (\(\mbox{kernel width} \times \mbox{in\_channels} +\times \mbox{out\_channels}\))

    bias

    bias of shape (\(\mbox{out\_channels}\))

    pad

    number of timesteps to pad. Default: 0

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_conv_transpose1d.html b/reference/nnf_conv_transpose1d.html new file mode 100644 index 0000000000000000000000000000000000000000..50ed18247b49e4e36055ebc325b4249c0566d25a --- /dev/null +++ b/reference/nnf_conv_transpose1d.html @@ -0,0 +1,248 @@ + + + + + + + + +Conv_transpose1d — nnf_conv_transpose1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D transposed convolution operator over an input signal +composed of several input planes, sometimes also called "deconvolution".

    +
    + +
    nnf_conv_transpose1d(
    +  input,
    +  weight,
    +  bias = NULL,
    +  stride = 1,
    +  padding = 0,
    +  output_padding = 0,
    +  groups = 1,
    +  dilation = 1
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch, in_channels , iW)

    weight

    filters of shape (out_channels, in_channels/groups , kW)

    bias

    optional bias of shape (out_channels). Default: NULL

    stride

    the stride of the convolving kernel. Can be a single number or +a one-element tuple (sW,). Default: 1

    padding

    implicit paddings on both sides of the input. Can be a +single number or a one-element tuple (padW,). Default: 0

    output_padding

    padding applied to the output

    groups

    split input into groups, in_channels should be divisible by +the number of groups. Default: 1

    dilation

    the spacing between kernel elements. Can be a single number or +a one-element tuple (dW,). Default: 1

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_conv_transpose2d.html b/reference/nnf_conv_transpose2d.html new file mode 100644 index 0000000000000000000000000000000000000000..d7e49efd2fefa756a398bf219c725e27bb0fea0f --- /dev/null +++ b/reference/nnf_conv_transpose2d.html @@ -0,0 +1,248 @@ + + + + + + + + +Conv_transpose2d — nnf_conv_transpose2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D transposed convolution operator over an input image +composed of several input planes, sometimes also called "deconvolution".

    +
    + +
    nnf_conv_transpose2d(
    +  input,
    +  weight,
    +  bias = NULL,
    +  stride = 1,
    +  padding = 0,
    +  output_padding = 0,
    +  groups = 1,
    +  dilation = 1
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch, in_channels, iH , iW)

    weight

    filters of shape (out_channels , in_channels/groups, kH , kW)

    bias

    optional bias tensor of shape (out_channels). Default: NULL

    stride

    the stride of the convolving kernel. Can be a single number or a +tuple (sH, sW). Default: 1

    padding

    implicit paddings on both sides of the input. Can be a +single number or a tuple (padH, padW). Default: 0

    output_padding

    padding applied to the output

    groups

    split input into groups, in_channels should be divisible by the +number of groups. Default: 1

    dilation

    the spacing between kernel elements. Can be a single number or +a tuple (dH, dW). Default: 1

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_conv_transpose3d.html b/reference/nnf_conv_transpose3d.html new file mode 100644 index 0000000000000000000000000000000000000000..8772c88e5d491f375b17ad4537efd37147e455e8 --- /dev/null +++ b/reference/nnf_conv_transpose3d.html @@ -0,0 +1,248 @@ + + + + + + + + +Conv_transpose3d — nnf_conv_transpose3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 3D transposed convolution operator over an input image +composed of several input planes, sometimes also called "deconvolution"

    +
    + +
    nnf_conv_transpose3d(
    +  input,
    +  weight,
    +  bias = NULL,
    +  stride = 1,
    +  padding = 0,
    +  output_padding = 0,
    +  groups = 1,
    +  dilation = 1
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch, in_channels , iT , iH , iW)

    weight

    filters of shape (out_channels , in_channels/groups, kT , kH , kW)

    bias

    optional bias tensor of shape (out_channels). Default: NULL

    stride

    the stride of the convolving kernel. Can be a single number or a +tuple (sT, sH, sW). Default: 1

    padding

    implicit paddings on both sides of the input. Can be a +single number or a tuple (padT, padH, padW). Default: 0

    output_padding

    padding applied to the output

    groups

    split input into groups, in_channels should be divisible by +the number of groups. Default: 1

    dilation

    the spacing between kernel elements. Can be a single number or +a tuple (dT, dH, dW). Default: 1

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_cosine_embedding_loss.html b/reference/nnf_cosine_embedding_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..32e420d4ebc0c1311ade64c325100df19cb2e2b2 --- /dev/null +++ b/reference/nnf_cosine_embedding_loss.html @@ -0,0 +1,237 @@ + + + + + + + + +Cosine_embedding_loss — nnf_cosine_embedding_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that measures the loss given input tensors x_1, x_2 and a +Tensor label y with values 1 or -1. This is used for measuring whether two inputs +are similar or dissimilar, using the cosine distance, and is typically used +for learning nonlinear embeddings or semi-supervised learning.

    +
    + +
    nnf_cosine_embedding_loss(
    +  input1,
    +  input2,
    +  target,
    +  margin = 0,
    +  reduction = c("mean", "sum", "none")
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input1

    the input x_1 tensor

    input2

    the input x_2 tensor

    target

    the target tensor

    margin

    Should be a number from -1 to 1 , 0 to 0.5 is suggested. If margin +is missing, the default value is 0.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_cosine_similarity.html b/reference/nnf_cosine_similarity.html new file mode 100644 index 0000000000000000000000000000000000000000..2c1c88b7bcd11ab7db9e18e578bed50ec19d06d0 --- /dev/null +++ b/reference/nnf_cosine_similarity.html @@ -0,0 +1,223 @@ + + + + + + + + +Cosine_similarity — nnf_cosine_similarity • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Returns cosine similarity between x1 and x2, computed along dim.

    +
    + +
    nnf_cosine_similarity(x1, x2, dim = 1, eps = 1e-08)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    x1

    (Tensor) First input.

    x2

    (Tensor) Second input (of size matching x1).

    dim

    (int, optional) Dimension of vectors. Default: 1

    eps

    (float, optional) Small value to avoid division by zero. +Default: 1e-8

    + +

    Details

    + +

    $$ + \mbox{similarity} = \frac{x_1 \cdot x_2}{\max(\Vert x_1 \Vert _2 \cdot \Vert x_2 \Vert _2, \epsilon)} +$$

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_cross_entropy.html b/reference/nnf_cross_entropy.html new file mode 100644 index 0000000000000000000000000000000000000000..b15d5a2b0c9b5f411a611724becfb156ee8ab546 --- /dev/null +++ b/reference/nnf_cross_entropy.html @@ -0,0 +1,237 @@ + + + + + + + + +Cross_entropy — nnf_cross_entropy • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This criterion combines log_softmax and nll_loss in a single +function.

    +
    + +
    nnf_cross_entropy(
    +  input,
    +  target,
    +  weight = NULL,
    +  ignore_index = -100,
    +  reduction = c("mean", "sum", "none")
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) \((N, C)\) where C = number of classes or \((N, C, H, W)\) +in case of 2D Loss, or \((N, C, d_1, d_2, ..., d_K)\) where \(K \geq 1\) +in the case of K-dimensional loss.

    target

    (Tensor) \((N)\) where each value is \(0 \leq \mbox{targets}[i] \leq C-1\), +or \((N, d_1, d_2, ..., d_K)\) where \(K \geq 1\) for K-dimensional loss.

    weight

    (Tensor, optional) a manual rescaling weight given to each class. If +given, has to be a Tensor of size C

    ignore_index

    (int, optional) Specifies a target value that is ignored +and does not contribute to the input gradient.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_ctc_loss.html b/reference/nnf_ctc_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..3a5841445d8f31e54a377f3462900e420fe3cfbc --- /dev/null +++ b/reference/nnf_ctc_loss.html @@ -0,0 +1,245 @@ + + + + + + + + +Ctc_loss — nnf_ctc_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The Connectionist Temporal Classification loss.

    +
    + +
    nnf_ctc_loss(
    +  log_probs,
    +  targets,
    +  input_lengths,
    +  target_lengths,
    +  blank = 0,
    +  reduction = c("mean", "sum", "none"),
    +  zero_infinity = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    log_probs

    \((T, N, C)\) where C = number of characters in alphabet including blank, +T = input length, and N = batch size. The logarithmized probabilities of +the outputs (e.g. obtained with nnf_log_softmax).

    targets

    \((N, S)\) or (sum(target_lengths)). Targets cannot be blank. +In the second form, the targets are assumed to be concatenated.

    input_lengths

    \((N)\). Lengths of the inputs (must each be \(\leq T\))

    target_lengths

    \((N)\). Lengths of the targets

    blank

    (int, optional) Blank label. Default \(0\).

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    zero_infinity

    (bool, optional) Whether to zero infinite losses and the +associated gradients. Default: FALSE Infinite losses mainly occur when the +inputs are too short to be aligned to the targets.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_dropout.html b/reference/nnf_dropout.html new file mode 100644 index 0000000000000000000000000000000000000000..478ee9945705b33384bc41996a97b2a0dab78596 --- /dev/null +++ b/reference/nnf_dropout.html @@ -0,0 +1,222 @@ + + + + + + + + +Dropout — nnf_dropout • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    During training, randomly zeroes some of the elements of the input +tensor with probability p using samples from a Bernoulli +distribution.

    +
    + +
    nnf_dropout(input, p = 0.5, training = TRUE, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    p

    probability of an element to be zeroed. Default: 0.5

    training

    apply dropout if is TRUE. Default: TRUE

    inplace

    If set to TRUE, will do this operation in-place. +Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_dropout2d.html b/reference/nnf_dropout2d.html new file mode 100644 index 0000000000000000000000000000000000000000..dd6b94e1b3bdca662d933cb16fd780d78f6344ee --- /dev/null +++ b/reference/nnf_dropout2d.html @@ -0,0 +1,226 @@ + + + + + + + + +Dropout2d — nnf_dropout2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randomly zero out entire channels (a channel is a 2D feature map, +e.g., the \(j\)-th channel of the \(i\)-th sample in the +batched input is a 2D tensor \(input[i, j]\)) of the input tensor). +Each channel will be zeroed out independently on every forward call with +probability p using samples from a Bernoulli distribution.

    +
    + +
    nnf_dropout2d(input, p = 0.5, training = TRUE, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    p

    probability of a channel to be zeroed. Default: 0.5

    training

    apply dropout if is TRUE. Default: TRUE.

    inplace

    If set to TRUE, will do this operation in-place. +Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_dropout3d.html b/reference/nnf_dropout3d.html new file mode 100644 index 0000000000000000000000000000000000000000..cf29d174c2ecb1cb97f820ebc0c13b62afa990dc --- /dev/null +++ b/reference/nnf_dropout3d.html @@ -0,0 +1,226 @@ + + + + + + + + +Dropout3d — nnf_dropout3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randomly zero out entire channels (a channel is a 3D feature map, +e.g., the \(j\)-th channel of the \(i\)-th sample in the +batched input is a 3D tensor \(input[i, j]\)) of the input tensor). +Each channel will be zeroed out independently on every forward call with +probability p using samples from a Bernoulli distribution.

    +
    + +
    nnf_dropout3d(input, p = 0.5, training = TRUE, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    p

    probability of a channel to be zeroed. Default: 0.5

    training

    apply dropout if is TRUE. Default: TRUE.

    inplace

    If set to TRUE, will do this operation in-place. +Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_elu.html b/reference/nnf_elu.html new file mode 100644 index 0000000000000000000000000000000000000000..8f2c3d330ccb056e5116eb6b4f489680ce2010b3 --- /dev/null +++ b/reference/nnf_elu.html @@ -0,0 +1,226 @@ + + + + + + + + +Elu — nnf_elu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise, +$$ELU(x) = max(0,x) + min(0, \alpha * (exp(x) - 1))$$.

    +
    + +
    nnf_elu(input, alpha = 1, inplace = FALSE)
    +
    +nnf_elu_(input, alpha = 1)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    alpha

    the alpha value for the ELU formulation. Default: 1.0

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +

    Examples

    +
    if (torch_is_installed()) { +x <- torch_randn(2, 2) +y <- nnf_elu(x, alpha = 1) +nnf_elu_(x, alpha = 1) +torch_equal(x, y) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_embedding.html b/reference/nnf_embedding.html new file mode 100644 index 0000000000000000000000000000000000000000..cb2f181723222348374f992c667631ee0c198077 --- /dev/null +++ b/reference/nnf_embedding.html @@ -0,0 +1,250 @@ + + + + + + + + +Embedding — nnf_embedding • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A simple lookup table that looks up embeddings in a fixed dictionary and size.

    +
    + +
    nnf_embedding(
    +  input,
    +  weight,
    +  padding_idx = NULL,
    +  max_norm = NULL,
    +  norm_type = 2,
    +  scale_grad_by_freq = FALSE,
    +  sparse = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (LongTensor) Tensor containing indices into the embedding matrix

    weight

    (Tensor) The embedding matrix with number of rows equal to the +maximum possible index + 1, and number of columns equal to the embedding size

    padding_idx

    (int, optional) If given, pads the output with the embedding +vector at padding_idx (initialized to zeros) whenever it encounters the index.

    max_norm

    (float, optional) If given, each embedding vector with norm larger +than max_norm is renormalized to have norm max_norm. Note: this will modify +weight in-place.

    norm_type

    (float, optional) The p of the p-norm to compute for the max_norm +option. Default 2.

    scale_grad_by_freq

    (boolean, optional) If given, this will scale gradients +by the inverse of frequency of the words in the mini-batch. Default FALSE.

    sparse

    (bool, optional) If TRUE, gradient w.r.t. weight will be a +sparse tensor. See Notes under nn_embedding for more details regarding +sparse gradients.

    + +

    Details

    + +

    This module is often used to retrieve word embeddings using indices. +The input to the module is a list of indices, and the embedding matrix, +and the output is the corresponding word embeddings.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_embedding_bag.html b/reference/nnf_embedding_bag.html new file mode 100644 index 0000000000000000000000000000000000000000..2ad8e227c982ee366549b8efed6c2e48f315541e --- /dev/null +++ b/reference/nnf_embedding_bag.html @@ -0,0 +1,267 @@ + + + + + + + + +Embedding_bag — nnf_embedding_bag • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Computes sums, means or maxes of bags of embeddings, without instantiating the +intermediate embeddings.

    +
    + +
    nnf_embedding_bag(
    +  input,
    +  weight,
    +  offsets = NULL,
    +  max_norm = NULL,
    +  norm_type = 2,
    +  scale_grad_by_freq = FALSE,
    +  mode = "mean",
    +  sparse = FALSE,
    +  per_sample_weights = NULL,
    +  include_last_offset = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (LongTensor) Tensor containing bags of indices into the embedding matrix

    weight

    (Tensor) The embedding matrix with number of rows equal to the +maximum possible index + 1, and number of columns equal to the embedding size

    offsets

    (LongTensor, optional) Only used when input is 1D. offsets +determines the starting index position of each bag (sequence) in input.

    max_norm

    (float, optional) If given, each embedding vector with norm +larger than max_norm is renormalized to have norm max_norm. +Note: this will modify weight in-place.

    norm_type

    (float, optional) The p in the p-norm to compute for the +max_norm option. Default 2.

    scale_grad_by_freq

    (boolean, optional) if given, this will scale gradients +by the inverse of frequency of the words in the mini-batch. Default FALSE. Note: this option is not supported when mode="max".

    mode

    (string, optional) "sum", "mean" or "max". Specifies +the way to reduce the bag. Default: 'mean'

    sparse

    (bool, optional) if TRUE, gradient w.r.t. weight will be a +sparse tensor. See Notes under nn_embedding for more details regarding +sparse gradients. Note: this option is not supported when mode="max".

    per_sample_weights

    (Tensor, optional) a tensor of float / double weights, +or NULL to indicate all weights should be taken to be 1. If specified, +per_sample_weights must have exactly the same shape as input and is treated +as having the same offsets, if those are not NULL.

    include_last_offset

    (bool, optional) if TRUE, the size of offsets is +equal to the number of bags + 1.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_fold.html b/reference/nnf_fold.html new file mode 100644 index 0000000000000000000000000000000000000000..519a0bde81f55e1ceb5db54355d3ce00675935dc --- /dev/null +++ b/reference/nnf_fold.html @@ -0,0 +1,245 @@ + + + + + + + + +Fold — nnf_fold • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Combines an array of sliding local blocks into a large containing +tensor.

    +
    + +
    nnf_fold(
    +  input,
    +  output_size,
    +  kernel_size,
    +  dilation = 1,
    +  padding = 0,
    +  stride = 1
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    output_size

    the shape of the spatial dimensions of the output (i.e., +output$sizes()[-c(1,2)])

    kernel_size

    the size of the sliding blocks

    dilation

    a parameter that controls the stride of elements within the +neighborhood. Default: 1

    padding

    implicit zero padding to be added on both sides of input. +Default: 0

    stride

    the stride of the sliding blocks in the input spatial dimensions. +Default: 1

    + +

    Warning

    + + + + +

    Currently, only 4-D output tensors (batched image-like tensors) are +supported.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_fractional_max_pool2d.html b/reference/nnf_fractional_max_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..2a190027b009fbaa4de63d4903f067df2ebb9b4e --- /dev/null +++ b/reference/nnf_fractional_max_pool2d.html @@ -0,0 +1,242 @@ + + + + + + + + +Fractional_max_pool2d — nnf_fractional_max_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies 2D fractional max pooling over an input signal composed of several input planes.

    +
    + +
    nnf_fractional_max_pool2d(
    +  input,
    +  kernel_size,
    +  output_size = NULL,
    +  output_ratio = NULL,
    +  return_indices = FALSE,
    +  random_samples = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    kernel_size

    the size of the window to take a max over. Can be a +single number \(k\) (for a square kernel of \(k * k\)) or +a tuple (kH, kW)

    output_size

    the target output size of the image of the form \(oH * oW\). +Can be a tuple (oH, oW) or a single number \(oH\) for a square image \(oH * oH\)

    output_ratio

    If one wants to have an output size as a ratio of the input size, +this option can be given. This has to be a number or tuple in the range (0, 1)

    return_indices

    if True, will return the indices along with the outputs.

    random_samples

    optional random samples.

    + +

    Details

    + +

    Fractional MaxPooling is described in detail in the paper Fractional MaxPooling_ by Ben Graham

    +

    The max-pooling operation is applied in \(kH * kW\) regions by a stochastic +step size determined by the target output size. +The number of output features is equal to the number of input planes.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_fractional_max_pool3d.html b/reference/nnf_fractional_max_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..a51015c4d806d35a85830f1f22ff02055fc60833 --- /dev/null +++ b/reference/nnf_fractional_max_pool3d.html @@ -0,0 +1,243 @@ + + + + + + + + +Fractional_max_pool3d — nnf_fractional_max_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies 3D fractional max pooling over an input signal composed of several input planes.

    +
    + +
    nnf_fractional_max_pool3d(
    +  input,
    +  kernel_size,
    +  output_size = NULL,
    +  output_ratio = NULL,
    +  return_indices = FALSE,
    +  random_samples = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    kernel_size

    the size of the window to take a max over. Can be a single number \(k\) +(for a square kernel of \(k * k * k\)) or a tuple (kT, kH, kW)

    output_size

    the target output size of the form \(oT * oH * oW\). +Can be a tuple (oT, oH, oW) or a single number \(oH\) for a cubic output +\(oH * oH * oH\)

    output_ratio

    If one wants to have an output size as a ratio of the +input size, this option can be given. This has to be a number or tuple in the +range (0, 1)

    return_indices

    if True, will return the indices along with the outputs.

    random_samples

    undocumented argument.

    + +

    Details

    + +

    Fractional MaxPooling is described in detail in the paper Fractional MaxPooling_ by Ben Graham

    +

    The max-pooling operation is applied in \(kT * kH * kW\) regions by a stochastic +step size determined by the target output size. +The number of output features is equal to the number of input planes.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_gelu.html b/reference/nnf_gelu.html new file mode 100644 index 0000000000000000000000000000000000000000..68c453cb2e3533113044affd0684df5c18bd216e --- /dev/null +++ b/reference/nnf_gelu.html @@ -0,0 +1,216 @@ + + + + + + + + +Gelu — nnf_gelu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Gelu

    +
    + +
    nnf_gelu(input)
    + +

    Arguments

    + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    + +

    gelu(input) -> Tensor

    + + + + +

    Applies element-wise the function +\(GELU(x) = x * \Phi(x)\)

    +

    where \(\Phi(x)\) is the Cumulative Distribution Function for +Gaussian Distribution.

    +

    See Gaussian Error Linear Units (GELUs).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_glu.html b/reference/nnf_glu.html new file mode 100644 index 0000000000000000000000000000000000000000..bdbc1c701f15cb87e0d178f37895f09da8ca1951 --- /dev/null +++ b/reference/nnf_glu.html @@ -0,0 +1,216 @@ + + + + + + + + +Glu — nnf_glu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The gated linear unit. Computes:

    +
    + +
    nnf_glu(input, dim = -1)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) input tensor

    dim

    (int) dimension on which to split the input. Default: -1

    + +

    Details

    + +

    $$GLU(a, b) = a \otimes \sigma(b)$$

    +

    where input is split in half along dim to form a and b, \(\sigma\) +is the sigmoid function and \(\otimes\) is the element-wise product +between matrices.

    +

    See Language Modeling with Gated Convolutional Networks.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_grid_sample.html b/reference/nnf_grid_sample.html new file mode 100644 index 0000000000000000000000000000000000000000..3f84505ce1526abd5dcefcbb7c5a8ce8a6178589 --- /dev/null +++ b/reference/nnf_grid_sample.html @@ -0,0 +1,277 @@ + + + + + + + + +Grid_sample — nnf_grid_sample • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Given an input and a flow-field grid, computes the +output using input values and pixel locations from grid.

    +
    + +
    nnf_grid_sample(
    +  input,
    +  grid,
    +  mode = c("bilinear", "nearest"),
    +  padding_mode = c("zeros", "border", "reflection"),
    +  align_corners = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) input of shape \((N, C, H_{\mbox{in}}, W_{\mbox{in}})\) (4-D case) or \((N, C, D_{\mbox{in}}, H_{\mbox{in}}, W_{\mbox{in}})\) (5-D case)

    grid

    (Tensor) flow-field of shape \((N, H_{\mbox{out}}, W_{\mbox{out}}, 2)\) (4-D case) or \((N, D_{\mbox{out}}, H_{\mbox{out}}, W_{\mbox{out}}, 3)\) (5-D case)

    mode

    (str) interpolation mode to calculate output values 'bilinear' | 'nearest'. +Default: 'bilinear'

    padding_mode

    (str) padding mode for outside grid values 'zeros' | 'border' +| 'reflection'. Default: 'zeros'

    align_corners

    (bool, optional) Geometrically, we consider the pixels of the +input as squares rather than points. If set to True, the extrema (-1 and +1) are considered as referring to the center points of the input's corner pixels. +If set to False, they are instead considered as referring to the corner +points of the input's corner pixels, making the sampling more resolution +agnostic. This option parallels the align_corners option in nnf_interpolate(), and +so whichever option is used here should also be used there to resize the input +image before grid sampling. Default: False

    + +

    Details

    + +

    Currently, only spatial (4-D) and volumetric (5-D) input are +supported.

    +

    In the spatial (4-D) case, for input with shape +\((N, C, H_{\mbox{in}}, W_{\mbox{in}})\) and grid with shape +\((N, H_{\mbox{out}}, W_{\mbox{out}}, 2)\), the output will have shape +\((N, C, H_{\mbox{out}}, W_{\mbox{out}})\).

    +

    For each output location output[n, :, h, w], the size-2 vector +grid[n, h, w] specifies input pixel locations x and y, +which are used to interpolate the output value output[n, :, h, w]. +In the case of 5D inputs, grid[n, d, h, w] specifies the +x, y, z pixel locations for interpolating +output[n, :, d, h, w]. mode argument specifies nearest or +bilinear interpolation method to sample the input pixels.

    +

    grid specifies the sampling pixel locations normalized by the +input spatial dimensions. Therefore, it should have most values in +the range of [-1, 1]. For example, values x = -1, y = -1 is the +left-top pixel of input, and values x = 1, y = 1 is the +right-bottom pixel of input.

    +

    If grid has values outside the range of [-1, 1], the corresponding +outputs are handled as defined by padding_mode. Options are

      +
    • padding_mode="zeros": use 0 for out-of-bound grid locations,

    • +
    • padding_mode="border": use border values for out-of-bound grid locations,

    • +
    • padding_mode="reflection": use values at locations reflected by +the border for out-of-bound grid locations. For location far away +from the border, it will keep being reflected until becoming in bound, +e.g., (normalized) pixel location x = -3.5 reflects by border -1 +and becomes x' = 1.5, then reflects by border 1 and becomes +x'' = -0.5.

    • +
    + +

    Note

    + + + + +

    This function is often used in conjunction with nnf_affine_grid() +to build Spatial Transformer Networks_ .

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_group_norm.html b/reference/nnf_group_norm.html new file mode 100644 index 0000000000000000000000000000000000000000..cf24e14683a9d7237c8302f6d446a5f85fc864e1 --- /dev/null +++ b/reference/nnf_group_norm.html @@ -0,0 +1,221 @@ + + + + + + + + +Group_norm — nnf_group_norm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies Group Normalization for last certain number of dimensions.

    +
    + +
    nnf_group_norm(input, num_groups, weight = NULL, bias = NULL, eps = 1e-05)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    num_groups

    number of groups to separate the channels into

    weight

    the weight tensor

    bias

    the bias tensor

    eps

    a value added to the denominator for numerical stability. Default: 1e-5

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_gumbel_softmax.html b/reference/nnf_gumbel_softmax.html new file mode 100644 index 0000000000000000000000000000000000000000..cf6d5ca66bc007bdbc605ded19854193087c9378 --- /dev/null +++ b/reference/nnf_gumbel_softmax.html @@ -0,0 +1,219 @@ + + + + + + + + +Gumbel_softmax — nnf_gumbel_softmax • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Samples from the Gumbel-Softmax distribution and +optionally discretizes.

    +
    + +
    nnf_gumbel_softmax(logits, tau = 1, hard = FALSE, dim = -1)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    logits

    [..., num_features] unnormalized log probabilities

    tau

    non-negative scalar temperature

    hard

    if True, the returned samples will be discretized as one-hot vectors, but will be differentiated as if it is the soft sample in autograd

    dim

    (int) A dimension along which softmax will be computed. Default: -1.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_hardshrink.html b/reference/nnf_hardshrink.html new file mode 100644 index 0000000000000000000000000000000000000000..f066154a29d29000ee02c8e10bf1fcc1af2c5beb --- /dev/null +++ b/reference/nnf_hardshrink.html @@ -0,0 +1,210 @@ + + + + + + + + +Hardshrink — nnf_hardshrink • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the hard shrinkage function element-wise

    +
    + +
    nnf_hardshrink(input, lambd = 0.5)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    lambd

    the lambda value for the Hardshrink formulation. Default: 0.5

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_hardsigmoid.html b/reference/nnf_hardsigmoid.html new file mode 100644 index 0000000000000000000000000000000000000000..0be7ab4d59c2621bb5cc5ebea768afddb753e41e --- /dev/null +++ b/reference/nnf_hardsigmoid.html @@ -0,0 +1,210 @@ + + + + + + + + +Hardsigmoid — nnf_hardsigmoid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function \(\mbox{Hardsigmoid}(x) = \frac{ReLU6(x + 3)}{6}\)

    +
    + +
    nnf_hardsigmoid(input, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    inplace

    NA If set to True, will do this operation in-place. Default: False

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_hardswish.html b/reference/nnf_hardswish.html new file mode 100644 index 0000000000000000000000000000000000000000..6118f0f718c3b7feee18b5c53bc7ac25e959453a --- /dev/null +++ b/reference/nnf_hardswish.html @@ -0,0 +1,221 @@ + + + + + + + + +Hardswish — nnf_hardswish • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the hardswish function, element-wise, as described in the paper: +Searching for MobileNetV3.

    +
    + +
    nnf_hardswish(input, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    inplace

    can optionally do the operation in-place. Default: FALSE

    + +

    Details

    + +

    $$ \mbox{Hardswish}(x) = \left\{ + \begin{array}{ll} + 0 & \mbox{if } x \le -3, \\ + x & \mbox{if } x \ge +3, \\ + x \cdot (x + 3)/6 & \mbox{otherwise} + \end{array} + \right. $$

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_hardtanh.html b/reference/nnf_hardtanh.html new file mode 100644 index 0000000000000000000000000000000000000000..741f063002040181aa9bc8b39325dc4a2541780e --- /dev/null +++ b/reference/nnf_hardtanh.html @@ -0,0 +1,220 @@ + + + + + + + + +Hardtanh — nnf_hardtanh • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the HardTanh function element-wise.

    +
    + +
    nnf_hardtanh(input, min_val = -1, max_val = 1, inplace = FALSE)
    +
    +nnf_hardtanh_(input, min_val = -1, max_val = 1)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    min_val

    minimum value of the linear region range. Default: -1

    max_val

    maximum value of the linear region range. Default: 1

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_hinge_embedding_loss.html b/reference/nnf_hinge_embedding_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..4a6ecccb8672298b624d2ef6678833c448e3d028 --- /dev/null +++ b/reference/nnf_hinge_embedding_loss.html @@ -0,0 +1,226 @@ + + + + + + + + +Hinge_embedding_loss — nnf_hinge_embedding_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Measures the loss given an input tensor xx and a labels tensor yy (containing 1 or -1). +This is usually used for measuring whether two inputs are similar or dissimilar, e.g. +using the L1 pairwise distance as xx , and is typically used for learning nonlinear +embeddings or semi-supervised learning.

    +
    + +
    nnf_hinge_embedding_loss(input, target, margin = 1, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    margin

    Has a default value of 1.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_instance_norm.html b/reference/nnf_instance_norm.html new file mode 100644 index 0000000000000000000000000000000000000000..7ca559c7096499cc29f3669c351b73e78b0bbb60 --- /dev/null +++ b/reference/nnf_instance_norm.html @@ -0,0 +1,244 @@ + + + + + + + + +Instance_norm — nnf_instance_norm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies Instance Normalization for each channel in each data sample in a +batch.

    +
    + +
    nnf_instance_norm(
    +  input,
    +  running_mean = NULL,
    +  running_var = NULL,
    +  weight = NULL,
    +  bias = NULL,
    +  use_input_stats = TRUE,
    +  momentum = 0.1,
    +  eps = 1e-05
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    running_mean

    the running_mean tensor

    running_var

    the running var tensor

    weight

    the weight tensor

    bias

    the bias tensor

    use_input_stats

    whether to use input stats

    momentum

    a double for the momentum

    eps

    an eps double for numerical stability

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_interpolate.html b/reference/nnf_interpolate.html new file mode 100644 index 0000000000000000000000000000000000000000..72de1004483797bde56467b2734e9cd11eee054f --- /dev/null +++ b/reference/nnf_interpolate.html @@ -0,0 +1,263 @@ + + + + + + + + +Interpolate — nnf_interpolate • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Down/up samples the input to either the given size or the given +scale_factor

    +
    + +
    nnf_interpolate(
    +  input,
    +  size = NULL,
    +  scale_factor = NULL,
    +  mode = "nearest",
    +  align_corners = FALSE,
    +  recompute_scale_factor = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor

    size

    (int or Tuple[int] or Tuple[int, int] or Tuple[int, int, int]) +output spatial size.

    scale_factor

    (float or Tuple[float]) multiplier for spatial size. +Has to match input size if it is a tuple.

    mode

    (str) algorithm used for upsampling: 'nearest' | 'linear' | 'bilinear' +| 'bicubic' | 'trilinear' | 'area' Default: 'nearest'

    align_corners

    (bool, optional) Geometrically, we consider the pixels +of the input and output as squares rather than points. If set to TRUE, +the input and output tensors are aligned by the center points of their corner +pixels, preserving the values at the corner pixels. If set to False, the +input and output tensors are aligned by the corner points of their corner pixels, +and the interpolation uses edge value padding for out-of-boundary values, +making this operation independent of input size when scale_factor is kept +the same. This only has an effect when mode is 'linear', 'bilinear', +'bicubic' or 'trilinear'. Default: False

    recompute_scale_factor

    (bool, optional) recompute the scale_factor +for use in the interpolation calculation. When scale_factor is passed +as a parameter, it is used to compute the output_size. If recompute_scale_factor +is ```True`` or not specified, a new scale_factor will be computed based on +the output and input sizes for use in the interpolation computation (i.e. the +computation will be identical to if the computed `output_size` were passed-in +explicitly). Otherwise, the passed-in `scale_factor` will be used in the +interpolation computation. Note that when `scale_factor` is floating-point, +the recomputed scale_factor may differ from the one passed in due to rounding +and precision issues.

    + +

    Details

    + +

    The algorithm used for interpolation is determined by mode.

    +

    Currently temporal, spatial and volumetric sampling are supported, i.e. +expected inputs are 3-D, 4-D or 5-D in shape.

    +

    The input dimensions are interpreted in the form: +mini-batch x channels x [optional depth] x [optional height] x width.

    +

    The modes available for resizing are: nearest, linear (3D-only), +bilinear, bicubic (4D-only), trilinear (5D-only), area

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_kl_div.html b/reference/nnf_kl_div.html new file mode 100644 index 0000000000000000000000000000000000000000..dd63dad8317e10bd7c75be744a07bb226dced4ed --- /dev/null +++ b/reference/nnf_kl_div.html @@ -0,0 +1,216 @@ + + + + + + + + +Kl_div — nnf_kl_div • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The Kullback-Leibler divergence Loss.

    +
    + +
    nnf_kl_div(input, target, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_l1_loss.html b/reference/nnf_l1_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..a763b48f96778b5d302caaad57d626befd9aec08 --- /dev/null +++ b/reference/nnf_l1_loss.html @@ -0,0 +1,216 @@ + + + + + + + + +L1_loss — nnf_l1_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Function that takes the mean element-wise absolute value difference.

    +
    + +
    nnf_l1_loss(input, target, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_layer_norm.html b/reference/nnf_layer_norm.html new file mode 100644 index 0000000000000000000000000000000000000000..6ac0f6b00f410923d8bfa63f9fb60224cbd53697 --- /dev/null +++ b/reference/nnf_layer_norm.html @@ -0,0 +1,229 @@ + + + + + + + + +Layer_norm — nnf_layer_norm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies Layer Normalization for last certain number of dimensions.

    +
    + +
    nnf_layer_norm(
    +  input,
    +  normalized_shape,
    +  weight = NULL,
    +  bias = NULL,
    +  eps = 1e-05
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    normalized_shape

    input shape from an expected input of size. If a single +integer is used, it is treated as a singleton list, and this module will normalize +over the last dimension which is expected to be of that specific size.

    weight

    the weight tensor

    bias

    the bias tensor

    eps

    a value added to the denominator for numerical stability. Default: 1e-5

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_leaky_relu.html b/reference/nnf_leaky_relu.html new file mode 100644 index 0000000000000000000000000000000000000000..722e084e0cda23d42ef4d7d8a1507703d891f8e2 --- /dev/null +++ b/reference/nnf_leaky_relu.html @@ -0,0 +1,216 @@ + + + + + + + + +Leaky_relu — nnf_leaky_relu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise, +\(LeakyReLU(x) = max(0, x) + negative_slope * min(0, x)\)

    +
    + +
    nnf_leaky_relu(input, negative_slope = 0.01, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    negative_slope

    Controls the angle of the negative slope. Default: 1e-2

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_linear.html b/reference/nnf_linear.html new file mode 100644 index 0000000000000000000000000000000000000000..f194255af5ba1d008b2197e4bccb8b343a398d91 --- /dev/null +++ b/reference/nnf_linear.html @@ -0,0 +1,214 @@ + + + + + + + + +Linear — nnf_linear • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a linear transformation to the incoming data: \(y = xA^T + b\).

    +
    + +
    nnf_linear(input, weight, bias = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    \((N, *, in\_features)\) where * means any number of +additional dimensions

    weight

    \((out\_features, in\_features)\) the weights tensor.

    bias

    optional tensor \((out\_features)\)

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_local_response_norm.html b/reference/nnf_local_response_norm.html new file mode 100644 index 0000000000000000000000000000000000000000..38e79b59b6e81b5860ecca781d0ccc74f97d0f06 --- /dev/null +++ b/reference/nnf_local_response_norm.html @@ -0,0 +1,225 @@ + + + + + + + + +Local_response_norm — nnf_local_response_norm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies local response normalization over an input signal composed of +several input planes, where channels occupy the second dimension. +Applies normalization across channels.

    +
    + +
    nnf_local_response_norm(input, size, alpha = 1e-04, beta = 0.75, k = 1)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    size

    amount of neighbouring channels used for normalization

    alpha

    multiplicative factor. Default: 0.0001

    beta

    exponent. Default: 0.75

    k

    additive factor. Default: 1

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_log_softmax.html b/reference/nnf_log_softmax.html new file mode 100644 index 0000000000000000000000000000000000000000..ccb5d702bb0bbe7033745e640871f7cffe22a45b --- /dev/null +++ b/reference/nnf_log_softmax.html @@ -0,0 +1,221 @@ + + + + + + + + +Log_softmax — nnf_log_softmax • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a softmax followed by a logarithm.

    +
    + +
    nnf_log_softmax(input, dim = NULL, dtype = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) input

    dim

    (int) A dimension along which log_softmax will be computed.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. +If specified, the input tensor is casted to dtype before the operation +is performed. This is useful for preventing data type overflows. +Default: NULL.

    + +

    Details

    + +

    While mathematically equivalent to log(softmax(x)), doing these two +operations separately is slower, and numerically unstable. This function +uses an alternative formulation to compute the output and gradient correctly.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_logsigmoid.html b/reference/nnf_logsigmoid.html new file mode 100644 index 0000000000000000000000000000000000000000..c77116105949454edf26e4518e0ca414648e551c --- /dev/null +++ b/reference/nnf_logsigmoid.html @@ -0,0 +1,206 @@ + + + + + + + + +Logsigmoid — nnf_logsigmoid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise \(LogSigmoid(x_i) = log(\frac{1}{1 + exp(-x_i)})\)

    +
    + +
    nnf_logsigmoid(input)
    + +

    Arguments

    + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_lp_pool1d.html b/reference/nnf_lp_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..4dbb42a8bfc78ab5f9fba6a863b840cb938feeb6 --- /dev/null +++ b/reference/nnf_lp_pool1d.html @@ -0,0 +1,226 @@ + + + + + + + + +Lp_pool1d — nnf_lp_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D power-average pooling over an input signal composed of +several input planes. If the sum of all inputs to the power of p is +zero, the gradient is set to zero as well.

    +
    + +
    nnf_lp_pool1d(input, norm_type, kernel_size, stride = NULL, ceil_mode = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    norm_type

    if inf than one gets max pooling if 0 you get sum pooling ( +proportional to the avg pooling)

    kernel_size

    a single int, the size of the window

    stride

    a single int, the stride of the window. Default value is kernel_size

    ceil_mode

    when True, will use ceil instead of floor to compute the output shape

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_lp_pool2d.html b/reference/nnf_lp_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..a873808571e265cdba1dd4e308e402607a9e93d0 --- /dev/null +++ b/reference/nnf_lp_pool2d.html @@ -0,0 +1,226 @@ + + + + + + + + +Lp_pool2d — nnf_lp_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D power-average pooling over an input signal composed of +several input planes. If the sum of all inputs to the power of p is +zero, the gradient is set to zero as well.

    +
    + +
    nnf_lp_pool2d(input, norm_type, kernel_size, stride = NULL, ceil_mode = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    norm_type

    if inf than one gets max pooling if 0 you get sum pooling ( +proportional to the avg pooling)

    kernel_size

    a single int, the size of the window

    stride

    a single int, the stride of the window. Default value is kernel_size

    ceil_mode

    when True, will use ceil instead of floor to compute the output shape

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_margin_ranking_loss.html b/reference/nnf_margin_ranking_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..a4ed76e0b6b6f7707e6523b7833605951ccd1051 --- /dev/null +++ b/reference/nnf_margin_ranking_loss.html @@ -0,0 +1,226 @@ + + + + + + + + +Margin_ranking_loss — nnf_margin_ranking_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that measures the loss given inputs x1 , x2 , two 1D +mini-batch Tensors, and a label 1D mini-batch tensor y (containing 1 or -1).

    +
    + +
    nnf_margin_ranking_loss(input1, input2, target, margin = 0, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input1

    the first tensor

    input2

    the second input tensor

    target

    the target tensor

    margin

    Has a default value of 00 .

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_max_pool1d.html b/reference/nnf_max_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..81517ba04ebc15232f56373108b66abdd6263932 --- /dev/null +++ b/reference/nnf_max_pool1d.html @@ -0,0 +1,244 @@ + + + + + + + + +Max_pool1d — nnf_max_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 1D max pooling over an input signal composed of several input +planes.

    +
    + +
    nnf_max_pool1d(
    +  input,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  dilation = 1,
    +  ceil_mode = FALSE,
    +  return_indices = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of shape (minibatch , in_channels , iW)

    kernel_size

    the size of the window. Can be a single number or a +tuple (kW,).

    stride

    the stride of the window. Can be a single number or a tuple +(sW,). Default: kernel_size

    padding

    implicit zero paddings on both sides of the input. Can be a +single number or a tuple (padW,). Default: 0

    dilation

    controls the spacing between the kernel points; also known as +the à trous algorithm.

    ceil_mode

    when True, will use ceil instead of floor to compute the +output shape. Default: FALSE

    return_indices

    whether to return the indices where the max occurs.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_max_pool2d.html b/reference/nnf_max_pool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..da91197ffa008d78c418b7f591916c9f94624e64 --- /dev/null +++ b/reference/nnf_max_pool2d.html @@ -0,0 +1,244 @@ + + + + + + + + +Max_pool2d — nnf_max_pool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 2D max pooling over an input signal composed of several input +planes.

    +
    + +
    nnf_max_pool2d(
    +  input,
    +  kernel_size,
    +  stride = kernel_size,
    +  padding = 0,
    +  dilation = 1,
    +  ceil_mode = FALSE,
    +  return_indices = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iH , iW)

    kernel_size

    size of the pooling region. Can be a single number or a +tuple (kH, kW)

    stride

    stride of the pooling operation. Can be a single number or a +tuple (sH, sW). Default: kernel_size

    padding

    implicit zero paddings on both sides of the input. Can be a +single number or a tuple (padH, padW). Default: 0

    dilation

    controls the spacing between the kernel points; also known as +the à trous algorithm.

    ceil_mode

    when True, will use ceil instead of floor in the formula +to compute the output shape. Default: FALSE

    return_indices

    whether to return the indices where the max occurs.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_max_pool3d.html b/reference/nnf_max_pool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..991841230339f6af0df8be172e79dbf9daa6a87a --- /dev/null +++ b/reference/nnf_max_pool3d.html @@ -0,0 +1,244 @@ + + + + + + + + +Max_pool3d — nnf_max_pool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a 3D max pooling over an input signal composed of several input +planes.

    +
    + +
    nnf_max_pool3d(
    +  input,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  dilation = 1,
    +  ceil_mode = FALSE,
    +  return_indices = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor (minibatch, in_channels , iT * iH , iW)

    kernel_size

    size of the pooling region. Can be a single number or a +tuple (kT, kH, kW)

    stride

    stride of the pooling operation. Can be a single number or a +tuple (sT, sH, sW). Default: kernel_size

    padding

    implicit zero paddings on both sides of the input. Can be a +single number or a tuple (padT, padH, padW), Default: 0

    dilation

    controls the spacing between the kernel points; also known as +the à trous algorithm.

    ceil_mode

    when True, will use ceil instead of floor in the formula +to compute the output shape

    return_indices

    whether to return the indices where the max occurs.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_max_unpool1d.html b/reference/nnf_max_unpool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..05d6978cb5d8b63403ad3cbe61805aef29c4478c --- /dev/null +++ b/reference/nnf_max_unpool1d.html @@ -0,0 +1,232 @@ + + + + + + + + +Max_unpool1d — nnf_max_unpool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Computes a partial inverse of MaxPool1d.

    +
    + +
    nnf_max_unpool1d(
    +  input,
    +  indices,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  output_size = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input Tensor to invert

    indices

    the indices given out by max pool

    kernel_size

    Size of the max pooling window.

    stride

    Stride of the max pooling window. It is set to kernel_size by default.

    padding

    Padding that was added to the input

    output_size

    the targeted output size

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_max_unpool2d.html b/reference/nnf_max_unpool2d.html new file mode 100644 index 0000000000000000000000000000000000000000..4a1eef797f59a502539f1fe41cad0aeaafdb2625 --- /dev/null +++ b/reference/nnf_max_unpool2d.html @@ -0,0 +1,232 @@ + + + + + + + + +Max_unpool2d — nnf_max_unpool2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Computes a partial inverse of MaxPool2d.

    +
    + +
    nnf_max_unpool2d(
    +  input,
    +  indices,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  output_size = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input Tensor to invert

    indices

    the indices given out by max pool

    kernel_size

    Size of the max pooling window.

    stride

    Stride of the max pooling window. It is set to kernel_size by default.

    padding

    Padding that was added to the input

    output_size

    the targeted output size

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_max_unpool3d.html b/reference/nnf_max_unpool3d.html new file mode 100644 index 0000000000000000000000000000000000000000..574e83fb9f516b09332ff09048dca59027a5e325 --- /dev/null +++ b/reference/nnf_max_unpool3d.html @@ -0,0 +1,232 @@ + + + + + + + + +Max_unpool3d — nnf_max_unpool3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Computes a partial inverse of MaxPool3d.

    +
    + +
    nnf_max_unpool3d(
    +  input,
    +  indices,
    +  kernel_size,
    +  stride = NULL,
    +  padding = 0,
    +  output_size = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input Tensor to invert

    indices

    the indices given out by max pool

    kernel_size

    Size of the max pooling window.

    stride

    Stride of the max pooling window. It is set to kernel_size by default.

    padding

    Padding that was added to the input

    output_size

    the targeted output size

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_mse_loss.html b/reference/nnf_mse_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..9c4e7e04c16b199205ac6f2b194a18870a6322e7 --- /dev/null +++ b/reference/nnf_mse_loss.html @@ -0,0 +1,216 @@ + + + + + + + + +Mse_loss — nnf_mse_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Measures the element-wise mean squared error.

    +
    + +
    nnf_mse_loss(input, target, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_multi_head_attention_forward.html b/reference/nnf_multi_head_attention_forward.html new file mode 100644 index 0000000000000000000000000000000000000000..ded4958bce67c5592dae8dbea828234f4bde83a5 --- /dev/null +++ b/reference/nnf_multi_head_attention_forward.html @@ -0,0 +1,334 @@ + + + + + + + + +Multi head attention forward — nnf_multi_head_attention_forward • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Allows the model to jointly attend to information from different representation +subspaces. See reference: Attention Is All You Need

    +
    + +
    nnf_multi_head_attention_forward(
    +  query,
    +  key,
    +  value,
    +  embed_dim_to_check,
    +  num_heads,
    +  in_proj_weight,
    +  in_proj_bias,
    +  bias_k,
    +  bias_v,
    +  add_zero_attn,
    +  dropout_p,
    +  out_proj_weight,
    +  out_proj_bias,
    +  training = TRUE,
    +  key_padding_mask = NULL,
    +  need_weights = TRUE,
    +  attn_mask = NULL,
    +  use_separate_proj_weight = FALSE,
    +  q_proj_weight = NULL,
    +  k_proj_weight = NULL,
    +  v_proj_weight = NULL,
    +  static_k = NULL,
    +  static_v = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    query

    \((L, N, E)\) where L is the target sequence length, N is the batch size, E is +the embedding dimension.

    key

    \((S, N, E)\), where S is the source sequence length, N is the batch size, E is +the embedding dimension.

    value

    \((S, N, E)\) where S is the source sequence length, N is the batch size, E is +the embedding dimension.

    embed_dim_to_check

    total dimension of the model.

    num_heads

    parallel attention heads.

    in_proj_weight

    input projection weight and bias.

    in_proj_bias

    currently undocumented.

    bias_k

    bias of the key and value sequences to be added at dim=0.

    bias_v

    currently undocumented.

    add_zero_attn

    add a new batch of zeros to the key and +value sequences at dim=1.

    dropout_p

    probability of an element to be zeroed.

    out_proj_weight

    the output projection weight and bias.

    out_proj_bias

    currently undocumented.

    training

    apply dropout if is TRUE.

    key_padding_mask

    \((N, S)\) where N is the batch size, S is the source sequence length. +If a ByteTensor is provided, the non-zero positions will be ignored while the position +with the zero positions will be unchanged. If a BoolTensor is provided, the positions with the +value of True will be ignored while the position with the value of False will be unchanged.

    need_weights

    output attn_output_weights.

    attn_mask

    2D mask \((L, S)\) where L is the target sequence length, S is the source sequence length. +3D mask \((N*num_heads, L, S)\) where N is the batch size, L is the target sequence length, +S is the source sequence length. attn_mask ensure that position i is allowed to attend the unmasked +positions. If a ByteTensor is provided, the non-zero positions are not allowed to attend +while the zero positions will be unchanged. If a BoolTensor is provided, positions with True +is not allowed to attend while False values will be unchanged. If a FloatTensor +is provided, it will be added to the attention weight.

    use_separate_proj_weight

    the function accept the proj. weights for +query, key, and value in different forms. If false, in_proj_weight will be used, +which is a combination of q_proj_weight, k_proj_weight, v_proj_weight.

    q_proj_weight

    input projection weight and bias.

    k_proj_weight

    currently undocumented.

    v_proj_weight

    currently undocumented.

    static_k

    static key and value used for attention operators.

    static_v

    currently undocumented.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_multi_margin_loss.html b/reference/nnf_multi_margin_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..7c3438050a20991c543f27fc1b9c1ec2f680860e --- /dev/null +++ b/reference/nnf_multi_margin_loss.html @@ -0,0 +1,240 @@ + + + + + + + + +Multi_margin_loss — nnf_multi_margin_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that optimizes a multi-class classification hinge loss +(margin-based loss) between input x (a 2D mini-batch Tensor) and output y +(which is a 1D tensor of target class indices, 0 <= y <= x$size(2) - 1 ).

    +
    + +
    nnf_multi_margin_loss(
    +  input,
    +  target,
    +  p = 1,
    +  margin = 1,
    +  weight = NULL,
    +  reduction = "mean"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    p

    Has a default value of 1. 1 and 2 are the only supported values.

    margin

    Has a default value of 1.

    weight

    a manual rescaling weight given to each class. If given, it has to +be a Tensor of size C. Otherwise, it is treated as if having all ones.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_multilabel_margin_loss.html b/reference/nnf_multilabel_margin_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..b90ae41ad1674f924938c349eae5c8b1a6075002 --- /dev/null +++ b/reference/nnf_multilabel_margin_loss.html @@ -0,0 +1,220 @@ + + + + + + + + +Multilabel_margin_loss — nnf_multilabel_margin_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that optimizes a multi-class multi-classification hinge loss +(margin-based loss) between input x (a 2D mini-batch Tensor) and output y (which +is a 2D Tensor of target class indices).

    +
    + +
    nnf_multilabel_margin_loss(input, target, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_multilabel_soft_margin_loss.html b/reference/nnf_multilabel_soft_margin_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..fa0555cdac75a1b2753b163341d0d512f6abf8f4 --- /dev/null +++ b/reference/nnf_multilabel_soft_margin_loss.html @@ -0,0 +1,222 @@ + + + + + + + + +Multilabel_soft_margin_loss — nnf_multilabel_soft_margin_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that optimizes a multi-label one-versus-all loss based on +max-entropy, between input x and target y of size (N, C).

    +
    + +
    nnf_multilabel_soft_margin_loss(input, target, weight, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    weight

    weight tensor to apply on the loss.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_nll_loss.html b/reference/nnf_nll_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..ab0cb7f5c124171e7d0febbe7d84736c3f142b0d --- /dev/null +++ b/reference/nnf_nll_loss.html @@ -0,0 +1,235 @@ + + + + + + + + +Nll_loss — nnf_nll_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    The negative log likelihood loss.

    +
    + +
    nnf_nll_loss(
    +  input,
    +  target,
    +  weight = NULL,
    +  ignore_index = -100,
    +  reduction = "mean"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    \((N, C)\) where C = number of classes or \((N, C, H, W)\) in +case of 2D Loss, or \((N, C, d_1, d_2, ..., d_K)\) where \(K \geq 1\) in +the case of K-dimensional loss.

    target

    \((N)\) where each value is \(0 \leq \mbox{targets}[i] \leq C-1\), +or \((N, d_1, d_2, ..., d_K)\) where \(K \geq 1\) for K-dimensional loss.

    weight

    (Tensor, optional) a manual rescaling weight given to each class. +If given, has to be a Tensor of size C

    ignore_index

    (int, optional) Specifies a target value that is ignored and +does not contribute to the input gradient.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_normalize.html b/reference/nnf_normalize.html new file mode 100644 index 0000000000000000000000000000000000000000..e3e1fe475f21ed4d25b9fbc4fc2cdf42c67b7c27 --- /dev/null +++ b/reference/nnf_normalize.html @@ -0,0 +1,230 @@ + + + + + + + + +Normalize — nnf_normalize • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Performs \(L_p\) normalization of inputs over specified dimension.

    +
    + +
    nnf_normalize(input, p = 2, dim = 1, eps = 1e-12, out = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    input tensor of any shape

    p

    (float) the exponent value in the norm formulation. Default: 2

    dim

    (int) the dimension to reduce. Default: 1

    eps

    (float) small value to avoid division by zero. Default: 1e-12

    out

    (Tensor, optional) the output tensor. If out is used, this operation won't be differentiable.

    + +

    Details

    + +

    For a tensor input of sizes \((n_0, ..., n_{dim}, ..., n_k)\), each +\(n_{dim}\) -element vector \(v\) along dimension dim is transformed as

    +

    $$ + v = \frac{v}{\max(\Vert v \Vert_p, \epsilon)}. +$$

    +

    With the default arguments it uses the Euclidean norm over vectors along +dimension \(1\) for normalization.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_one_hot.html b/reference/nnf_one_hot.html new file mode 100644 index 0000000000000000000000000000000000000000..2f8da2382d309005f947758c01e4606b1b97c0fc --- /dev/null +++ b/reference/nnf_one_hot.html @@ -0,0 +1,220 @@ + + + + + + + + +One_hot — nnf_one_hot • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Takes LongTensor with index values of shape (*) and returns a tensor +of shape (*, num_classes) that have zeros everywhere except where the +index of last dimension matches the corresponding value of the input tensor, +in which case it will be 1.

    +
    + +
    nnf_one_hot(tensor, num_classes = -1)
    + +

    Arguments

    + + + + + + + + + + +
    tensor

    (LongTensor) class values of any shape.

    num_classes

    (int) Total number of classes. If set to -1, the number +of classes will be inferred as one greater than the largest class value in +the input tensor.

    + +

    Details

    + +

    One-hot on Wikipedia: https://en.wikipedia.org/wiki/One-hot

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_pad.html b/reference/nnf_pad.html new file mode 100644 index 0000000000000000000000000000000000000000..8b2b419a05ba1aba122e394ae61008c27ec1c880 --- /dev/null +++ b/reference/nnf_pad.html @@ -0,0 +1,248 @@ + + + + + + + + +Pad — nnf_pad • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Pads tensor.

    +
    + +
    nnf_pad(input, pad, mode = "constant", value = 0)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) N-dimensional tensor

    pad

    (tuple) m-elements tuple, where \(\frac{m}{2} \leq\) input dimensions +and \(m\) is even.

    mode

    'constant', 'reflect', 'replicate' or 'circular'. Default: 'constant'

    value

    fill value for 'constant' padding. Default: 0.

    + +

    Padding size

    + + + + +

    The padding size by which to pad some dimensions of input +are described starting from the last dimension and moving forward. +\(\left\lfloor\frac{\mbox{len(pad)}}{2}\right\rfloor\) dimensions +of input will be padded. +For example, to pad only the last dimension of the input tensor, then +pad has the form +\((\mbox{padding\_left}, \mbox{padding\_right})\); +to pad the last 2 dimensions of the input tensor, then use +\((\mbox{padding\_left}, \mbox{padding\_right},\) +\(\mbox{padding\_top}, \mbox{padding\_bottom})\); +to pad the last 3 dimensions, use +\((\mbox{padding\_left}, \mbox{padding\_right},\) +\(\mbox{padding\_top}, \mbox{padding\_bottom}\) +\(\mbox{padding\_front}, \mbox{padding\_back})\).

    +

    Padding mode

    + + + + +

    See nn_constant_pad_2d, nn_reflection_pad_2d, and +nn_replication_pad_2d for concrete examples on how each of the +padding modes works. Constant padding is implemented for arbitrary dimensions. +tensor, or the last 2 dimensions of 4D input tensor, or the last dimension of +3D input tensor. Reflect padding is only implemented for padding the last 2 +dimensions of 4D input tensor, or the last dimension of 3D input tensor.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_pairwise_distance.html b/reference/nnf_pairwise_distance.html new file mode 100644 index 0000000000000000000000000000000000000000..0f98e33094ab07acd12837e8a8c918a8f719aa6a --- /dev/null +++ b/reference/nnf_pairwise_distance.html @@ -0,0 +1,222 @@ + + + + + + + + +Pairwise_distance — nnf_pairwise_distance • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Computes the batchwise pairwise distance between vectors using the p-norm.

    +
    + +
    nnf_pairwise_distance(x1, x2, p = 2, eps = 1e-06, keepdim = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    x1

    (Tensor) First input.

    x2

    (Tensor) Second input (of size matching x1).

    p

    the norm degree. Default: 2

    eps

    (float, optional) Small value to avoid division by zero. +Default: 1e-8

    keepdim

    Determines whether or not to keep the vector dimension. Default: False

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_pdist.html b/reference/nnf_pdist.html new file mode 100644 index 0000000000000000000000000000000000000000..a2f3dcdaab0e420e42d9e955d493e902cf187b5c --- /dev/null +++ b/reference/nnf_pdist.html @@ -0,0 +1,220 @@ + + + + + + + + +Pdist — nnf_pdist • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Computes the p-norm distance between every pair of row vectors in the input. +This is identical to the upper triangular portion, excluding the diagonal, of +torch_norm(input[:, None] - input, dim=2, p=p). This function will be faster +if the rows are contiguous.

    +
    + +
    nnf_pdist(input, p = 2)
    + +

    Arguments

    + + + + + + + + + + +
    input

    input tensor of shape \(N \times M\).

    p

    p value for the p-norm distance to calculate between each vector pair +\(\in [0, \infty]\).

    + +

    Details

    + +

    If input has shape \(N \times M\) then the output will have shape +\(\frac{1}{2} N (N - 1)\).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_pixel_shuffle.html b/reference/nnf_pixel_shuffle.html new file mode 100644 index 0000000000000000000000000000000000000000..a81c24cce0178eb01ac0bfcdcb6cfa493944bd15 --- /dev/null +++ b/reference/nnf_pixel_shuffle.html @@ -0,0 +1,211 @@ + + + + + + + + +Pixel_shuffle — nnf_pixel_shuffle • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Rearranges elements in a tensor of shape \((*, C \times r^2, H, W)\) to a +tensor of shape \((*, C, H \times r, W \times r)\).

    +
    + +
    nnf_pixel_shuffle(input, upscale_factor)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor

    upscale_factor

    (int) factor to increase spatial resolution by

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_poisson_nll_loss.html b/reference/nnf_poisson_nll_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..b1bb0a6fd3c460a2aa956f81dbb7cc326740d880 --- /dev/null +++ b/reference/nnf_poisson_nll_loss.html @@ -0,0 +1,239 @@ + + + + + + + + +Poisson_nll_loss — nnf_poisson_nll_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Poisson negative log likelihood loss.

    +
    + +
    nnf_poisson_nll_loss(
    +  input,
    +  target,
    +  log_input = TRUE,
    +  full = FALSE,
    +  eps = 1e-08,
    +  reduction = "mean"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    log_input

    if TRUE the loss is computed as \(\exp(\mbox{input}) - \mbox{target} * \mbox{input}\), +if FALSE then loss is \(\mbox{input} - \mbox{target} * \log(\mbox{input}+\mbox{eps})\). +Default: TRUE.

    full

    whether to compute full loss, i. e. to add the Stirling approximation +term. Default: FALSE.

    eps

    (float, optional) Small value to avoid evaluation of \(\log(0)\) when +log_input=FALSE. Default: 1e-8

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_prelu.html b/reference/nnf_prelu.html new file mode 100644 index 0000000000000000000000000000000000000000..fb3a6bb5217202172b34f13f369ec1a1456a03f2 --- /dev/null +++ b/reference/nnf_prelu.html @@ -0,0 +1,214 @@ + + + + + + + + +Prelu — nnf_prelu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise the function +\(PReLU(x) = max(0,x) + weight * min(0,x)\) +where weight is a learnable parameter.

    +
    + +
    nnf_prelu(input, weight)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    weight

    (Tensor) the learnable weights

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_relu.html b/reference/nnf_relu.html new file mode 100644 index 0000000000000000000000000000000000000000..e97f5cb053b1875002399b50006d9d4b832fa4ae --- /dev/null +++ b/reference/nnf_relu.html @@ -0,0 +1,212 @@ + + + + + + + + +Relu — nnf_relu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the rectified linear unit function element-wise.

    +
    + +
    nnf_relu(input, inplace = FALSE)
    +
    +nnf_relu_(input)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_relu6.html b/reference/nnf_relu6.html new file mode 100644 index 0000000000000000000000000000000000000000..7373b22d25f8013f23ffa1e4e5984c65ab3d0330 --- /dev/null +++ b/reference/nnf_relu6.html @@ -0,0 +1,210 @@ + + + + + + + + +Relu6 — nnf_relu6 • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the element-wise function \(ReLU6(x) = min(max(0,x), 6)\).

    +
    + +
    nnf_relu6(input, inplace = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_rrelu.html b/reference/nnf_rrelu.html new file mode 100644 index 0000000000000000000000000000000000000000..cdae613b9f7188dc76bec78522d37aea2a721b31 --- /dev/null +++ b/reference/nnf_rrelu.html @@ -0,0 +1,224 @@ + + + + + + + + +Rrelu — nnf_rrelu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randomized leaky ReLU.

    +
    + +
    nnf_rrelu(input, lower = 1/8, upper = 1/3, training = FALSE, inplace = FALSE)
    +
    +nnf_rrelu_(input, lower = 1/8, upper = 1/3, training = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    lower

    lower bound of the uniform distribution. Default: 1/8

    upper

    upper bound of the uniform distribution. Default: 1/3

    training

    bool wether it's a training pass. DEfault: FALSE

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_selu.html b/reference/nnf_selu.html new file mode 100644 index 0000000000000000000000000000000000000000..4960e9f7702a13f63ffa023c4aeeccd008979c3b --- /dev/null +++ b/reference/nnf_selu.html @@ -0,0 +1,226 @@ + + + + + + + + +Selu — nnf_selu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise, +$$SELU(x) = scale * (max(0,x) + min(0, \alpha * (exp(x) - 1)))$$, +with \(\alpha=1.6732632423543772848170429916717\) and +\(scale=1.0507009873554804934193349852946\).

    +
    + +
    nnf_selu(input, inplace = FALSE)
    +
    +nnf_selu_(input)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +

    Examples

    +
    if (torch_is_installed()) { +x <- torch_randn(2, 2) +y <- nnf_selu(x) +nnf_selu_(x) +torch_equal(x, y) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_sigmoid.html b/reference/nnf_sigmoid.html new file mode 100644 index 0000000000000000000000000000000000000000..6b3e0e0ddbe382f02748cb323f2c3140b67ed672 --- /dev/null +++ b/reference/nnf_sigmoid.html @@ -0,0 +1,206 @@ + + + + + + + + +Sigmoid — nnf_sigmoid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise \(Sigmoid(x_i) = \frac{1}{1 + exp(-x_i)}\)

    +
    + +
    nnf_sigmoid(input)
    + +

    Arguments

    + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_smooth_l1_loss.html b/reference/nnf_smooth_l1_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..496512b98ead8dde9ff81b6acf2867066d94216c --- /dev/null +++ b/reference/nnf_smooth_l1_loss.html @@ -0,0 +1,218 @@ + + + + + + + + +Smooth_l1_loss — nnf_smooth_l1_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Function that uses a squared term if the absolute +element-wise error falls below 1 and an L1 term otherwise.

    +
    + +
    nnf_smooth_l1_loss(input, target, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_soft_margin_loss.html b/reference/nnf_soft_margin_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..7b15040a677c22e58efd6e8a3fb591e3a9a645eb --- /dev/null +++ b/reference/nnf_soft_margin_loss.html @@ -0,0 +1,218 @@ + + + + + + + + +Soft_margin_loss — nnf_soft_margin_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that optimizes a two-class classification logistic loss +between input tensor x and target tensor y (containing 1 or -1).

    +
    + +
    nnf_soft_margin_loss(input, target, reduction = "mean")
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    tensor (N,*) where ** means, any number of additional dimensions

    target

    tensor (N,*) , same shape as the input

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_softmax.html b/reference/nnf_softmax.html new file mode 100644 index 0000000000000000000000000000000000000000..d7b9de57eb2a7e9be36586bba013d9568b4573ed --- /dev/null +++ b/reference/nnf_softmax.html @@ -0,0 +1,220 @@ + + + + + + + + +Softmax — nnf_softmax • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a softmax function.

    +
    + +
    nnf_softmax(input, dim, dtype = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) input

    dim

    (int) A dimension along which softmax will be computed.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. This is useful for preventing data type overflows. +Default: NULL.

    + +

    Details

    + +

    Softmax is defined as:

    +

    $$Softmax(x_{i}) = exp(x_i)/\sum_j exp(x_j)$$

    +

    It is applied to all slices along dim, and will re-scale them so that the elements +lie in the range [0, 1] and sum to 1.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_softmin.html b/reference/nnf_softmin.html new file mode 100644 index 0000000000000000000000000000000000000000..d60bacfc71d5a9d53adddc68a6e0d5607e6980e4 --- /dev/null +++ b/reference/nnf_softmin.html @@ -0,0 +1,220 @@ + + + + + + + + +Softmin — nnf_softmin • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies a softmin function.

    +
    + +
    nnf_softmin(input, dim, dtype = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) input

    dim

    (int) A dimension along which softmin will be computed +(so every slice along dim will sum to 1).

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. +This is useful for preventing data type overflows. Default: NULL.

    + +

    Details

    + +

    Note that

    +

    $$Softmin(x) = Softmax(-x)$$.

    +

    See nnf_softmax definition for mathematical formula.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_softplus.html b/reference/nnf_softplus.html new file mode 100644 index 0000000000000000000000000000000000000000..a412c2f9adbab4a5be0b2d6b9619efcc44d3c617 --- /dev/null +++ b/reference/nnf_softplus.html @@ -0,0 +1,218 @@ + + + + + + + + +Softplus — nnf_softplus • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise, the function \(Softplus(x) = 1/\beta * log(1 + exp(\beta * x))\).

    +
    + +
    nnf_softplus(input, beta = 1, threshold = 20)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    beta

    the beta value for the Softplus formulation. Default: 1

    threshold

    values above this revert to a linear function. Default: 20

    + +

    Details

    + +

    For numerical stability the implementation reverts to the linear function +when \(input * \beta > threshold\).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_softshrink.html b/reference/nnf_softshrink.html new file mode 100644 index 0000000000000000000000000000000000000000..8a18d2a50188f256b23b8f9bfbf6621a1a1db846 --- /dev/null +++ b/reference/nnf_softshrink.html @@ -0,0 +1,211 @@ + + + + + + + + +Softshrink — nnf_softshrink • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies the soft shrinkage function elementwise

    +
    + +
    nnf_softshrink(input, lambd = 0.5)
    + +

    Arguments

    + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    lambd

    the lambda (must be no less than zero) value for the Softshrink +formulation. Default: 0.5

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_softsign.html b/reference/nnf_softsign.html new file mode 100644 index 0000000000000000000000000000000000000000..99abab61efe8f95fec313b86ef150a76d12a2b87 --- /dev/null +++ b/reference/nnf_softsign.html @@ -0,0 +1,206 @@ + + + + + + + + +Softsign — nnf_softsign • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise, the function \(SoftSign(x) = x/(1 + |x|\)

    +
    + +
    nnf_softsign(input)
    + +

    Arguments

    + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_tanhshrink.html b/reference/nnf_tanhshrink.html new file mode 100644 index 0000000000000000000000000000000000000000..e16e47fac52e0f6964667b5d8eab038bc593f4ff --- /dev/null +++ b/reference/nnf_tanhshrink.html @@ -0,0 +1,206 @@ + + + + + + + + +Tanhshrink — nnf_tanhshrink • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Applies element-wise, \(Tanhshrink(x) = x - Tanh(x)\)

    +
    + +
    nnf_tanhshrink(input)
    + +

    Arguments

    + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_threshold.html b/reference/nnf_threshold.html new file mode 100644 index 0000000000000000000000000000000000000000..a68168b3fd0f2bf624b08c2ac11ae9de5ca3ab2b --- /dev/null +++ b/reference/nnf_threshold.html @@ -0,0 +1,220 @@ + + + + + + + + +Threshold — nnf_threshold • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Thresholds each element of the input Tensor.

    +
    + +
    nnf_threshold(input, threshold, value, inplace = FALSE)
    +
    +nnf_threshold_(input, threshold, value)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (N,*) tensor, where * means, any number of additional +dimensions

    threshold

    The value to threshold at

    value

    The value to replace with

    inplace

    can optionally do the operation in-place. Default: FALSE

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_triplet_margin_loss.html b/reference/nnf_triplet_margin_loss.html new file mode 100644 index 0000000000000000000000000000000000000000..7cfc9329af9beccfb45d728bfa50c1d05ae690e2 --- /dev/null +++ b/reference/nnf_triplet_margin_loss.html @@ -0,0 +1,255 @@ + + + + + + + + +Triplet_margin_loss — nnf_triplet_margin_loss • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates a criterion that measures the triplet loss given an input tensors x1 , +x2 , x3 and a margin with a value greater than 0 . This is used for measuring +a relative similarity between samples. A triplet is composed by a, p and n (i.e., +anchor, positive examples and negative examples respectively). The shapes of all +input tensors should be (N, D).

    +
    + +
    nnf_triplet_margin_loss(
    +  anchor,
    +  positive,
    +  negative,
    +  margin = 1,
    +  p = 2,
    +  eps = 1e-06,
    +  swap = FALSE,
    +  reduction = "mean"
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    anchor

    the anchor input tensor

    positive

    the positive input tensor

    negative

    the negative input tensor

    margin

    Default: 1.

    p

    The norm degree for pairwise distance. Default: 2.

    eps

    (float, optional) Small value to avoid division by zero.

    swap

    The distance swap is described in detail in the paper Learning shallow +convolutional feature descriptors with triplet losses by V. Balntas, E. Riba et al. +Default: FALSE.

    reduction

    (string, optional) – Specifies the reduction to apply to the +output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': +the sum of the output will be divided by the number of elements in the output, +'sum': the output will be summed. Default: 'mean'

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/nnf_unfold.html b/reference/nnf_unfold.html new file mode 100644 index 0000000000000000000000000000000000000000..aec9b5aebcaf4c887df2c803f84a792377bf28b2 --- /dev/null +++ b/reference/nnf_unfold.html @@ -0,0 +1,237 @@ + + + + + + + + +Unfold — nnf_unfold • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Extracts sliding local blocks from an batched input tensor.

    +
    + +
    nnf_unfold(input, kernel_size, dilation = 1, padding = 0, stride = 1)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    the input tensor

    kernel_size

    the size of the sliding blocks

    dilation

    a parameter that controls the stride of elements within the +neighborhood. Default: 1

    padding

    implicit zero padding to be added on both sides of input. +Default: 0

    stride

    the stride of the sliding blocks in the input spatial dimensions. +Default: 1

    + +

    Warning

    + + + + +

    Currently, only 4-D input tensors (batched image-like tensors) are +supported.

    + + +

    More than one element of the unfolded tensor may refer to a single +memory location. As a result, in-place operations (especially ones that +are vectorized) may result in incorrect behavior. If you need to write +to the tensor, please clone it first.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/optim_adam.html b/reference/optim_adam.html new file mode 100644 index 0000000000000000000000000000000000000000..3a10c0c3c3a97efeaf5ab9e32045547cd942f323 --- /dev/null +++ b/reference/optim_adam.html @@ -0,0 +1,247 @@ + + + + + + + + +Implements Adam algorithm. — optim_adam • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    It has been proposed in Adam: A Method for Stochastic Optimization.

    +
    + +
    optim_adam(
    +  params,
    +  lr = 0.001,
    +  betas = c(0.9, 0.999),
    +  eps = 1e-08,
    +  weight_decay = 0,
    +  amsgrad = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    params

    (iterable): iterable of parameters to optimize or dicts defining +parameter groups

    lr

    (float, optional): learning rate (default: 1e-3)

    betas

    (Tuple[float, float], optional): coefficients used for computing +running averages of gradient and its square (default: (0.9, 0.999))

    eps

    (float, optional): term added to the denominator to improve +numerical stability (default: 1e-8)

    weight_decay

    (float, optional): weight decay (L2 penalty) (default: 0)

    amsgrad

    (boolean, optional): whether to use the AMSGrad variant of this +algorithm from the paper On the Convergence of Adam and Beyond +(default: FALSE)

    + + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +optimizer <- optim_adam(model$parameters(), lr=0.1) +optimizer$zero_grad() +loss_fn(model(input), target)$backward() +optimizer$step() +} + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/optim_required.html b/reference/optim_required.html new file mode 100644 index 0000000000000000000000000000000000000000..23ee3b7c4d2f349a049a217946175706a356a13e --- /dev/null +++ b/reference/optim_required.html @@ -0,0 +1,197 @@ + + + + + + + + +Dummy value indicating a required value. — optim_required • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    export

    +
    + +
    optim_required()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/optim_sgd.html b/reference/optim_sgd.html new file mode 100644 index 0000000000000000000000000000000000000000..45dee33d6cb0d288dd2fd2505c35be13cd8d4516 --- /dev/null +++ b/reference/optim_sgd.html @@ -0,0 +1,272 @@ + + + + + + + + +SGD optimizer — optim_sgd • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Implements stochastic gradient descent (optionally with momentum). +Nesterov momentum is based on the formula from +On the importance of initialization and momentum in deep learning.

    +
    + +
    optim_sgd(
    +  params,
    +  lr = optim_required(),
    +  momentum = 0,
    +  dampening = 0,
    +  weight_decay = 0,
    +  nesterov = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    params

    (iterable): iterable of parameters to optimize or dicts defining +parameter groups

    lr

    (float): learning rate

    momentum

    (float, optional): momentum factor (default: 0)

    dampening

    (float, optional): dampening for momentum (default: 0)

    weight_decay

    (float, optional): weight decay (L2 penalty) (default: 0)

    nesterov

    (bool, optional): enables Nesterov momentum (default: FALSE)

    + +

    Note

    + + + + +

    The implementation of SGD with Momentum-Nesterov subtly differs from +Sutskever et. al. and implementations in some other frameworks.

    +

    Considering the specific case of Momentum, the update can be written as +$$ + \begin{array}{ll} +v_{t+1} & = \mu * v_{t} + g_{t+1}, \\ +p_{t+1} & = p_{t} - \mbox{lr} * v_{t+1}, +\end{array} +$$

    +

    where \(p\), \(g\), \(v\) and \(\mu\) denote the +parameters, gradient, velocity, and momentum respectively.

    +

    This is in contrast to Sutskever et. al. and +other frameworks which employ an update of the form

    +

    $$ + \begin{array}{ll} +v_{t+1} & = \mu * v_{t} + \mbox{lr} * g_{t+1}, \\ +p_{t+1} & = p_{t} - v_{t+1}. +\end{array} +$$ +The Nesterov version is analogously modified.

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +optimizer <- optim_sgd(model$parameters(), lr=0.1, momentum=0.9) +optimizer$zero_grad() +loss_fn(model(input), target)$backward() +optimizer$step() +} + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/tensor_dataset.html b/reference/tensor_dataset.html new file mode 100644 index 0000000000000000000000000000000000000000..cb5c5974d5b029fe71d05cfc2616f1bf87394ee2 --- /dev/null +++ b/reference/tensor_dataset.html @@ -0,0 +1,205 @@ + + + + + + + + +Dataset wrapping tensors. — tensor_dataset • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Each sample will be retrieved by indexing tensors along the first dimension.

    +
    + +
    tensor_dataset(...)
    + +

    Arguments

    + + + + + + +
    ...

    tensors that have the same size of the first dimension.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_abs.html b/reference/torch_abs.html new file mode 100644 index 0000000000000000000000000000000000000000..94ca0f4fe36bca210760fdb8e8844d2c13fb1724 --- /dev/null +++ b/reference/torch_abs.html @@ -0,0 +1,222 @@ + + + + + + + + +Abs — torch_abs • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Abs

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    abs(input, out=None) -> Tensor

    + + + + +

    Computes the element-wise absolute value of the given input tensor.

    +

    $$ + \mbox{out}_{i} = |\mbox{input}_{i}| +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_abs(torch_tensor(c(-1, -2, 3))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_acos.html b/reference/torch_acos.html new file mode 100644 index 0000000000000000000000000000000000000000..1a8f215a2f2fbf6b49e2ed0830f5fab29567645e --- /dev/null +++ b/reference/torch_acos.html @@ -0,0 +1,224 @@ + + + + + + + + +Acos — torch_acos • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Acos

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    acos(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the arccosine of the elements of input.

    +

    $$ + \mbox{out}_{i} = \cos^{-1}(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_acos(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_adaptive_avg_pool1d.html b/reference/torch_adaptive_avg_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..808c84c8f0605482b85d52ce31990ffde857c587 --- /dev/null +++ b/reference/torch_adaptive_avg_pool1d.html @@ -0,0 +1,212 @@ + + + + + + + + +Adaptive_avg_pool1d — torch_adaptive_avg_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Adaptive_avg_pool1d

    +
    + + +

    Arguments

    + + + + + + +
    output_size

    NA the target output size (single integer)

    + +

    adaptive_avg_pool1d(input, output_size) -> Tensor

    + + + + +

    Applies a 1D adaptive average pooling over an input signal composed of +several input planes.

    +

    See ~torch.nn.AdaptiveAvgPool1d for details and output shape.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_add.html b/reference/torch_add.html new file mode 100644 index 0000000000000000000000000000000000000000..26262156c17324b78b5629880c33f8e79cf4008f --- /dev/null +++ b/reference/torch_add.html @@ -0,0 +1,257 @@ + + + + + + + + +Add — torch_add • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Add

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    value

    (Number) the number to be added to each element of input

    other

    (Tensor) the second input tensor

    alpha

    (Number) the scalar multiplier for other

    + +

    add(input, other, out=None)

    + + + + +

    Adds the scalar other to each element of the input input +and returns a new resulting tensor.

    +

    $$ + \mbox{out} = \mbox{input} + \mbox{other} +$$ +If input is of type FloatTensor or DoubleTensor, other must be +a real number, otherwise it should be an integer.

    +

    add(input, other, *, alpha=1, out=None)

    + + + + +

    Each element of the tensor other is multiplied by the scalar +alpha and added to each element of the tensor input. +The resulting tensor is returned.

    +

    The shapes of input and other must be +broadcastable .

    +

    $$ + \mbox{out} = \mbox{input} + \mbox{alpha} \times \mbox{other} +$$ +If other is of type FloatTensor or DoubleTensor, alpha must be +a real number, otherwise it should be an integer.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_add(a, 20) + + +a = torch_randn(c(4)) +a +b = torch_randn(c(4, 1)) +b +torch_add(a, b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_addbmm.html b/reference/torch_addbmm.html new file mode 100644 index 0000000000000000000000000000000000000000..29689137da7447a5840c4cda1ab1dcb57681b54f --- /dev/null +++ b/reference/torch_addbmm.html @@ -0,0 +1,253 @@ + + + + + + + + +Addbmm — torch_addbmm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Addbmm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    batch1

    (Tensor) the first batch of matrices to be multiplied

    batch2

    (Tensor) the second batch of matrices to be multiplied

    beta

    (Number, optional) multiplier for input (\(\beta\))

    input

    (Tensor) matrix to be added

    alpha

    (Number, optional) multiplier for batch1 @ batch2 (\(\alpha\))

    out

    (Tensor, optional) the output tensor.

    + +

    addbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None) -> Tensor

    + + + + +

    Performs a batch matrix-matrix product of matrices stored +in batch1 and batch2, +with a reduced add step (all matrix multiplications get accumulated +along the first dimension). +input is added to the final result.

    +

    batch1 and batch2 must be 3-D tensors each containing the +same number of matrices.

    +

    If batch1 is a \((b \times n \times m)\) tensor, batch2 is a +\((b \times m \times p)\) tensor, input must be +broadcastable with a \((n \times p)\) tensor +and out will be a \((n \times p)\) tensor.

    +

    $$ + out = \beta\ \mbox{input} + \alpha\ (\sum_{i=0}^{b-1} \mbox{batch1}_i \mathbin{@} \mbox{batch2}_i) +$$ +For inputs of type FloatTensor or DoubleTensor, arguments beta and alpha +must be real numbers, otherwise they should be integers.

    + +

    Examples

    +
    if (torch_is_installed()) { + +M = torch_randn(c(3, 5)) +batch1 = torch_randn(c(10, 3, 4)) +batch2 = torch_randn(c(10, 4, 5)) +torch_addbmm(M, batch1, batch2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_addcdiv.html b/reference/torch_addcdiv.html new file mode 100644 index 0000000000000000000000000000000000000000..6d016d1ae13d4717479ef135dfce11df75edf4bd --- /dev/null +++ b/reference/torch_addcdiv.html @@ -0,0 +1,256 @@ + + + + + + + + +Addcdiv — torch_addcdiv • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Addcdiv

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to be added

    tensor1

    (Tensor) the numerator tensor

    tensor2

    (Tensor) the denominator tensor

    value

    (Number, optional) multiplier for \(\mbox{tensor1} / \mbox{tensor2}\)

    out

    (Tensor, optional) the output tensor.

    + +

    addcdiv(input, tensor1, tensor2, *, value=1, out=None) -> Tensor

    + + + + +

    Performs the element-wise division of tensor1 by tensor2, +multiply the result by the scalar value and add it to input.

    +

    Warning

    + + + +

    Integer division with addcdiv is deprecated, and in a future release +addcdiv will perform a true division of tensor1 and tensor2. +The current addcdiv behavior can be replicated using torch_floor_divide() +for integral inputs +(input + value * tensor1 // tensor2) +and torch_div() for float inputs +(input + value * tensor1 / tensor2). +The new addcdiv behavior can be implemented with torch_true_divide() +(input + value * torch.true_divide(tensor1, +tensor2).

    +

    $$ + \mbox{out}_i = \mbox{input}_i + \mbox{value} \times \frac{\mbox{tensor1}_i}{\mbox{tensor2}_i} +$$

    +

    The shapes of input, tensor1, and tensor2 must be +broadcastable .

    +

    For inputs of type FloatTensor or DoubleTensor, value must be +a real number, otherwise an integer.

    + +

    Examples

    +
    if (torch_is_installed()) { + +t = torch_randn(c(1, 3)) +t1 = torch_randn(c(3, 1)) +t2 = torch_randn(c(1, 3)) +torch_addcdiv(t, t1, t2, 0.1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_addcmul.html b/reference/torch_addcmul.html new file mode 100644 index 0000000000000000000000000000000000000000..559ec804225892dee7069a83843530362eb81ae8 --- /dev/null +++ b/reference/torch_addcmul.html @@ -0,0 +1,243 @@ + + + + + + + + +Addcmul — torch_addcmul • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Addcmul

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to be added

    tensor1

    (Tensor) the tensor to be multiplied

    tensor2

    (Tensor) the tensor to be multiplied

    value

    (Number, optional) multiplier for \(tensor1 .* tensor2\)

    out

    (Tensor, optional) the output tensor.

    + +

    addcmul(input, tensor1, tensor2, *, value=1, out=None) -> Tensor

    + + + + +

    Performs the element-wise multiplication of tensor1 +by tensor2, multiply the result by the scalar value +and add it to input.

    +

    $$ + \mbox{out}_i = \mbox{input}_i + \mbox{value} \times \mbox{tensor1}_i \times \mbox{tensor2}_i +$$ +The shapes of tensor, tensor1, and tensor2 must be +broadcastable .

    +

    For inputs of type FloatTensor or DoubleTensor, value must be +a real number, otherwise an integer.

    + +

    Examples

    +
    if (torch_is_installed()) { + +t = torch_randn(c(1, 3)) +t1 = torch_randn(c(3, 1)) +t2 = torch_randn(c(1, 3)) +torch_addcmul(t, t1, t2, 0.1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_addmm.html b/reference/torch_addmm.html new file mode 100644 index 0000000000000000000000000000000000000000..618606ac6abbf825016b0f19a2c2334f319353b2 --- /dev/null +++ b/reference/torch_addmm.html @@ -0,0 +1,250 @@ + + + + + + + + +Addmm — torch_addmm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Addmm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) matrix to be added

    mat1

    (Tensor) the first matrix to be multiplied

    mat2

    (Tensor) the second matrix to be multiplied

    beta

    (Number, optional) multiplier for input (\(\beta\))

    alpha

    (Number, optional) multiplier for \(mat1 @ mat2\) (\(\alpha\))

    out

    (Tensor, optional) the output tensor.

    + +

    addmm(input, mat1, mat2, *, beta=1, alpha=1, out=None) -> Tensor

    + + + + +

    Performs a matrix multiplication of the matrices mat1 and mat2. +The matrix input is added to the final result.

    +

    If mat1 is a \((n \times m)\) tensor, mat2 is a +\((m \times p)\) tensor, then input must be +broadcastable with a \((n \times p)\) tensor +and out will be a \((n \times p)\) tensor.

    +

    alpha and beta are scaling factors on matrix-vector product between +mat1 and mat2 and the added matrix input respectively.

    +

    $$ + \mbox{out} = \beta\ \mbox{input} + \alpha\ (\mbox{mat1}_i \mathbin{@} \mbox{mat2}_i) +$$ +For inputs of type FloatTensor or DoubleTensor, arguments beta and +alpha must be real numbers, otherwise they should be integers.

    + +

    Examples

    +
    if (torch_is_installed()) { + +M = torch_randn(c(2, 3)) +mat1 = torch_randn(c(2, 3)) +mat2 = torch_randn(c(3, 3)) +torch_addmm(M, mat1, mat2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_addmv.html b/reference/torch_addmv.html new file mode 100644 index 0000000000000000000000000000000000000000..ff63d455c1a43d99ffd032f54a07e77f736f68b3 --- /dev/null +++ b/reference/torch_addmv.html @@ -0,0 +1,251 @@ + + + + + + + + +Addmv — torch_addmv • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Addmv

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) vector to be added

    mat

    (Tensor) matrix to be multiplied

    vec

    (Tensor) vector to be multiplied

    beta

    (Number, optional) multiplier for input (\(\beta\))

    alpha

    (Number, optional) multiplier for \(mat @ vec\) (\(\alpha\))

    out

    (Tensor, optional) the output tensor.

    + +

    addmv(input, mat, vec, *, beta=1, alpha=1, out=None) -> Tensor

    + + + + +

    Performs a matrix-vector product of the matrix mat and +the vector vec. +The vector input is added to the final result.

    +

    If mat is a \((n \times m)\) tensor, vec is a 1-D tensor of +size m, then input must be +broadcastable with a 1-D tensor of size n and +out will be 1-D tensor of size n.

    +

    alpha and beta are scaling factors on matrix-vector product between +mat and vec and the added tensor input respectively.

    +

    $$ + \mbox{out} = \beta\ \mbox{input} + \alpha\ (\mbox{mat} \mathbin{@} \mbox{vec}) +$$ +For inputs of type FloatTensor or DoubleTensor, arguments beta and +alpha must be real numbers, otherwise they should be integers

    + +

    Examples

    +
    if (torch_is_installed()) { + +M = torch_randn(c(2)) +mat = torch_randn(c(2, 3)) +vec = torch_randn(c(3)) +torch_addmv(M, mat, vec) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_addr.html b/reference/torch_addr.html new file mode 100644 index 0000000000000000000000000000000000000000..818a14c626fccd237da79b8b950f6f59ba349046 --- /dev/null +++ b/reference/torch_addr.html @@ -0,0 +1,252 @@ + + + + + + + + +Addr — torch_addr • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Addr

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) matrix to be added

    vec1

    (Tensor) the first vector of the outer product

    vec2

    (Tensor) the second vector of the outer product

    beta

    (Number, optional) multiplier for input (\(\beta\))

    alpha

    (Number, optional) multiplier for \(\mbox{vec1} \otimes \mbox{vec2}\) (\(\alpha\))

    out

    (Tensor, optional) the output tensor.

    + +

    addr(input, vec1, vec2, *, beta=1, alpha=1, out=None) -> Tensor

    + + + + +

    Performs the outer-product of vectors vec1 and vec2 +and adds it to the matrix input.

    +

    Optional values beta and alpha are scaling factors on the +outer product between vec1 and vec2 and the added matrix +input respectively.

    +

    $$ + \mbox{out} = \beta\ \mbox{input} + \alpha\ (\mbox{vec1} \otimes \mbox{vec2}) +$$ +If vec1 is a vector of size n and vec2 is a vector +of size m, then input must be +broadcastable with a matrix of size +\((n \times m)\) and out will be a matrix of size +\((n \times m)\).

    +

    For inputs of type FloatTensor or DoubleTensor, arguments beta and +alpha must be real numbers, otherwise they should be integers

    + +

    Examples

    +
    if (torch_is_installed()) { + +vec1 = torch_arange(1., 4.) +vec2 = torch_arange(1., 3.) +M = torch_zeros(c(3, 2)) +torch_addr(M, vec1, vec2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_allclose.html b/reference/torch_allclose.html new file mode 100644 index 0000000000000000000000000000000000000000..798b8a1b2533e7b0f39cd67171d34e832f3f827b --- /dev/null +++ b/reference/torch_allclose.html @@ -0,0 +1,239 @@ + + + + + + + + +Allclose — torch_allclose • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Allclose

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) first tensor to compare

    other

    (Tensor) second tensor to compare

    atol

    (float, optional) absolute tolerance. Default: 1e-08

    rtol

    (float, optional) relative tolerance. Default: 1e-05

    equal_nan

    (bool, optional) if True, then two NaN s will be compared as equal. Default: False

    + +

    allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) -> bool

    + + + + +

    This function checks if all input and other satisfy the condition:

    +

    $$ + \vert \mbox{input} - \mbox{other} \vert \leq \mbox{atol} + \mbox{rtol} \times \vert \mbox{other} \vert +$$ +elementwise, for all elements of input and other. The behaviour of this function is analogous to +numpy.allclose <https://docs.scipy.org/doc/numpy/reference/generated/numpy.allclose.html>_

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_allclose(torch_tensor(c(10000., 1e-07)), torch_tensor(c(10000.1, 1e-08))) +torch_allclose(torch_tensor(c(10000., 1e-08)), torch_tensor(c(10000.1, 1e-09))) +torch_allclose(torch_tensor(c(1.0, NaN)), torch_tensor(c(1.0, NaN))) +torch_allclose(torch_tensor(c(1.0, NaN)), torch_tensor(c(1.0, NaN)), equal_nan=TRUE) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_angle.html b/reference/torch_angle.html new file mode 100644 index 0000000000000000000000000000000000000000..e49069ab3364301de2134ae2be3ee82650392648 --- /dev/null +++ b/reference/torch_angle.html @@ -0,0 +1,224 @@ + + + + + + + + +Angle — torch_angle • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Angle

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    angle(input, out=None) -> Tensor

    + + + + +

    Computes the element-wise angle (in radians) of the given input tensor.

    +

    $$ + \mbox{out}_{i} = angle(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +torch_angle(torch_tensor(c(-1 + 1i, -2 + 2i, 3 - 3i)))*180/3.14159 +} + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_arange.html b/reference/torch_arange.html new file mode 100644 index 0000000000000000000000000000000000000000..02159f06899da8dc2c313602ad3a5cd54e1169f4 --- /dev/null +++ b/reference/torch_arange.html @@ -0,0 +1,253 @@ + + + + + + + + +Arange — torch_arange • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Arange

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    start

    (Number) the starting value for the set of points. Default: 0.

    end

    (Number) the ending value for the set of points

    step

    (Number) the gap between each pair of adjacent points. Default: 1.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type). If dtype is not given, infer the data type from the other input arguments. If any of start, end, or stop are floating-point, the dtype is inferred to be the default dtype, see ~torch.get_default_dtype. Otherwise, the dtype is inferred to be torch.int64.

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    arange(start=0, end, step=1, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a 1-D tensor of size \(\left\lceil \frac{\mbox{end} - \mbox{start}}{\mbox{step}} \right\rceil\) +with values from the interval [start, end) taken with common difference +step beginning from start.

    +

    Note that non-integer step is subject to floating point rounding errors when +comparing against end; to avoid inconsistency, we advise adding a small epsilon to end +in such cases.

    +

    $$ + \mbox{out}_{{i+1}} = \mbox{out}_{i} + \mbox{step} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_arange(start = 0, end = 5) +torch_arange(1, 4) +torch_arange(1, 2.5, 0.5) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_argmax.html b/reference/torch_argmax.html new file mode 100644 index 0000000000000000000000000000000000000000..7f07577b7f61a7ff20b795b01ff5f6ba8ebba75b --- /dev/null +++ b/reference/torch_argmax.html @@ -0,0 +1,242 @@ + + + + + + + + +Argmax — torch_argmax • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Argmax

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to reduce. If None, the argmax of the flattened input is returned.

    keepdim

    (bool) whether the output tensor has dim retained or not. Ignored if dim=None.

    + +

    argmax(input) -> LongTensor

    + + + + +

    Returns the indices of the maximum value of all elements in the input tensor.

    +

    This is the second value returned by torch_max. See its +documentation for the exact semantics of this method.

    +

    argmax(input, dim, keepdim=False) -> LongTensor

    + + + + +

    Returns the indices of the maximum values of a tensor across a dimension.

    +

    This is the second value returned by torch_max. See its +documentation for the exact semantics of this method.

    + +

    Examples

    +
    if (torch_is_installed()) { + +if (FALSE) { +a = torch_randn(c(4, 4)) +a +torch_argmax(a) +} + + +a = torch_randn(c(4, 4)) +a +torch_argmax(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_argmin.html b/reference/torch_argmin.html new file mode 100644 index 0000000000000000000000000000000000000000..106d245098df3669196de054ec4bff6273def707 --- /dev/null +++ b/reference/torch_argmin.html @@ -0,0 +1,240 @@ + + + + + + + + +Argmin — torch_argmin • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Argmin

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to reduce. If None, the argmin of the flattened input is returned.

    keepdim

    (bool) whether the output tensor has dim retained or not. Ignored if dim=None.

    + +

    argmin(input) -> LongTensor

    + + + + +

    Returns the indices of the minimum value of all elements in the input tensor.

    +

    This is the second value returned by torch_min. See its +documentation for the exact semantics of this method.

    +

    argmin(input, dim, keepdim=False, out=None) -> LongTensor

    + + + + +

    Returns the indices of the minimum values of a tensor across a dimension.

    +

    This is the second value returned by torch_min. See its +documentation for the exact semantics of this method.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4, 4)) +a +torch_argmin(a) + + +a = torch_randn(c(4, 4)) +a +torch_argmin(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_argsort.html b/reference/torch_argsort.html new file mode 100644 index 0000000000000000000000000000000000000000..251994e5b25824bfe5dc4cb1a40e03e300f30e81 --- /dev/null +++ b/reference/torch_argsort.html @@ -0,0 +1,228 @@ + + + + + + + + +Argsort — torch_argsort • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Argsort

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int, optional) the dimension to sort along

    descending

    (bool, optional) controls the sorting order (ascending or descending)

    + +

    argsort(input, dim=-1, descending=False) -> LongTensor

    + + + + +

    Returns the indices that sort a tensor along a given dimension in ascending +order by value.

    +

    This is the second value returned by torch_sort. See its documentation +for the exact semantics of this method.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4, 4)) +a +torch_argsort(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_as_strided.html b/reference/torch_as_strided.html new file mode 100644 index 0000000000000000000000000000000000000000..fd7eb3e1360a5dc4816180219ceb5e1911a8244b --- /dev/null +++ b/reference/torch_as_strided.html @@ -0,0 +1,246 @@ + + + + + + + + +As_strided — torch_as_strided • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    As_strided

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    size

    (tuple or ints) the shape of the output tensor

    stride

    (tuple or ints) the stride of the output tensor

    storage_offset

    (int, optional) the offset in the underlying storage of the output tensor

    + +

    as_strided(input, size, stride, storage_offset=0) -> Tensor

    + + + + +

    Create a view of an existing torch_Tensor input with specified +size, stride and storage_offset.

    +

    Warning

    + + + +

    More than one element of a created tensor may refer to a single memory +location. As a result, in-place operations (especially ones that are +vectorized) may result in incorrect behavior. If you need to write to +the tensors, please clone them first.

    Many PyTorch functions, which return a view of a tensor, are internally
    +implemented with this function. Those functions, like
    +`torch_Tensor.expand`, are easier to read and are therefore more
    +advisable to use.
    +
    + + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(3, 3)) +x +t = torch_as_strided(x, list(2, 2), list(1, 2)) +t +t = torch_as_strided(x, list(2, 2), list(1, 2), 1) +t +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_asin.html b/reference/torch_asin.html new file mode 100644 index 0000000000000000000000000000000000000000..12934e2a5bf3ada89cdf55cad2e9dfb6f4eaec08 --- /dev/null +++ b/reference/torch_asin.html @@ -0,0 +1,224 @@ + + + + + + + + +Asin — torch_asin • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Asin

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    asin(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the arcsine of the elements of input.

    +

    $$ + \mbox{out}_{i} = \sin^{-1}(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_asin(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_atan.html b/reference/torch_atan.html new file mode 100644 index 0000000000000000000000000000000000000000..65986bd7c05ee1eec44b3dff105cd703ec60357f --- /dev/null +++ b/reference/torch_atan.html @@ -0,0 +1,224 @@ + + + + + + + + +Atan — torch_atan • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Atan

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    atan(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the arctangent of the elements of input.

    +

    $$ + \mbox{out}_{i} = \tan^{-1}(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_atan(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_atan2.html b/reference/torch_atan2.html new file mode 100644 index 0000000000000000000000000000000000000000..0ea68a1e8f642933a13376255e6495460f4d1c6c --- /dev/null +++ b/reference/torch_atan2.html @@ -0,0 +1,232 @@ + + + + + + + + +Atan2 — torch_atan2 • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Atan2

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the first input tensor

    other

    (Tensor) the second input tensor

    out

    (Tensor, optional) the output tensor.

    + +

    atan2(input, other, out=None) -> Tensor

    + + + + +

    Element-wise arctangent of \(\mbox{input}_{i} / \mbox{other}_{i}\) +with consideration of the quadrant. Returns a new tensor with the signed angles +in radians between vector \((\mbox{other}_{i}, \mbox{input}_{i})\) +and vector \((1, 0)\). (Note that \(\mbox{other}_{i}\), the second +parameter, is the x-coordinate, while \(\mbox{input}_{i}\), the first +parameter, is the y-coordinate.)

    +

    The shapes of input and other must be +broadcastable .

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_atan2(a, torch_randn(c(4))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_avg_pool1d.html b/reference/torch_avg_pool1d.html new file mode 100644 index 0000000000000000000000000000000000000000..736e66d8a67c3f5c9416126371c39220b24f3715 --- /dev/null +++ b/reference/torch_avg_pool1d.html @@ -0,0 +1,232 @@ + + + + + + + + +Avg_pool1d — torch_avg_pool1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Avg_pool1d

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iW)\)

    kernel_size

    NA the size of the window. Can be a single number or a tuple (kW,)

    stride

    NA the stride of the window. Can be a single number or a tuple (sW,). Default: kernel_size

    padding

    NA implicit zero paddings on both sides of the input. Can be a single number or a tuple (padW,). Default: 0

    ceil_mode

    NA when True, will use ceil instead of floor to compute the output shape. Default: False

    count_include_pad

    NA when True, will include the zero-padding in the averaging calculation. Default: True

    + +

    avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True) -> Tensor

    + + + + +

    Applies a 1D average pooling over an input signal composed of several +input planes.

    +

    See ~torch.nn.AvgPool1d for details and output shape.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_baddbmm.html b/reference/torch_baddbmm.html new file mode 100644 index 0000000000000000000000000000000000000000..10c73090dd88a19274a03fa738c19dbab06543dd --- /dev/null +++ b/reference/torch_baddbmm.html @@ -0,0 +1,253 @@ + + + + + + + + +Baddbmm — torch_baddbmm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Baddbmm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to be added

    batch1

    (Tensor) the first batch of matrices to be multiplied

    batch2

    (Tensor) the second batch of matrices to be multiplied

    beta

    (Number, optional) multiplier for input (\(\beta\))

    alpha

    (Number, optional) multiplier for \(\mbox{batch1} \mathbin{@} \mbox{batch2}\) (\(\alpha\))

    out

    (Tensor, optional) the output tensor.

    + +

    baddbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None) -> Tensor

    + + + + +

    Performs a batch matrix-matrix product of matrices in batch1 +and batch2. +input is added to the final result.

    +

    batch1 and batch2 must be 3-D tensors each containing the same +number of matrices.

    +

    If batch1 is a \((b \times n \times m)\) tensor, batch2 is a +\((b \times m \times p)\) tensor, then input must be +broadcastable with a +\((b \times n \times p)\) tensor and out will be a +\((b \times n \times p)\) tensor. Both alpha and beta mean the +same as the scaling factors used in torch_addbmm.

    +

    $$ + \mbox{out}_i = \beta\ \mbox{input}_i + \alpha\ (\mbox{batch1}_i \mathbin{@} \mbox{batch2}_i) +$$ +For inputs of type FloatTensor or DoubleTensor, arguments beta and +alpha must be real numbers, otherwise they should be integers.

    + +

    Examples

    +
    if (torch_is_installed()) { + +M = torch_randn(c(10, 3, 5)) +batch1 = torch_randn(c(10, 3, 4)) +batch2 = torch_randn(c(10, 4, 5)) +torch_baddbmm(M, batch1, batch2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bartlett_window.html b/reference/torch_bartlett_window.html new file mode 100644 index 0000000000000000000000000000000000000000..7150b7c7742f6bdcb65077ce29b913f4fc43c56b --- /dev/null +++ b/reference/torch_bartlett_window.html @@ -0,0 +1,252 @@ + + + + + + + + +Bartlett_window — torch_bartlett_window • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bartlett_window

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    window_length

    (int) the size of returned window

    periodic

    (bool, optional) If True, returns a window to be used as periodic function. If False, return a symmetric window.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type). Only floating point types are supported.

    layout

    (torch.layout, optional) the desired layout of returned window tensor. Only torch_strided (dense layout) is supported.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    Note

    + + +
    If `window_length` \eqn{=1}, the returned window contains a single value 1.
    +
    + +

    bartlett_window(window_length, periodic=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Bartlett window function.

    +

    $$ + w[n] = 1 - \left| \frac{2n}{N-1} - 1 \right| = \left\{ \begin{array}{ll} + \frac{2n}{N - 1} & \mbox{if } 0 \leq n \leq \frac{N - 1}{2} \\ + 2 - \frac{2n}{N - 1} & \mbox{if } \frac{N - 1}{2} < n < N \\ + \end{array} + \right. , +$$ +where \(N\) is the full window size.

    +

    The input window_length is a positive integer controlling the +returned window size. periodic flag determines whether the returned +window trims off the last duplicate value from the symmetric window and is +ready to be used as a periodic window with functions like +torch_stft. Therefore, if periodic is true, the \(N\) in +above formula is in fact \(\mbox{window\_length} + 1\). Also, we always have +torch_bartlett_window(L, periodic=True) equal to +torch_bartlett_window(L + 1, periodic=False)[:-1]).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bernoulli.html b/reference/torch_bernoulli.html new file mode 100644 index 0000000000000000000000000000000000000000..99054339a31449aed1a35d7e24d81e1cc95f8947 --- /dev/null +++ b/reference/torch_bernoulli.html @@ -0,0 +1,243 @@ + + + + + + + + +Bernoulli — torch_bernoulli • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bernoulli

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of probability values for the Bernoulli distribution

    generator

    (torch.Generator, optional) a pseudorandom number generator for sampling

    out

    (Tensor, optional) the output tensor.

    + +

    bernoulli(input, *, generator=None, out=None) -> Tensor

    + + + + +

    Draws binary random numbers (0 or 1) from a Bernoulli distribution.

    +

    The input tensor should be a tensor containing probabilities +to be used for drawing the binary random number. +Hence, all values in input have to be in the range: +\(0 \leq \mbox{input}_i \leq 1\).

    +

    The \(\mbox{i}^{th}\) element of the output tensor will draw a +value \(1\) according to the \(\mbox{i}^{th}\) probability value given +in input.

    +

    $$ + \mbox{out}_{i} \sim \mathrm{Bernoulli}(p = \mbox{input}_{i}) +$$ +The returned out tensor only has values 0 or 1 and is of the same +shape as input.

    +

    out can have integral dtype, but input must have floating +point dtype.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_empty(c(3, 3))$uniform_(0, 1) # generate a uniform random matrix with range c(0, 1) +a +torch_bernoulli(a) +a = torch_ones(c(3, 3)) # probability of drawing "1" is 1 +torch_bernoulli(a) +a = torch_zeros(c(3, 3)) # probability of drawing "1" is 0 +torch_bernoulli(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bincount.html b/reference/torch_bincount.html new file mode 100644 index 0000000000000000000000000000000000000000..096fdf697b948235d5fa96779fef4056fdba898e --- /dev/null +++ b/reference/torch_bincount.html @@ -0,0 +1,236 @@ + + + + + + + + +Bincount — torch_bincount • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bincount

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) 1-d int tensor

    weights

    (Tensor) optional, weight for each value in the input tensor. Should be of same size as input tensor.

    minlength

    (int) optional, minimum number of bins. Should be non-negative.

    + +

    bincount(input, weights=None, minlength=0) -> Tensor

    + + + + +

    Count the frequency of each value in an array of non-negative ints.

    +

    The number of bins (size 1) is one larger than the largest value in +input unless input is empty, in which case the result is a +tensor of size 0. If minlength is specified, the number of bins is at least +minlength and if input is empty, then the result is tensor of size +minlength filled with zeros. If n is the value at position i, +out[n] += weights[i] if weights is specified else +out[n] += 1.

    +

    .. include:: cuda_deterministic.rst

    + +

    Examples

    +
    if (torch_is_installed()) { + +input = torch_randint(0, 8, list(5), dtype=torch_int64()) +weights = torch_linspace(0, 1, steps=5) +input +weights +torch_bincount(input, weights) +input$bincount(weights) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bitwise_and.html b/reference/torch_bitwise_and.html new file mode 100644 index 0000000000000000000000000000000000000000..a89fc5587cd846b784c260ca55f6215a7d4df26b --- /dev/null +++ b/reference/torch_bitwise_and.html @@ -0,0 +1,219 @@ + + + + + + + + +Bitwise_and — torch_bitwise_and • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bitwise_and

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    NA the first input tensor

    other

    NA the second input tensor

    out

    (Tensor, optional) the output tensor.

    + +

    bitwise_and(input, other, out=None) -> Tensor

    + + + + +

    Computes the bitwise AND of input and other. The input tensor must be of +integral or Boolean types. For bool tensors, it computes the logical AND.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bitwise_not.html b/reference/torch_bitwise_not.html new file mode 100644 index 0000000000000000000000000000000000000000..3e94c826988bd7939f23762dfdeb030056517a44 --- /dev/null +++ b/reference/torch_bitwise_not.html @@ -0,0 +1,215 @@ + + + + + + + + +Bitwise_not — torch_bitwise_not • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bitwise_not

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    bitwise_not(input, out=None) -> Tensor

    + + + + +

    Computes the bitwise NOT of the given input tensor. The input tensor must be of +integral or Boolean types. For bool tensors, it computes the logical NOT.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bitwise_or.html b/reference/torch_bitwise_or.html new file mode 100644 index 0000000000000000000000000000000000000000..e479d632e1ff01310ee62742a288bb792e8a0257 --- /dev/null +++ b/reference/torch_bitwise_or.html @@ -0,0 +1,219 @@ + + + + + + + + +Bitwise_or — torch_bitwise_or • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bitwise_or

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    NA the first input tensor

    other

    NA the second input tensor

    out

    (Tensor, optional) the output tensor.

    + +

    bitwise_or(input, other, out=None) -> Tensor

    + + + + +

    Computes the bitwise OR of input and other. The input tensor must be of +integral or Boolean types. For bool tensors, it computes the logical OR.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bitwise_xor.html b/reference/torch_bitwise_xor.html new file mode 100644 index 0000000000000000000000000000000000000000..cb388de71c851e4d2c1514e1aed936ea2fbee7b3 --- /dev/null +++ b/reference/torch_bitwise_xor.html @@ -0,0 +1,219 @@ + + + + + + + + +Bitwise_xor — torch_bitwise_xor • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bitwise_xor

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    NA the first input tensor

    other

    NA the second input tensor

    out

    (Tensor, optional) the output tensor.

    + +

    bitwise_xor(input, other, out=None) -> Tensor

    + + + + +

    Computes the bitwise XOR of input and other. The input tensor must be of +integral or Boolean types. For bool tensors, it computes the logical XOR.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_blackman_window.html b/reference/torch_blackman_window.html new file mode 100644 index 0000000000000000000000000000000000000000..d8c9fa8ea7a1189581adb61c4ec5e91ca015cbf0 --- /dev/null +++ b/reference/torch_blackman_window.html @@ -0,0 +1,248 @@ + + + + + + + + +Blackman_window — torch_blackman_window • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Blackman_window

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    window_length

    (int) the size of returned window

    periodic

    (bool, optional) If True, returns a window to be used as periodic function. If False, return a symmetric window.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type). Only floating point types are supported.

    layout

    (torch.layout, optional) the desired layout of returned window tensor. Only torch_strided (dense layout) is supported.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    Note

    + + +
    If `window_length` \eqn{=1}, the returned window contains a single value 1.
    +
    + +

    blackman_window(window_length, periodic=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Blackman window function.

    +

    $$ + w[n] = 0.42 - 0.5 \cos \left( \frac{2 \pi n}{N - 1} \right) + 0.08 \cos \left( \frac{4 \pi n}{N - 1} \right) +$$ +where \(N\) is the full window size.

    +

    The input window_length is a positive integer controlling the +returned window size. periodic flag determines whether the returned +window trims off the last duplicate value from the symmetric window and is +ready to be used as a periodic window with functions like +torch_stft. Therefore, if periodic is true, the \(N\) in +above formula is in fact \(\mbox{window\_length} + 1\). Also, we always have +torch_blackman_window(L, periodic=True) equal to +torch_blackman_window(L + 1, periodic=False)[:-1]).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_bmm.html b/reference/torch_bmm.html new file mode 100644 index 0000000000000000000000000000000000000000..03611caa78b8e647827d32a142b3eb20736d95d3 --- /dev/null +++ b/reference/torch_bmm.html @@ -0,0 +1,239 @@ + + + + + + + + +Bmm — torch_bmm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Bmm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the first batch of matrices to be multiplied

    mat2

    (Tensor) the second batch of matrices to be multiplied

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    This function does not broadcast . +For broadcasting matrix products, see torch_matmul.

    +

    bmm(input, mat2, out=None) -> Tensor

    + + + + +

    Performs a batch matrix-matrix product of matrices stored in input +and mat2.

    +

    input and mat2 must be 3-D tensors each containing +the same number of matrices.

    +

    If input is a \((b \times n \times m)\) tensor, mat2 is a +\((b \times m \times p)\) tensor, out will be a +\((b \times n \times p)\) tensor.

    +

    $$ + \mbox{out}_i = \mbox{input}_i \mathbin{@} \mbox{mat2}_i +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +input = torch_randn(c(10, 3, 4)) +mat2 = torch_randn(c(10, 4, 5)) +res = torch_bmm(input, mat2) +res +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_broadcast_tensors.html b/reference/torch_broadcast_tensors.html new file mode 100644 index 0000000000000000000000000000000000000000..23e01d486cb99aac59c479c5f519d53c12f40b67 --- /dev/null +++ b/reference/torch_broadcast_tensors.html @@ -0,0 +1,218 @@ + + + + + + + + +Broadcast_tensors — torch_broadcast_tensors • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Broadcast_tensors

    +
    + + +

    Arguments

    + + + + + + +
    *tensors

    NA any number of tensors of the same type

    + +

    broadcast_tensors(*tensors) -> List of Tensors

    + + + + +

    Broadcasts the given tensors according to broadcasting-semantics.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_arange(0, 3)$view(c(1, 3)) +y = torch_arange(0, 2)$view(c(2, 1)) +out = torch_broadcast_tensors(list(x, y)) +out[[1]] +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_can_cast.html b/reference/torch_can_cast.html new file mode 100644 index 0000000000000000000000000000000000000000..cc24e40f3b10620bb5ca55a96765bcbce16eaa3b --- /dev/null +++ b/reference/torch_can_cast.html @@ -0,0 +1,221 @@ + + + + + + + + +Can_cast — torch_can_cast • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Can_cast

    +
    + + +

    Arguments

    + + + + + + + + + + +
    from

    (dtype) The original torch_dtype.

    to

    (dtype) The target torch_dtype.

    + +

    can_cast(from, to) -> bool

    + + + + +

    Determines if a type conversion is allowed under PyTorch casting rules +described in the type promotion documentation .

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_can_cast(torch_double(), torch_float()) +torch_can_cast(torch_float(), torch_int()) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cartesian_prod.html b/reference/torch_cartesian_prod.html new file mode 100644 index 0000000000000000000000000000000000000000..7422b100d24ec65ecd7220b4408a101a8b0f1645 --- /dev/null +++ b/reference/torch_cartesian_prod.html @@ -0,0 +1,220 @@ + + + + + + + + +Cartesian_prod — torch_cartesian_prod • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cartesian_prod

    +
    + + +

    Arguments

    + + + + + + +
    *tensors

    NA any number of 1 dimensional tensors.

    + +

    TEST

    + + + + +

    Do cartesian product of the given sequence of tensors. The behavior is similar to +python's itertools.product.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = c(1, 2, 3) +b = c(4, 5) +tensor_a = torch_tensor(a) +tensor_b = torch_tensor(b) +torch_cartesian_prod(list(tensor_a, tensor_b)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cat.html b/reference/torch_cat.html new file mode 100644 index 0000000000000000000000000000000000000000..1dd596945dabc0034e866a580ef8ae5f377da920 --- /dev/null +++ b/reference/torch_cat.html @@ -0,0 +1,231 @@ + + + + + + + + +Cat — torch_cat • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cat

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    tensors

    (sequence of Tensors) any python sequence of tensors of the same type. Non-empty tensors provided must have the same shape, except in the cat dimension.

    dim

    (int, optional) the dimension over which the tensors are concatenated

    out

    (Tensor, optional) the output tensor.

    + +

    cat(tensors, dim=0, out=None) -> Tensor

    + + + + +

    Concatenates the given sequence of seq tensors in the given dimension. +All tensors must either have the same shape (except in the concatenating +dimension) or be empty.

    +

    torch_cat can be seen as an inverse operation for torch_split() +and torch_chunk.

    +

    torch_cat can be best understood via examples.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(2, 3)) +x +torch_cat(list(x, x, x), 1) +torch_cat(list(x, x, x), 2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cdist.html b/reference/torch_cdist.html new file mode 100644 index 0000000000000000000000000000000000000000..f28e49cd111f5491ad50ba77a58f395a6f2c03a2 --- /dev/null +++ b/reference/torch_cdist.html @@ -0,0 +1,222 @@ + + + + + + + + +Cdist — torch_cdist • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cdist

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    x1

    (Tensor) input tensor of shape \(B \times P \times M\).

    x2

    (Tensor) input tensor of shape \(B \times R \times M\).

    p

    NA p value for the p-norm distance to calculate between each vector pair \(\in [0, \infty]\).

    compute_mode

    NA 'use_mm_for_euclid_dist_if_necessary' - will use matrix multiplication approach to calculate euclidean distance (p = 2) if P > 25 or R > 25 'use_mm_for_euclid_dist' - will always use matrix multiplication approach to calculate euclidean distance (p = 2) 'donot_use_mm_for_euclid_dist' - will never use matrix multiplication approach to calculate euclidean distance (p = 2) Default: use_mm_for_euclid_dist_if_necessary.

    + +

    TEST

    + + + + +

    Computes batched the p-norm distance between each pair of the two collections of row vectors.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ceil.html b/reference/torch_ceil.html new file mode 100644 index 0000000000000000000000000000000000000000..69be1233c5c999877c6ac43c805a6563392f9ad6 --- /dev/null +++ b/reference/torch_ceil.html @@ -0,0 +1,225 @@ + + + + + + + + +Ceil — torch_ceil • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ceil

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    ceil(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the ceil of the elements of input, +the smallest integer greater than or equal to each element.

    +

    $$ + \mbox{out}_{i} = \left\lceil \mbox{input}_{i} \right\rceil = \left\lfloor \mbox{input}_{i} \right\rfloor + 1 +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_ceil(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_celu_.html b/reference/torch_celu_.html new file mode 100644 index 0000000000000000000000000000000000000000..28b9604048b50e42289c357b0481e37ee4f36d03 --- /dev/null +++ b/reference/torch_celu_.html @@ -0,0 +1,202 @@ + + + + + + + + +Celu_ — torch_celu_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Celu_

    +
    + + + +

    celu_(input, alpha=1.) -> Tensor

    + + + + +

    In-place version of torch_celu.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_chain_matmul.html b/reference/torch_chain_matmul.html new file mode 100644 index 0000000000000000000000000000000000000000..05f33cf17a5deb762c3055621da14d90610f1bb9 --- /dev/null +++ b/reference/torch_chain_matmul.html @@ -0,0 +1,223 @@ + + + + + + + + +Chain_matmul — torch_chain_matmul • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Chain_matmul

    +
    + + +

    Arguments

    + + + + + + +
    matrices

    (Tensors...) a sequence of 2 or more 2-D tensors whose product is to be determined.

    + +

    TEST

    + + + + +

    Returns the matrix product of the \(N\) 2-D tensors. This product is efficiently computed +using the matrix chain order algorithm which selects the order in which incurs the lowest cost in terms +of arithmetic operations ([CLRS]_). Note that since this is a function to compute the product, \(N\) +needs to be greater than or equal to 2; if equal to 2 then a trivial matrix-matrix product is returned. +If \(N\) is 1, then this is a no-op - the original matrix is returned as is.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3, 4)) +b = torch_randn(c(4, 5)) +c = torch_randn(c(5, 6)) +d = torch_randn(c(6, 7)) +torch_chain_matmul(list(a, b, c, d)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cholesky.html b/reference/torch_cholesky.html new file mode 100644 index 0000000000000000000000000000000000000000..d44bac00640168b256bcc249096f60407cb96708 --- /dev/null +++ b/reference/torch_cholesky.html @@ -0,0 +1,251 @@ + + + + + + + + +Cholesky — torch_cholesky • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cholesky

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor \(A\) of size \((*, n, n)\) where * is zero or more batch dimensions consisting of symmetric positive-definite matrices.

    upper

    (bool, optional) flag that indicates whether to return a upper or lower triangular matrix. Default: False

    out

    (Tensor, optional) the output matrix

    + +

    cholesky(input, upper=False, out=None) -> Tensor

    + + + + +

    Computes the Cholesky decomposition of a symmetric positive-definite +matrix \(A\) or for batches of symmetric positive-definite matrices.

    +

    If upper is True, the returned matrix U is upper-triangular, and +the decomposition has the form:

    +

    $$ + A = U^TU +$$ +If upper is False, the returned matrix L is lower-triangular, and +the decomposition has the form:

    +

    $$ + A = LL^T +$$ +If upper is True, and \(A\) is a batch of symmetric positive-definite +matrices, then the returned tensor will be composed of upper-triangular Cholesky factors +of each of the individual matrices. Similarly, when upper is False, the returned +tensor will be composed of lower-triangular Cholesky factors of each of the individual +matrices.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3, 3)) +a = torch_mm(a, a$t()) # make symmetric positive-definite +l = torch_cholesky(a) +a +l +torch_mm(l, l$t()) +a = torch_randn(c(3, 2, 2)) +if (FALSE) { +a = torch_matmul(a, a$transpose(-1, -2)) + 1e-03 # make symmetric positive-definite +l = torch_cholesky(a) +z = torch_matmul(l, l$transpose(-1, -2)) +torch_max(torch_abs(z - a)) # Max non-zero +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cholesky_inverse.html b/reference/torch_cholesky_inverse.html new file mode 100644 index 0000000000000000000000000000000000000000..3e1897e47da7d72b00d9df6aed832c282bbdc765 --- /dev/null +++ b/reference/torch_cholesky_inverse.html @@ -0,0 +1,242 @@ + + + + + + + + +Cholesky_inverse — torch_cholesky_inverse • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cholesky_inverse

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input 2-D tensor \(u\), a upper or lower triangular Cholesky factor

    upper

    (bool, optional) whether to return a lower (default) or upper triangular matrix

    out

    (Tensor, optional) the output tensor for inv

    + +

    cholesky_inverse(input, upper=False, out=None) -> Tensor

    + + + + +

    Computes the inverse of a symmetric positive-definite matrix \(A\) using its +Cholesky factor \(u\): returns matrix inv. The inverse is computed using +LAPACK routines dpotri and spotri (and the corresponding MAGMA routines).

    +

    If upper is False, \(u\) is lower triangular +such that the returned tensor is

    +

    $$ + inv = (uu^{{T}})^{{-1}} +$$ +If upper is True or not provided, \(u\) is upper +triangular such that the returned tensor is

    +

    $$ + inv = (u^T u)^{{-1}} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +if (FALSE) { +a = torch_randn(c(3, 3)) +a = torch_mm(a, a$t()) + 1e-05 * torch_eye(3) # make symmetric positive definite +u = torch_cholesky(a) +a +torch_cholesky_inverse(u) +a$inverse() +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cholesky_solve.html b/reference/torch_cholesky_solve.html new file mode 100644 index 0000000000000000000000000000000000000000..7f0e6adcaa8a0b8a2f87f443d47fb547ab9e3684 --- /dev/null +++ b/reference/torch_cholesky_solve.html @@ -0,0 +1,248 @@ + + + + + + + + +Cholesky_solve — torch_cholesky_solve • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cholesky_solve

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) input matrix \(b\) of size \((*, m, k)\), where \(*\) is zero or more batch dimensions

    input2

    (Tensor) input matrix \(u\) of size \((*, m, m)\), where \(*\) is zero of more batch dimensions composed of upper or lower triangular Cholesky factor

    upper

    (bool, optional) whether to consider the Cholesky factor as a lower or upper triangular matrix. Default: False.

    out

    (Tensor, optional) the output tensor for c

    + +

    cholesky_solve(input, input2, upper=False, out=None) -> Tensor

    + + + + +

    Solves a linear system of equations with a positive semidefinite +matrix to be inverted given its Cholesky factor matrix \(u\).

    +

    If upper is False, \(u\) is and lower triangular and c is +returned such that:

    +

    $$ + c = (u u^T)^{{-1}} b +$$ +If upper is True or not provided, \(u\) is upper triangular +and c is returned such that:

    +

    $$ + c = (u^T u)^{{-1}} b +$$ +torch_cholesky_solve(b, u) can take in 2D inputs b, u or inputs that are +batches of 2D matrices. If the inputs are batches, then returns +batched outputs c

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3, 3)) +a = torch_mm(a, a$t()) # make symmetric positive definite +u = torch_cholesky(a) +a +b = torch_randn(c(3, 2)) +b +torch_cholesky_solve(b, u) +torch_mm(a$inverse(), b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_chunk.html b/reference/torch_chunk.html new file mode 100644 index 0000000000000000000000000000000000000000..782ed0358334425ec18e56b3fdaf4e76a42d6f82 --- /dev/null +++ b/reference/torch_chunk.html @@ -0,0 +1,221 @@ + + + + + + + + +Chunk — torch_chunk • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Chunk

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to split

    chunks

    (int) number of chunks to return

    dim

    (int) dimension along which to split the tensor

    + +

    chunk(input, chunks, dim=0) -> List of Tensors

    + + + + +

    Splits a tensor into a specific number of chunks. Each chunk is a view of +the input tensor.

    +

    Last chunk will be smaller if the tensor size along the given dimension +dim is not divisible by chunks.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_clamp.html b/reference/torch_clamp.html new file mode 100644 index 0000000000000000000000000000000000000000..297f2b3dc452eca6bc5b1ad779cef730b19cfc07 --- /dev/null +++ b/reference/torch_clamp.html @@ -0,0 +1,270 @@ + + + + + + + + +Clamp — torch_clamp • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Clamp

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    min

    (Number) lower-bound of the range to be clamped to

    max

    (Number) upper-bound of the range to be clamped to

    out

    (Tensor, optional) the output tensor.

    value

    (Number) minimal value of each element in the output

    + +

    clamp(input, min, max, out=None) -> Tensor

    + + + + +

    Clamp all elements in input into the range [ min, max ] and return +a resulting tensor:

    +

    $$ + y_i = \left\{ \begin{array}{ll} + \mbox{min} & \mbox{if } x_i < \mbox{min} \\ + x_i & \mbox{if } \mbox{min} \leq x_i \leq \mbox{max} \\ + \mbox{max} & \mbox{if } x_i > \mbox{max} + \end{array} + \right. +$$ +If input is of type FloatTensor or DoubleTensor, args min +and max must be real numbers, otherwise they should be integers.

    +

    clamp(input, *, min, out=None) -> Tensor

    + + + + +

    Clamps all elements in input to be larger or equal min.

    +

    If input is of type FloatTensor or DoubleTensor, value +should be a real number, otherwise it should be an integer.

    +

    clamp(input, *, max, out=None) -> Tensor

    + + + + +

    Clamps all elements in input to be smaller or equal max.

    +

    If input is of type FloatTensor or DoubleTensor, value +should be a real number, otherwise it should be an integer.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_clamp(a, min=-0.5, max=0.5) + + +a = torch_randn(c(4)) +a +torch_clamp(a, min=0.5) + + +a = torch_randn(c(4)) +a +torch_clamp(a, max=0.5) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_combinations.html b/reference/torch_combinations.html new file mode 100644 index 0000000000000000000000000000000000000000..097a55822ca66ad707bb439a699e3b1e5b0beaed --- /dev/null +++ b/reference/torch_combinations.html @@ -0,0 +1,229 @@ + + + + + + + + +Combinations — torch_combinations • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Combinations

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) 1D vector.

    r

    (int, optional) number of elements to combine

    with_replacement

    (boolean, optional) whether to allow duplication in combination

    + +

    combinations(input, r=2, with_replacement=False) -> seq

    + + + + +

    Compute combinations of length \(r\) of the given tensor. The behavior is similar to +python's itertools.combinations when with_replacement is set to False, and +itertools.combinations_with_replacement when with_replacement is set to True.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = c(1, 2, 3) +tensor_a = torch_tensor(a) +torch_combinations(tensor_a) +torch_combinations(tensor_a, r=3) +torch_combinations(tensor_a, with_replacement=TRUE) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conj.html b/reference/torch_conj.html new file mode 100644 index 0000000000000000000000000000000000000000..f0ae46594696bbc67fe71c35af413aebe87a0a9e --- /dev/null +++ b/reference/torch_conj.html @@ -0,0 +1,223 @@ + + + + + + + + +Conj — torch_conj • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conj

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    conj(input, out=None) -> Tensor

    + + + + +

    Computes the element-wise conjugate of the given input tensor.

    +

    $$ + \mbox{out}_{i} = conj(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +torch_conj(torch_tensor(c(-1 + 1i, -2 + 2i, 3 - 3i))) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conv1d.html b/reference/torch_conv1d.html new file mode 100644 index 0000000000000000000000000000000000000000..07a0b312c79351705ca3f46730f878da7632ea6e --- /dev/null +++ b/reference/torch_conv1d.html @@ -0,0 +1,244 @@ + + + + + + + + +Conv1d — torch_conv1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conv1d

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iW)\)

    weight

    NA filters of shape \((\mbox{out\_channels} , \frac{\mbox{in\_channels}}{\mbox{groups}} , kW)\)

    bias

    NA optional bias of shape \((\mbox{out\_channels})\). Default: None

    stride

    NA the stride of the convolving kernel. Can be a single number or a one-element tuple (sW,). Default: 1

    padding

    NA implicit paddings on both sides of the input. Can be a single number or a one-element tuple (padW,). Default: 0

    dilation

    NA the spacing between kernel elements. Can be a single number or a one-element tuple (dW,). Default: 1

    groups

    NA split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

    + +

    conv1d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -> Tensor

    + + + + +

    Applies a 1D convolution over an input signal composed of several input +planes.

    +

    See ~torch.nn.Conv1d for details and output shape.

    +

    .. include:: cudnn_deterministic.rst

    + +

    Examples

    +
    if (torch_is_installed()) { + +filters = torch_randn(c(33, 16, 3)) +inputs = torch_randn(c(20, 16, 50)) +nnf_conv1d(inputs, filters) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conv2d.html b/reference/torch_conv2d.html new file mode 100644 index 0000000000000000000000000000000000000000..b18a4ff611d6fa86835855a06a801e2f31db6d6d --- /dev/null +++ b/reference/torch_conv2d.html @@ -0,0 +1,245 @@ + + + + + + + + +Conv2d — torch_conv2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conv2d

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iH , iW)\)

    weight

    NA filters of shape \((\mbox{out\_channels} , \frac{\mbox{in\_channels}}{\mbox{groups}} , kH , kW)\)

    bias

    NA optional bias tensor of shape \((\mbox{out\_channels})\). Default: None

    stride

    NA the stride of the convolving kernel. Can be a single number or a tuple (sH, sW). Default: 1

    padding

    NA implicit paddings on both sides of the input. Can be a single number or a tuple (padH, padW). Default: 0

    dilation

    NA the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1

    groups

    NA split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

    + +

    conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -> Tensor

    + + + + +

    Applies a 2D convolution over an input image composed of several input +planes.

    +

    See ~torch.nn.Conv2d for details and output shape.

    +

    .. include:: cudnn_deterministic.rst

    + +

    Examples

    +
    if (torch_is_installed()) { + +# With square kernels and equal stride +filters = torch_randn(c(8,4,3,3)) +inputs = torch_randn(c(1,4,5,5)) +nnf_conv2d(inputs, filters, padding=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conv3d.html b/reference/torch_conv3d.html new file mode 100644 index 0000000000000000000000000000000000000000..429e035b4bb48d4df6cbbcb8c620d4295eaa86da --- /dev/null +++ b/reference/torch_conv3d.html @@ -0,0 +1,244 @@ + + + + + + + + +Conv3d — torch_conv3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conv3d

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iT , iH , iW)\)

    weight

    NA filters of shape \((\mbox{out\_channels} , \frac{\mbox{in\_channels}}{\mbox{groups}} , kT , kH , kW)\)

    bias

    NA optional bias tensor of shape \((\mbox{out\_channels})\). Default: None

    stride

    NA the stride of the convolving kernel. Can be a single number or a tuple (sT, sH, sW). Default: 1

    padding

    NA implicit paddings on both sides of the input. Can be a single number or a tuple (padT, padH, padW). Default: 0

    dilation

    NA the spacing between kernel elements. Can be a single number or a tuple (dT, dH, dW). Default: 1

    groups

    NA split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

    + +

    conv3d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -> Tensor

    + + + + +

    Applies a 3D convolution over an input image composed of several input +planes.

    +

    See ~torch.nn.Conv3d for details and output shape.

    +

    .. include:: cudnn_deterministic.rst

    + +

    Examples

    +
    if (torch_is_installed()) { + +# filters = torch_randn(c(33, 16, 3, 3, 3)) +# inputs = torch_randn(c(20, 16, 50, 10, 20)) +# nnf_conv3d(inputs, filters) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conv_tbc.html b/reference/torch_conv_tbc.html new file mode 100644 index 0000000000000000000000000000000000000000..2c0e24b42814253a082ff3698bf4501038537c5d --- /dev/null +++ b/reference/torch_conv_tbc.html @@ -0,0 +1,223 @@ + + + + + + + + +Conv_tbc — torch_conv_tbc • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conv_tbc

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{sequence length} \times batch \times \mbox{in\_channels})\)

    weight

    NA filter of shape (\(\mbox{kernel width} \times \mbox{in\_channels} \times \mbox{out\_channels}\))

    bias

    NA bias of shape (\(\mbox{out\_channels}\))

    pad

    NA number of timesteps to pad. Default: 0

    + +

    TEST

    + + + + +

    Applies a 1-dimensional sequence convolution over an input sequence. +Input and output dimensions are (Time, Batch, Channels) - hence TBC.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conv_transpose1d.html b/reference/torch_conv_transpose1d.html new file mode 100644 index 0000000000000000000000000000000000000000..02bcbec3a5f95848a0d47498d2c3dc3fd0dfb2a5 --- /dev/null +++ b/reference/torch_conv_transpose1d.html @@ -0,0 +1,248 @@ + + + + + + + + +Conv_transpose1d — torch_conv_transpose1d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conv_transpose1d

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iW)\)

    weight

    NA filters of shape \((\mbox{in\_channels} , \frac{\mbox{out\_channels}}{\mbox{groups}} , kW)\)

    bias

    NA optional bias of shape \((\mbox{out\_channels})\). Default: None

    stride

    NA the stride of the convolving kernel. Can be a single number or a tuple (sW,). Default: 1

    padding

    NA dilation * (kernel_size - 1) - padding zero-padding will be added to both sides of each dimension in the input. Can be a single number or a tuple (padW,). Default: 0

    output_padding

    NA additional size added to one side of each dimension in the output shape. Can be a single number or a tuple (out_padW). Default: 0

    groups

    NA split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

    dilation

    NA the spacing between kernel elements. Can be a single number or a tuple (dW,). Default: 1

    + +

    conv_transpose1d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1) -> Tensor

    + + + + +

    Applies a 1D transposed convolution operator over an input signal +composed of several input planes, sometimes also called "deconvolution".

    +

    See ~torch.nn.ConvTranspose1d for details and output shape.

    +

    .. include:: cudnn_deterministic.rst

    + +

    Examples

    +
    if (torch_is_installed()) { + +inputs = torch_randn(c(20, 16, 50)) +weights = torch_randn(c(16, 33, 5)) +nnf_conv_transpose1d(inputs, weights) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conv_transpose2d.html b/reference/torch_conv_transpose2d.html new file mode 100644 index 0000000000000000000000000000000000000000..92c669cbd10fda4a294a5bae88af02c34413d565 --- /dev/null +++ b/reference/torch_conv_transpose2d.html @@ -0,0 +1,249 @@ + + + + + + + + +Conv_transpose2d — torch_conv_transpose2d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conv_transpose2d

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iH , iW)\)

    weight

    NA filters of shape \((\mbox{in\_channels} , \frac{\mbox{out\_channels}}{\mbox{groups}} , kH , kW)\)

    bias

    NA optional bias of shape \((\mbox{out\_channels})\). Default: None

    stride

    NA the stride of the convolving kernel. Can be a single number or a tuple (sH, sW). Default: 1

    padding

    NA dilation * (kernel_size - 1) - padding zero-padding will be added to both sides of each dimension in the input. Can be a single number or a tuple (padH, padW). Default: 0

    output_padding

    NA additional size added to one side of each dimension in the output shape. Can be a single number or a tuple (out_padH, out_padW). Default: 0

    groups

    NA split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

    dilation

    NA the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1

    + +

    conv_transpose2d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1) -> Tensor

    + + + + +

    Applies a 2D transposed convolution operator over an input image +composed of several input planes, sometimes also called "deconvolution".

    +

    See ~torch.nn.ConvTranspose2d for details and output shape.

    +

    .. include:: cudnn_deterministic.rst

    + +

    Examples

    +
    if (torch_is_installed()) { + +# With square kernels and equal stride +inputs = torch_randn(c(1, 4, 5, 5)) +weights = torch_randn(c(4, 8, 3, 3)) +nnf_conv_transpose2d(inputs, weights, padding=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_conv_transpose3d.html b/reference/torch_conv_transpose3d.html new file mode 100644 index 0000000000000000000000000000000000000000..a2262be647b82602ca65b3c194da2fe46d3e064b --- /dev/null +++ b/reference/torch_conv_transpose3d.html @@ -0,0 +1,249 @@ + + + + + + + + +Conv_transpose3d — torch_conv_transpose3d • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Conv_transpose3d

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iT , iH , iW)\)

    weight

    NA filters of shape \((\mbox{in\_channels} , \frac{\mbox{out\_channels}}{\mbox{groups}} , kT , kH , kW)\)

    bias

    NA optional bias of shape \((\mbox{out\_channels})\). Default: None

    stride

    NA the stride of the convolving kernel. Can be a single number or a tuple (sT, sH, sW). Default: 1

    padding

    NA dilation * (kernel_size - 1) - padding zero-padding will be added to both sides of each dimension in the input. Can be a single number or a tuple (padT, padH, padW). Default: 0

    output_padding

    NA additional size added to one side of each dimension in the output shape. Can be a single number or a tuple (out_padT, out_padH, out_padW). Default: 0

    groups

    NA split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

    dilation

    NA the spacing between kernel elements. Can be a single number or a tuple (dT, dH, dW). Default: 1

    + +

    conv_transpose3d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1) -> Tensor

    + + + + +

    Applies a 3D transposed convolution operator over an input image +composed of several input planes, sometimes also called "deconvolution"

    +

    See ~torch.nn.ConvTranspose3d for details and output shape.

    +

    .. include:: cudnn_deterministic.rst

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +inputs = torch_randn(c(20, 16, 50, 10, 20)) +weights = torch_randn(c(16, 33, 3, 3, 3)) +nnf_conv_transpose3d(inputs, weights) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cos.html b/reference/torch_cos.html new file mode 100644 index 0000000000000000000000000000000000000000..24aa918d04ed2fdab21bf96700e1ad86cfc3b839 --- /dev/null +++ b/reference/torch_cos.html @@ -0,0 +1,224 @@ + + + + + + + + +Cos — torch_cos • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cos

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    cos(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the cosine of the elements of input.

    +

    $$ + \mbox{out}_{i} = \cos(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_cos(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cosh.html b/reference/torch_cosh.html new file mode 100644 index 0000000000000000000000000000000000000000..4a3dc29cc5c276de8d9efae1338152f17c2711c1 --- /dev/null +++ b/reference/torch_cosh.html @@ -0,0 +1,225 @@ + + + + + + + + +Cosh — torch_cosh • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cosh

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    cosh(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the hyperbolic cosine of the elements of +input.

    +

    $$ + \mbox{out}_{i} = \cosh(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_cosh(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cosine_similarity.html b/reference/torch_cosine_similarity.html new file mode 100644 index 0000000000000000000000000000000000000000..1d1a6567d7fac3987e2b97dbc2fcb38ff81d35da --- /dev/null +++ b/reference/torch_cosine_similarity.html @@ -0,0 +1,233 @@ + + + + + + + + +Cosine_similarity — torch_cosine_similarity • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cosine_similarity

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    x1

    (Tensor) First input.

    x2

    (Tensor) Second input (of size matching x1).

    dim

    (int, optional) Dimension of vectors. Default: 1

    eps

    (float, optional) Small value to avoid division by zero. Default: 1e-8

    + +

    cosine_similarity(x1, x2, dim=1, eps=1e-8) -> Tensor

    + + + + +

    Returns cosine similarity between x1 and x2, computed along dim.

    +

    $$ + \mbox{similarity} = \frac{x_1 \cdot x_2}{\max(\Vert x_1 \Vert _2 \cdot \Vert x_2 \Vert _2, \epsilon)} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +input1 = torch_randn(c(100, 128)) +input2 = torch_randn(c(100, 128)) +output = torch_cosine_similarity(input1, input2) +output +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cross.html b/reference/torch_cross.html new file mode 100644 index 0000000000000000000000000000000000000000..21c3b82558e8ab2ec53f67b87381583d665b3557 --- /dev/null +++ b/reference/torch_cross.html @@ -0,0 +1,237 @@ + + + + + + + + +Cross — torch_cross • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cross

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    other

    (Tensor) the second input tensor

    dim

    (int, optional) the dimension to take the cross-product in.

    out

    (Tensor, optional) the output tensor.

    + +

    cross(input, other, dim=-1, out=None) -> Tensor

    + + + + +

    Returns the cross product of vectors in dimension dim of input +and other.

    +

    input and other must have the same size, and the size of their +dim dimension should be 3.

    +

    If dim is not given, it defaults to the first dimension found with the +size 3.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4, 3)) +a +b = torch_randn(c(4, 3)) +b +torch_cross(a, b, dim=2) +torch_cross(a, b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cummax.html b/reference/torch_cummax.html new file mode 100644 index 0000000000000000000000000000000000000000..25f05f400b59dbb78fb8a6e3e783545f46788380 --- /dev/null +++ b/reference/torch_cummax.html @@ -0,0 +1,230 @@ + + + + + + + + +Cummax — torch_cummax • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cummax

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to do the operation over

    out

    (tuple, optional) the result tuple of two output tensors (values, indices)

    + +

    cummax(input, dim, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns a namedtuple (values, indices) where values is the cumulative maximum of +elements of input in the dimension dim. And indices is the index +location of each maximum value found in the dimension dim.

    +

    $$ + y_i = max(x_1, x_2, x_3, \dots, x_i) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(10)) +a +torch_cummax(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cummin.html b/reference/torch_cummin.html new file mode 100644 index 0000000000000000000000000000000000000000..b68371da4b50066829befa560564e9377f029f6a --- /dev/null +++ b/reference/torch_cummin.html @@ -0,0 +1,230 @@ + + + + + + + + +Cummin — torch_cummin • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cummin

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to do the operation over

    out

    (tuple, optional) the result tuple of two output tensors (values, indices)

    + +

    cummin(input, dim, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns a namedtuple (values, indices) where values is the cumulative minimum of +elements of input in the dimension dim. And indices is the index +location of each maximum value found in the dimension dim.

    +

    $$ + y_i = min(x_1, x_2, x_3, \dots, x_i) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(10)) +a +torch_cummin(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cumprod.html b/reference/torch_cumprod.html new file mode 100644 index 0000000000000000000000000000000000000000..a6fc5f56b3306a2b15cf1bb1b8a71723d630e439 --- /dev/null +++ b/reference/torch_cumprod.html @@ -0,0 +1,235 @@ + + + + + + + + +Cumprod — torch_cumprod • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cumprod

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to do the operation over

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.

    out

    (Tensor, optional) the output tensor.

    + +

    cumprod(input, dim, out=None, dtype=None) -> Tensor

    + + + + +

    Returns the cumulative product of elements of input in the dimension +dim.

    +

    For example, if input is a vector of size N, the result will also be +a vector of size N, with elements.

    +

    $$ + y_i = x_1 \times x_2\times x_3\times \dots \times x_i +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(10)) +a +torch_cumprod(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_cumsum.html b/reference/torch_cumsum.html new file mode 100644 index 0000000000000000000000000000000000000000..d94b1332686b8a1132365872b37914cecd4dee13 --- /dev/null +++ b/reference/torch_cumsum.html @@ -0,0 +1,235 @@ + + + + + + + + +Cumsum — torch_cumsum • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Cumsum

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to do the operation over

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.

    out

    (Tensor, optional) the output tensor.

    + +

    cumsum(input, dim, out=None, dtype=None) -> Tensor

    + + + + +

    Returns the cumulative sum of elements of input in the dimension +dim.

    +

    For example, if input is a vector of size N, the result will also be +a vector of size N, with elements.

    +

    $$ + y_i = x_1 + x_2 + x_3 + \dots + x_i +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(10)) +a +torch_cumsum(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_det.html b/reference/torch_det.html new file mode 100644 index 0000000000000000000000000000000000000000..4dc2e269d4764226b4885d38595b0b82b9c374f9 --- /dev/null +++ b/reference/torch_det.html @@ -0,0 +1,228 @@ + + + + + + + + +Det — torch_det • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Det

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) the input tensor of size (*, n, n) where * is zero or more batch dimensions.

    + +

    Note

    + + +
    Backward through `det` internally uses SVD results when `input` is
    +not invertible. In this case, double backward through `det` will be
    +unstable in when `input` doesn't have distinct singular values. See
    +`~torch.svd` for details.
    +
    + +

    det(input) -> Tensor

    + + + + +

    Calculates determinant of a square matrix or batches of square matrices.

    + +

    Examples

    +
    if (torch_is_installed()) { + +A = torch_randn(c(3, 3)) +torch_det(A) +A = torch_randn(c(3, 2, 2)) +A +A$det() +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_device.html b/reference/torch_device.html new file mode 100644 index 0000000000000000000000000000000000000000..fdebe4611dc44b4f4177a5c81e3eeef68d391da4 --- /dev/null +++ b/reference/torch_device.html @@ -0,0 +1,229 @@ + + + + + + + + +Create a Device object — torch_device • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A torch_device is an object representing the device on which a torch_tensor +is or will be allocated.

    +
    + +
    torch_device(type, index = NULL)
    + +

    Arguments

    + + + + + + + + + + +
    type

    (character) a device type "cuda" or "cpu"

    index

    (integer) optional device ordinal for the device type. If the device ordinal +is not present, this object will always represent the current device for the device +type, even after torch_cuda_set_device() is called; e.g., a torch_tensor constructed +with device 'cuda' is equivalent to 'cuda:X' where X is the result of +torch_cuda_current_device().

    +

    A torch_device can be constructed via a string or via a string and device ordinal

    + + +

    Examples

    +
    if (torch_is_installed()) { + +# Via string +torch_device("cuda:1") +torch_device("cpu") +torch_device("cuda") # current cuda device + +# Via string and device ordinal +torch_device("cuda", 0) +torch_device("cpu", 0) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_diag.html b/reference/torch_diag.html new file mode 100644 index 0000000000000000000000000000000000000000..9c1f5b4d09a584ed922fb8188b0a2cb364afa117 --- /dev/null +++ b/reference/torch_diag.html @@ -0,0 +1,229 @@ + + + + + + + + +Diag — torch_diag • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Diag

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    diagonal

    (int, optional) the diagonal to consider

    out

    (Tensor, optional) the output tensor.

    + +

    diag(input, diagonal=0, out=None) -> Tensor

    + + + +
      +
    • If input is a vector (1-D tensor), then returns a 2-D square tensor +with the elements of input as the diagonal.

    • +
    • If input is a matrix (2-D tensor), then returns a 1-D tensor with +the diagonal elements of input.

    • +
    + +

    The argument diagonal controls which diagonal to consider:

      +
    • If diagonal = 0, it is the main diagonal.

    • +
    • If diagonal > 0, it is above the main diagonal.

    • +
    • If diagonal < 0, it is below the main diagonal.

    • +
    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_diag_embed.html b/reference/torch_diag_embed.html new file mode 100644 index 0000000000000000000000000000000000000000..8add904b695ac8686cf3f5ab44ce381a5b93a16a --- /dev/null +++ b/reference/torch_diag_embed.html @@ -0,0 +1,247 @@ + + + + + + + + +Diag_embed — torch_diag_embed • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Diag_embed

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor. Must be at least 1-dimensional.

    offset

    (int, optional) which diagonal to consider. Default: 0 (main diagonal).

    dim1

    (int, optional) first dimension with respect to which to take diagonal. Default: -2.

    dim2

    (int, optional) second dimension with respect to which to take diagonal. Default: -1.

    + +

    diag_embed(input, offset=0, dim1=-2, dim2=-1) -> Tensor

    + + + + +

    Creates a tensor whose diagonals of certain 2D planes (specified by +dim1 and dim2) are filled by input. +To facilitate creating batched diagonal matrices, the 2D planes formed by +the last two dimensions of the returned tensor are chosen by default.

    +

    The argument offset controls which diagonal to consider:

      +
    • If offset = 0, it is the main diagonal.

    • +
    • If offset > 0, it is above the main diagonal.

    • +
    • If offset < 0, it is below the main diagonal.

    • +
    + +

    The size of the new matrix will be calculated to make the specified diagonal +of the size of the last input dimension. +Note that for offset other than \(0\), the order of dim1 +and dim2 matters. Exchanging them is equivalent to changing the +sign of offset.

    +

    Applying torch_diagonal to the output of this function with +the same arguments yields a matrix identical to input. However, +torch_diagonal has different default dimensions, so those +need to be explicitly specified.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(2, 3)) +torch_diag_embed(a) +torch_diag_embed(a, offset=1, dim1=1, dim2=3) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_diagflat.html b/reference/torch_diagflat.html new file mode 100644 index 0000000000000000000000000000000000000000..cd27567e8d999738b27d476d0104e05a86fe327e --- /dev/null +++ b/reference/torch_diagflat.html @@ -0,0 +1,236 @@ + + + + + + + + +Diagflat — torch_diagflat • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Diagflat

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    offset

    (int, optional) the diagonal to consider. Default: 0 (main diagonal).

    + +

    diagflat(input, offset=0) -> Tensor

    + + + +
      +
    • If input is a vector (1-D tensor), then returns a 2-D square tensor +with the elements of input as the diagonal.

    • +
    • If input is a tensor with more than one dimension, then returns a +2-D tensor with diagonal elements equal to a flattened input.

    • +
    + +

    The argument offset controls which diagonal to consider:

      +
    • If offset = 0, it is the main diagonal.

    • +
    • If offset > 0, it is above the main diagonal.

    • +
    • If offset < 0, it is below the main diagonal.

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3)) +a +torch_diagflat(a) +torch_diagflat(a, 1) +a = torch_randn(c(2, 2)) +a +torch_diagflat(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_diagonal.html b/reference/torch_diagonal.html new file mode 100644 index 0000000000000000000000000000000000000000..b2c0e61d7fac5c3f550fb1b6bdd6ea8d1beafe75 --- /dev/null +++ b/reference/torch_diagonal.html @@ -0,0 +1,244 @@ + + + + + + + + +Diagonal — torch_diagonal • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Diagonal

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor. Must be at least 2-dimensional.

    offset

    (int, optional) which diagonal to consider. Default: 0 (main diagonal).

    dim1

    (int, optional) first dimension with respect to which to take diagonal. Default: 0.

    dim2

    (int, optional) second dimension with respect to which to take diagonal. Default: 1.

    + +

    diagonal(input, offset=0, dim1=0, dim2=1) -> Tensor

    + + + + +

    Returns a partial view of input with the its diagonal elements +with respect to dim1 and dim2 appended as a dimension +at the end of the shape.

    +

    The argument offset controls which diagonal to consider:

      +
    • If offset = 0, it is the main diagonal.

    • +
    • If offset > 0, it is above the main diagonal.

    • +
    • If offset < 0, it is below the main diagonal.

    • +
    + +

    Applying torch_diag_embed to the output of this function with +the same arguments yields a diagonal matrix with the diagonal entries +of the input. However, torch_diag_embed has different default +dimensions, so those need to be explicitly specified.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3, 3)) +a +torch_diagonal(a, offset = 0) +torch_diagonal(a, offset = 1) +x = torch_randn(c(2, 5, 4, 2)) +torch_diagonal(x, offset=-1, dim1=1, dim2=2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_digamma.html b/reference/torch_digamma.html new file mode 100644 index 0000000000000000000000000000000000000000..9a1e8482de0086ff2489c263ddcd5256e6669011 --- /dev/null +++ b/reference/torch_digamma.html @@ -0,0 +1,219 @@ + + + + + + + + +Digamma — torch_digamma • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Digamma

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) the tensor to compute the digamma function on

    + +

    digamma(input, out=None) -> Tensor

    + + + + +

    Computes the logarithmic derivative of the gamma function on input.

    +

    $$ + \psi(x) = \frac{d}{dx} \ln\left(\Gamma\left(x\right)\right) = \frac{\Gamma'(x)}{\Gamma(x)} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_tensor(c(1, 0.5)) +torch_digamma(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_dist.html b/reference/torch_dist.html new file mode 100644 index 0000000000000000000000000000000000000000..7394d3678ff5b267e97dc2b4e366ecea74b84643 --- /dev/null +++ b/reference/torch_dist.html @@ -0,0 +1,232 @@ + + + + + + + + +Dist — torch_dist • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Dist

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    other

    (Tensor) the Right-hand-side input tensor

    p

    (float, optional) the norm to be computed

    + +

    dist(input, other, p=2) -> Tensor

    + + + + +

    Returns the p-norm of (input - other)

    +

    The shapes of input and other must be +broadcastable .

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(4)) +x +y = torch_randn(c(4)) +y +torch_dist(x, y, 3.5) +torch_dist(x, y, 3) +torch_dist(x, y, 0) +torch_dist(x, y, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_div.html b/reference/torch_div.html new file mode 100644 index 0000000000000000000000000000000000000000..67d848442ea8a4785a56b72bd5e2ebdb0520889a --- /dev/null +++ b/reference/torch_div.html @@ -0,0 +1,260 @@ + + + + + + + + +Div — torch_div • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Div

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    other

    (Number) the number to be divided to each element of input

    + +

    div(input, other, out=None) -> Tensor

    + + + + +

    Divides each element of the input input with the scalar other and +returns a new resulting tensor.

    + + +

    Each element of the tensor input is divided by each element of the tensor +other. The resulting tensor is returned.

    +

    $$ + \mbox{out}_i = \frac{\mbox{input}_i}{\mbox{other}_i} +$$ +The shapes of input and other must be broadcastable +. If the torch_dtype of input and +other differ, the torch_dtype of the result tensor is determined +following rules described in the type promotion documentation +. If out is specified, the result must be +castable to the torch_dtype of the +specified output tensor. Integral division by zero leads to undefined behavior.

    +

    Warning

    + + + +

    Integer division using div is deprecated, and in a future release div will +perform true division like torch_true_divide. +Use torch_floor_divide (// in Python) to perform integer division, +instead.

    +

    $$ + \mbox{out}_i = \frac{\mbox{input}_i}{\mbox{other}} +$$ +If the torch_dtype of input and other differ, the +torch_dtype of the result tensor is determined following rules +described in the type promotion documentation . If +out is specified, the result must be castable +to the torch_dtype of the specified output tensor. Integral division +by zero leads to undefined behavior.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(5)) +a +torch_div(a, 0.5) + + +a = torch_randn(c(4, 4)) +a +b = torch_randn(c(4)) +b +torch_div(a, b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_dot.html b/reference/torch_dot.html new file mode 100644 index 0000000000000000000000000000000000000000..0a4c7f2ef7574e2b15ccd7134963f224b7ad534f --- /dev/null +++ b/reference/torch_dot.html @@ -0,0 +1,210 @@ + + + + + + + + +Dot — torch_dot • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Dot

    +
    + + + +

    Note

    + +

    This function does not broadcast .

    +

    dot(input, tensor) -> Tensor

    + + + + +

    Computes the dot product (inner product) of two tensors.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_dot(torch_tensor(c(2, 3)), torch_tensor(c(2, 1))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_dtype.html b/reference/torch_dtype.html new file mode 100644 index 0000000000000000000000000000000000000000..b43143e1231453f16070fa457fcf35ca103e2d99 --- /dev/null +++ b/reference/torch_dtype.html @@ -0,0 +1,231 @@ + + + + + + + + +Torch data types — torch_dtype • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Returns the correspondent data type.

    +
    + +
    torch_float32()
    +
    +torch_float()
    +
    +torch_float64()
    +
    +torch_double()
    +
    +torch_float16()
    +
    +torch_half()
    +
    +torch_uint8()
    +
    +torch_int8()
    +
    +torch_int16()
    +
    +torch_short()
    +
    +torch_int32()
    +
    +torch_int()
    +
    +torch_int64()
    +
    +torch_long()
    +
    +torch_bool()
    +
    +torch_quint8()
    +
    +torch_qint8()
    +
    +torch_qint32()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_eig.html b/reference/torch_eig.html new file mode 100644 index 0000000000000000000000000000000000000000..52f6392d8581906e391e6e070e5ab9a1c4102641 --- /dev/null +++ b/reference/torch_eig.html @@ -0,0 +1,225 @@ + + + + + + + + +Eig — torch_eig • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Eig

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the square matrix of shape \((n \times n)\) for which the eigenvalues and eigenvectors will be computed

    eigenvectors

    (bool) True to compute both eigenvalues and eigenvectors; otherwise, only eigenvalues will be computed

    out

    (tuple, optional) the output tensors

    + +

    Note

    + + +
    Since eigenvalues and eigenvectors might be complex, backward pass is supported only
    +for [`torch_symeig`]
    +
    + +

    eig(input, eigenvectors=False, out=None) -> (Tensor, Tensor)

    + + + + +

    Computes the eigenvalues and eigenvectors of a real square matrix.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_einsum.html b/reference/torch_einsum.html new file mode 100644 index 0000000000000000000000000000000000000000..9379dec6779ffba83c4329edb86365f2776a7b74 --- /dev/null +++ b/reference/torch_einsum.html @@ -0,0 +1,239 @@ + + + + + + + + +Einsum — torch_einsum • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Einsum

    +
    + + +

    Arguments

    + + + + + + + + + + +
    equation

    (string) The equation is given in terms of lower case letters (indices) to be associated with each dimension of the operands and result. The left hand side lists the operands dimensions, separated by commas. There should be one index letter per tensor dimension. The right hand side follows after -> and gives the indices for the output. If the -> and right hand side are omitted, it implicitly defined as the alphabetically sorted list of all indices appearing exactly once in the left hand side. The indices not apprearing in the output are summed over after multiplying the operands entries. If an index appears several times for the same operand, a diagonal is taken. Ellipses ... represent a fixed number of dimensions. If the right hand side is inferred, the ellipsis dimensions are at the beginning of the output.

    operands

    (Tensor) The operands to compute the Einstein sum of.

    + +

    einsum(equation, *operands) -> Tensor

    + + + + +

    This function provides a way of computing multilinear expressions (i.e. sums of products) using the +Einstein summation convention.

    + +

    Examples

    +
    if (torch_is_installed()) { + +if (FALSE) { + +x = torch_randn(c(5)) +y = torch_randn(c(4)) +torch_einsum('i,j->ij', list(x, y)) # outer product +A = torch_randn(c(3,5,4)) +l = torch_randn(c(2,5)) +r = torch_randn(c(2,4)) +torch_einsum('bn,anm,bm->ba', list(l, A, r)) # compare torch_nn$functional$bilinear +As = torch_randn(c(3,2,5)) +Bs = torch_randn(c(3,5,4)) +torch_einsum('bij,bjk->bik', list(As, Bs)) # batch matrix multiplication +A = torch_randn(c(3, 3)) +torch_einsum('ii->i', list(A)) # diagonal +A = torch_randn(c(4, 3, 3)) +torch_einsum('...ii->...i', list(A)) # batch diagonal +A = torch_randn(c(2, 3, 4, 5)) +torch_einsum('...ij->...ji', list(A))$shape # batch permute + +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_empty.html b/reference/torch_empty.html new file mode 100644 index 0000000000000000000000000000000000000000..56e3c1bce661d38a76d2e0739a497de72d2a2888 --- /dev/null +++ b/reference/torch_empty.html @@ -0,0 +1,244 @@ + + + + + + + + +Empty — torch_empty • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Empty

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    size

    (int...) a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    pin_memory

    (bool, optional) If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_contiguous_format.

    + +

    empty(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False, pin_memory=False) -> Tensor

    + + + + +

    Returns a tensor filled with uninitialized data. The shape of the tensor is +defined by the variable argument size.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_empty(c(2, 3)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_empty_like.html b/reference/torch_empty_like.html new file mode 100644 index 0000000000000000000000000000000000000000..f0b3d872bc25307d8c6443693be8f6b0ca22f3b0 --- /dev/null +++ b/reference/torch_empty_like.html @@ -0,0 +1,237 @@ + + + + + + + + +Empty_like — torch_empty_like • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Empty_like

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the size of input will determine size of the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned Tensor. Default: if None, defaults to the dtype of input.

    layout

    (torch.layout, optional) the desired layout of returned tensor. Default: if None, defaults to the layout of input.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, defaults to the device of input.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_preserve_format.

    + +

    empty_like(input, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor

    + + + + +

    Returns an uninitialized tensor with the same size as input. +torch_empty_like(input) is equivalent to +torch_empty(input.size(), dtype=input.dtype, layout=input.layout, device=input.device).

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_empty(list(2,3), dtype = torch_int64()) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_empty_strided.html b/reference/torch_empty_strided.html new file mode 100644 index 0000000000000000000000000000000000000000..64516692a5cf6b7d1bdfd3b7ec3e9d9f75b23e9b --- /dev/null +++ b/reference/torch_empty_strided.html @@ -0,0 +1,253 @@ + + + + + + + + +Empty_strided — torch_empty_strided • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Empty_strided

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    size

    (tuple of ints) the shape of the output tensor

    stride

    (tuple of ints) the strides of the output tensor

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    pin_memory

    (bool, optional) If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False.

    + +

    empty_strided(size, stride, dtype=None, layout=None, device=None, requires_grad=False, pin_memory=False) -> Tensor

    + + + + +

    Returns a tensor filled with uninitialized data. The shape and strides of the tensor is +defined by the variable argument size and stride respectively. +torch_empty_strided(size, stride) is equivalent to +torch_empty(size).as_strided(size, stride).

    +

    Warning

    + + + +

    More than one element of the created tensor may refer to a single memory +location. As a result, in-place operations (especially ones that are +vectorized) may result in incorrect behavior. If you need to write to +the tensors, please clone them first.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_empty_strided(list(2, 3), list(1, 2)) +a +a$stride(1) +a$size(1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_eq.html b/reference/torch_eq.html new file mode 100644 index 0000000000000000000000000000000000000000..372e848360fe7ce7d635ca25ee8dafa25d40151d --- /dev/null +++ b/reference/torch_eq.html @@ -0,0 +1,225 @@ + + + + + + + + +Eq — torch_eq • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Eq

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to compare

    other

    (Tensor or float) the tensor or value to compare

    out

    (Tensor, optional) the output tensor. Must be a ByteTensor

    + +

    eq(input, other, out=None) -> Tensor

    + + + + +

    Computes element-wise equality

    +

    The second argument can be a number or a tensor whose shape is +broadcastable with the first argument.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_eq(torch_tensor(c(1,2,3,4)), torch_tensor(c(1, 3, 2, 4))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_equal.html b/reference/torch_equal.html new file mode 100644 index 0000000000000000000000000000000000000000..f72cf4549d086a86028df187c676afe69f4e5c49 --- /dev/null +++ b/reference/torch_equal.html @@ -0,0 +1,207 @@ + + + + + + + + +Equal — torch_equal • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Equal

    +
    + + + +

    equal(input, other) -> bool

    + + + + +

    True if two tensors have the same size and elements, False otherwise.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_equal(torch_tensor(c(1, 2)), torch_tensor(c(1, 2))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_erf.html b/reference/torch_erf.html new file mode 100644 index 0000000000000000000000000000000000000000..fdacabb0f06ca9b0e85d3310a0f8eb9cdeb444ff --- /dev/null +++ b/reference/torch_erf.html @@ -0,0 +1,222 @@ + + + + + + + + +Erf — torch_erf • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Erf

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    erf(input, out=None) -> Tensor

    + + + + +

    Computes the error function of each element. The error function is defined as follows:

    +

    $$ + \mathrm{erf}(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_erf(torch_tensor(c(0, -1., 10.))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_erfc.html b/reference/torch_erfc.html new file mode 100644 index 0000000000000000000000000000000000000000..325ef9b4cc52b60313adb8087d77975ff7cfcf47 --- /dev/null +++ b/reference/torch_erfc.html @@ -0,0 +1,223 @@ + + + + + + + + +Erfc — torch_erfc • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Erfc

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    erfc(input, out=None) -> Tensor

    + + + + +

    Computes the complementary error function of each element of input. +The complementary error function is defined as follows:

    +

    $$ + \mathrm{erfc}(x) = 1 - \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_erfc(torch_tensor(c(0, -1., 10.))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_erfinv.html b/reference/torch_erfinv.html new file mode 100644 index 0000000000000000000000000000000000000000..a71224176eb2c77b2e9f30514ec15785cf020109 --- /dev/null +++ b/reference/torch_erfinv.html @@ -0,0 +1,223 @@ + + + + + + + + +Erfinv — torch_erfinv • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Erfinv

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    erfinv(input, out=None) -> Tensor

    + + + + +

    Computes the inverse error function of each element of input. +The inverse error function is defined in the range \((-1, 1)\) as:

    +

    $$ + \mathrm{erfinv}(\mathrm{erf}(x)) = x +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_erfinv(torch_tensor(c(0, 0.5, -1.))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_exp.html b/reference/torch_exp.html new file mode 100644 index 0000000000000000000000000000000000000000..2e7cf55ff43e969d123b1192223e9ae5ffed4b6d --- /dev/null +++ b/reference/torch_exp.html @@ -0,0 +1,223 @@ + + + + + + + + +Exp — torch_exp • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Exp

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    exp(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the exponential of the elements +of the input tensor input.

    +

    $$ + y_{i} = e^{x_{i}} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_exp(torch_tensor(c(0, log(2)))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_expm1.html b/reference/torch_expm1.html new file mode 100644 index 0000000000000000000000000000000000000000..54ba8162ea789a102e50880e1e132e7b4826aaf2 --- /dev/null +++ b/reference/torch_expm1.html @@ -0,0 +1,223 @@ + + + + + + + + +Expm1 — torch_expm1 • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Expm1

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    expm1(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the exponential of the elements minus 1 +of input.

    +

    $$ + y_{i} = e^{x_{i}} - 1 +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_expm1(torch_tensor(c(0, log(2)))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_eye.html b/reference/torch_eye.html new file mode 100644 index 0000000000000000000000000000000000000000..98f2632a4c527963055348331bd56e0352d6aeba --- /dev/null +++ b/reference/torch_eye.html @@ -0,0 +1,239 @@ + + + + + + + + +Eye — torch_eye • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Eye

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    n

    (int) the number of rows

    m

    (int, optional) the number of columns with default being n

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    eye(n, m=None, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a 2-D tensor with ones on the diagonal and zeros elsewhere.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_eye(3) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_fft.html b/reference/torch_fft.html new file mode 100644 index 0000000000000000000000000000000000000000..72128d8c7a2894fe1bec466d8aed169452b17d5d --- /dev/null +++ b/reference/torch_fft.html @@ -0,0 +1,265 @@ + + + + + + + + +Fft — torch_fft • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fft

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of at least signal_ndim + 1 dimensions

    signal_ndim

    (int) the number of dimensions in each signal. signal_ndim can only be 1, 2 or 3

    normalized

    (bool, optional) controls whether to return normalized results. Default: False

    + +

    Note

    + + +
    For CUDA tensors, an LRU cache is used for cuFFT plans to speed up
    +repeatedly running FFT methods on tensors of same geometry with same
    +configuration. See cufft-plan-cache for more details on how to
    +monitor and control the cache.
    +
    + +

    fft(input, signal_ndim, normalized=False) -> Tensor

    + + + + +

    Complex-to-complex Discrete Fourier Transform

    +

    This method computes the complex-to-complex discrete Fourier transform. +Ignoring the batch dimensions, it computes the following expression:

    +

    $$ + X[\omega_1, \dots, \omega_d] = + \sum_{n_1=0}^{N_1-1} \dots \sum_{n_d=0}^{N_d-1} x[n_1, \dots, n_d] + e^{-j\ 2 \pi \sum_{i=0}^d \frac{\omega_i n_i}{N_i}}, +$$ +where \(d\) = signal_ndim is number of dimensions for the +signal, and \(N_i\) is the size of signal dimension \(i\).

    +

    This method supports 1D, 2D and 3D complex-to-complex transforms, indicated +by signal_ndim. input must be a tensor with last dimension +of size 2, representing the real and imaginary components of complex +numbers, and should have at least signal_ndim + 1 dimensions with optionally +arbitrary number of leading batch dimensions. If normalized is set to +True, this normalizes the result by dividing it with +\(\sqrt{\prod_{i=1}^K N_i}\) so that the operator is unitary.

    +

    Returns the real and the imaginary parts together as one tensor of the same +shape of input.

    +

    The inverse of this function is torch_ifft.

    +

    Warning

    + + + +

    For CPU tensors, this method is currently only available with MKL. Use +torch_backends.mkl.is_available to check if MKL is installed.

    + +

    Examples

    +
    if (torch_is_installed()) { + +# unbatched 2D FFT +x = torch_randn(c(4, 3, 2)) +torch_fft(x, 2) +# batched 1D FFT +torch_fft(x, 1) +# arbitrary number of batch dimensions, 2D FFT +x = torch_randn(c(3, 3, 5, 5, 2)) +torch_fft(x, 2) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_finfo.html b/reference/torch_finfo.html new file mode 100644 index 0000000000000000000000000000000000000000..9231bf121f604cd1d2ca134933547dc37a550db8 --- /dev/null +++ b/reference/torch_finfo.html @@ -0,0 +1,207 @@ + + + + + + + + +Floating point type info — torch_finfo • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A list that represents the numerical properties of a +floating point torch.dtype

    +
    + +
    torch_finfo(dtype)
    + +

    Arguments

    + + + + + + +
    dtype

    dtype to check information

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_flatten.html b/reference/torch_flatten.html new file mode 100644 index 0000000000000000000000000000000000000000..2eb92ba1a2518ad8d5e52e550178110cbe22d804 --- /dev/null +++ b/reference/torch_flatten.html @@ -0,0 +1,225 @@ + + + + + + + + +Flatten — torch_flatten • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Flatten

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    start_dim

    (int) the first dim to flatten

    end_dim

    (int) the last dim to flatten

    + +

    flatten(input, start_dim=0, end_dim=-1) -> Tensor

    + + + + +

    Flattens a contiguous range of dims in a tensor.

    + +

    Examples

    +
    if (torch_is_installed()) { + +t = torch_tensor(matrix(c(1, 2), ncol = 2)) +torch_flatten(t) +torch_flatten(t, start_dim=2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_flip.html b/reference/torch_flip.html new file mode 100644 index 0000000000000000000000000000000000000000..fec28f9474e061337ada109d7a046f51313e5656 --- /dev/null +++ b/reference/torch_flip.html @@ -0,0 +1,221 @@ + + + + + + + + +Flip — torch_flip • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Flip

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dims

    (a list or tuple) axis to flip on

    + +

    flip(input, dims) -> Tensor

    + + + + +

    Reverse the order of a n-D tensor along given axis in dims.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_arange(0, 8)$view(c(2, 2, 2)) +x +torch_flip(x, c(1, 2)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_floor.html b/reference/torch_floor.html new file mode 100644 index 0000000000000000000000000000000000000000..6f87bba3194e315364d62a90c0531970062e9f1b --- /dev/null +++ b/reference/torch_floor.html @@ -0,0 +1,225 @@ + + + + + + + + +Floor — torch_floor • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Floor

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    floor(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the floor of the elements of input, +the largest integer less than or equal to each element.

    +

    $$ + \mbox{out}_{i} = \left\lfloor \mbox{input}_{i} \right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_floor(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_floor_divide.html b/reference/torch_floor_divide.html new file mode 100644 index 0000000000000000000000000000000000000000..a810401db2cc1437298c260f05ee4c88d6c66dde --- /dev/null +++ b/reference/torch_floor_divide.html @@ -0,0 +1,226 @@ + + + + + + + + +Floor_divide — torch_floor_divide • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Floor_divide

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the numerator tensor

    other

    (Tensor or Scalar) the denominator

    + +

    floor_divide(input, other, out=None) -> Tensor

    + + + + +

    Return the division of the inputs rounded down to the nearest integer. See torch_div +for type promotion and broadcasting rules.

    +

    $$ + \mbox{{out}}_i = \left\lfloor \frac{{\mbox{{input}}_i}}{{\mbox{{other}}_i}} \right\rfloor +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_tensor(c(4.0, 3.0)) +b = torch_tensor(c(2.0, 2.0)) +torch_floor_divide(a, b) +torch_floor_divide(a, 1.4) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_fmod.html b/reference/torch_fmod.html new file mode 100644 index 0000000000000000000000000000000000000000..ee4a12a21ec92a2ff9004c23c6619424f8cf9410 --- /dev/null +++ b/reference/torch_fmod.html @@ -0,0 +1,228 @@ + + + + + + + + +Fmod — torch_fmod • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Fmod

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the dividend

    other

    (Tensor or float) the divisor, which may be either a number or a tensor of the same shape as the dividend

    out

    (Tensor, optional) the output tensor.

    + +

    fmod(input, other, out=None) -> Tensor

    + + + + +

    Computes the element-wise remainder of division.

    +

    The dividend and divisor may contain both for integer and floating point +numbers. The remainder has the same sign as the dividend input.

    +

    When other is a tensor, the shapes of input and +other must be broadcastable .

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_fmod(torch_tensor(c(-3., -2, -1, 1, 2, 3)), 2) +torch_fmod(torch_tensor(c(1., 2, 3, 4, 5)), 1.5) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_frac.html b/reference/torch_frac.html new file mode 100644 index 0000000000000000000000000000000000000000..913a39289719e5f3dc243135726e4ae2a66c0278 --- /dev/null +++ b/reference/torch_frac.html @@ -0,0 +1,210 @@ + + + + + + + + +Frac — torch_frac • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Frac

    +
    + + + +

    frac(input, out=None) -> Tensor

    + + + + +

    Computes the fractional portion of each element in input.

    +

    $$ + \mbox{out}_{i} = \mbox{input}_{i} - \left\lfloor |\mbox{input}_{i}| \right\rfloor * \mbox{sgn}(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_frac(torch_tensor(c(1, 2.5, -3.2))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_full.html b/reference/torch_full.html new file mode 100644 index 0000000000000000000000000000000000000000..b93ea8f4ac79ec1b11c274822068e3396c8c6718 --- /dev/null +++ b/reference/torch_full.html @@ -0,0 +1,248 @@ + + + + + + + + +Full — torch_full • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Full

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    size

    (int...) a list, tuple, or torch_Size of integers defining the shape of the output tensor.

    fill_value

    NA the number to fill the output tensor with.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    full(size, fill_value, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a tensor of size size filled with fill_value.

    +

    Warning

    + + + +

    In PyTorch 1.5 a bool or integral fill_value will produce a warning if +dtype or out are not set. +In a future PyTorch release, when dtype and out are not set +a bool fill_value will return a tensor of torch.bool dtype, +and an integral fill_value will return a tensor of torch.long dtype.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_full(list(2, 3), 3.141592) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_full_like.html b/reference/torch_full_like.html new file mode 100644 index 0000000000000000000000000000000000000000..a2a9d61f01ca2c4797921384eca6923451ea6b63 --- /dev/null +++ b/reference/torch_full_like.html @@ -0,0 +1,237 @@ + + + + + + + + +Full_like — torch_full_like • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Full_like

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the size of input will determine size of the output tensor.

    fill_value

    NA the number to fill the output tensor with.

    dtype

    (torch.dtype, optional) the desired data type of returned Tensor. Default: if None, defaults to the dtype of input.

    layout

    (torch.layout, optional) the desired layout of returned tensor. Default: if None, defaults to the layout of input.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, defaults to the device of input.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_preserve_format.

    + +

    full_like(input, fill_value, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False,

    + + + + +

    memory_format=torch.preserve_format) -> Tensor

    +

    Returns a tensor with the same size as input filled with fill_value. +torch_full_like(input, fill_value) is equivalent to +torch_full(input.size(), fill_value, dtype=input.dtype, layout=input.layout, device=input.device).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_gather.html b/reference/torch_gather.html new file mode 100644 index 0000000000000000000000000000000000000000..21afedcf876aef460f5f64d57bb0cdec69ec8513 --- /dev/null +++ b/reference/torch_gather.html @@ -0,0 +1,241 @@ + + + + + + + + +Gather — torch_gather • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Gather

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the source tensor

    dim

    (int) the axis along which to index

    index

    (LongTensor) the indices of elements to gather

    out

    (Tensor, optional) the destination tensor

    sparse_grad

    (bool,optional) If True, gradient w.r.t. input will be a sparse tensor.

    + +

    gather(input, dim, index, out=None, sparse_grad=False) -> Tensor

    + + + + +

    Gathers values along an axis specified by dim.

    +

    For a 3-D tensor the output is specified by::

    out[i][j][k] = input[index[i][j][k]][j][k]  # if dim == 0
    +out[i][j][k] = input[i][index[i][j][k]][k]  # if dim == 1
    +out[i][j][k] = input[i][j][index[i][j][k]]  # if dim == 2
    + +

    If input is an n-dimensional tensor with size +\((x_0, x_1..., x_{i-1}, x_i, x_{i+1}, ..., x_{n-1})\) +and dim = i, then index must be an \(n\)-dimensional tensor with +size \((x_0, x_1, ..., x_{i-1}, y, x_{i+1}, ..., x_{n-1})\) where \(y \geq 1\) +and out will have the same size as index.

    + +

    Examples

    +
    if (torch_is_installed()) { + +t = torch_tensor(matrix(c(1,2,3,4), ncol = 2, byrow = TRUE)) +torch_gather(t, 2, torch_tensor(matrix(c(1,1,2,1), ncol = 2, byrow=TRUE), dtype = torch_int64())) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ge.html b/reference/torch_ge.html new file mode 100644 index 0000000000000000000000000000000000000000..a52af4ee8445bd5ddaaed633478c164b4106bc7f --- /dev/null +++ b/reference/torch_ge.html @@ -0,0 +1,226 @@ + + + + + + + + +Ge — torch_ge • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ge

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to compare

    other

    (Tensor or float) the tensor or value to compare

    out

    (Tensor, optional) the output tensor that must be a BoolTensor

    + +

    ge(input, other, out=None) -> Tensor

    + + + + +

    Computes \(\mbox{input} \geq \mbox{other}\) element-wise.

    +

    The second argument can be a number or a tensor whose shape is +broadcastable with the first argument.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_ge(torch_tensor(matrix(1:4, ncol = 2, byrow=TRUE)), + torch_tensor(matrix(c(1,1,4,4), ncol = 2, byrow=TRUE))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_generator.html b/reference/torch_generator.html new file mode 100644 index 0000000000000000000000000000000000000000..f16db5fa05ca51f6af4d6d917d3613276717dadd --- /dev/null +++ b/reference/torch_generator.html @@ -0,0 +1,212 @@ + + + + + + + + +Create a Generator object — torch_generator • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A torch_generator is an object which manages the state of the algorithm +that produces pseudo random numbers. Used as a keyword argument in many +In-place random sampling functions.

    +
    + +
    torch_generator()
    + + + +

    Examples

    +
    if (torch_is_installed()) { + +# Via string +generator <- torch_generator() +generator$current_seed() +generator$set_current_seed(1234567L) +generator$current_seed() + + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_geqrf.html b/reference/torch_geqrf.html new file mode 100644 index 0000000000000000000000000000000000000000..52292ec102ebd2f8324c9a5ed023a63de148cab0 --- /dev/null +++ b/reference/torch_geqrf.html @@ -0,0 +1,221 @@ + + + + + + + + +Geqrf — torch_geqrf • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Geqrf

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input matrix

    out

    (tuple, optional) the output tuple of (Tensor, Tensor)

    + +

    geqrf(input, out=None) -> (Tensor, Tensor)

    + + + + +

    This is a low-level function for calling LAPACK directly. This function +returns a namedtuple (a, tau) as defined in LAPACK documentation for geqrf_ .

    +

    You'll generally want to use torch_qr instead.

    +

    Computes a QR decomposition of input, but without constructing +\(Q\) and \(R\) as explicit separate matrices.

    +

    Rather, this directly calls the underlying LAPACK function ?geqrf +which produces a sequence of 'elementary reflectors'.

    +

    See LAPACK documentation for geqrf_ for further details.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ger.html b/reference/torch_ger.html new file mode 100644 index 0000000000000000000000000000000000000000..1f2c7a9687f1107cdebf8b1d202eca357f462214 --- /dev/null +++ b/reference/torch_ger.html @@ -0,0 +1,230 @@ + + + + + + + + +Ger — torch_ger • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ger

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) 1-D input vector

    vec2

    (Tensor) 1-D input vector

    out

    (Tensor, optional) optional output matrix

    + +

    Note

    + +

    This function does not broadcast .

    +

    ger(input, vec2, out=None) -> Tensor

    + + + + +

    Outer product of input and vec2. +If input is a vector of size \(n\) and vec2 is a vector of +size \(m\), then out must be a matrix of size \((n \times m)\).

    + +

    Examples

    +
    if (torch_is_installed()) { + +v1 = torch_arange(1., 5.) +v2 = torch_arange(1., 4.) +torch_ger(v1, v2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_gt.html b/reference/torch_gt.html new file mode 100644 index 0000000000000000000000000000000000000000..041c8a5f6a82c69b7362e5ea626113ddb0a48ab1 --- /dev/null +++ b/reference/torch_gt.html @@ -0,0 +1,226 @@ + + + + + + + + +Gt — torch_gt • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Gt

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to compare

    other

    (Tensor or float) the tensor or value to compare

    out

    (Tensor, optional) the output tensor that must be a BoolTensor

    + +

    gt(input, other, out=None) -> Tensor

    + + + + +

    Computes \(\mbox{input} > \mbox{other}\) element-wise.

    +

    The second argument can be a number or a tensor whose shape is +broadcastable with the first argument.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_gt(torch_tensor(matrix(1:4, ncol = 2, byrow=TRUE)), + torch_tensor(matrix(c(1,1,4,4), ncol = 2, byrow=TRUE))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_hamming_window.html b/reference/torch_hamming_window.html new file mode 100644 index 0000000000000000000000000000000000000000..922c0b934baa2a81ea06f851edf1dcd16c93d72d --- /dev/null +++ b/reference/torch_hamming_window.html @@ -0,0 +1,259 @@ + + + + + + + + +Hamming_window — torch_hamming_window • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Hamming_window

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    window_length

    (int) the size of returned window

    periodic

    (bool, optional) If True, returns a window to be used as periodic function. If False, return a symmetric window.

    alpha

    (float, optional) The coefficient \(\alpha\) in the equation above

    beta

    (float, optional) The coefficient \(\beta\) in the equation above

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type). Only floating point types are supported.

    layout

    (torch.layout, optional) the desired layout of returned window tensor. Only torch_strided (dense layout) is supported.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    Note

    + + +
    If `window_length` \eqn{=1}, the returned window contains a single value 1.
    +
    + +
    This is a generalized version of `torch_hann_window`.
    +
    + +

    hamming_window(window_length, periodic=True, alpha=0.54, beta=0.46, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Hamming window function.

    +

    $$ + w[n] = \alpha - \beta\ \cos \left( \frac{2 \pi n}{N - 1} \right), +$$ +where \(N\) is the full window size.

    +

    The input window_length is a positive integer controlling the +returned window size. periodic flag determines whether the returned +window trims off the last duplicate value from the symmetric window and is +ready to be used as a periodic window with functions like +torch_stft. Therefore, if periodic is true, the \(N\) in +above formula is in fact \(\mbox{window\_length} + 1\). Also, we always have +torch_hamming_window(L, periodic=True) equal to +torch_hamming_window(L + 1, periodic=False)[:-1]).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_hann_window.html b/reference/torch_hann_window.html new file mode 100644 index 0000000000000000000000000000000000000000..08e80de8539b113bc05bf59d5f1ce8431c2097ab --- /dev/null +++ b/reference/torch_hann_window.html @@ -0,0 +1,249 @@ + + + + + + + + +Hann_window — torch_hann_window • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Hann_window

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    window_length

    (int) the size of returned window

    periodic

    (bool, optional) If True, returns a window to be used as periodic function. If False, return a symmetric window.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type). Only floating point types are supported.

    layout

    (torch.layout, optional) the desired layout of returned window tensor. Only torch_strided (dense layout) is supported.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    Note

    + + +
    If `window_length` \eqn{=1}, the returned window contains a single value 1.
    +
    + +

    hann_window(window_length, periodic=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Hann window function.

    +

    $$ + w[n] = \frac{1}{2}\ \left[1 - \cos \left( \frac{2 \pi n}{N - 1} \right)\right] = + \sin^2 \left( \frac{\pi n}{N - 1} \right), +$$ +where \(N\) is the full window size.

    +

    The input window_length is a positive integer controlling the +returned window size. periodic flag determines whether the returned +window trims off the last duplicate value from the symmetric window and is +ready to be used as a periodic window with functions like +torch_stft. Therefore, if periodic is true, the \(N\) in +above formula is in fact \(\mbox{window\_length} + 1\). Also, we always have +torch_hann_window(L, periodic=True) equal to +torch_hann_window(L + 1, periodic=False)[:-1]).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_histc.html b/reference/torch_histc.html new file mode 100644 index 0000000000000000000000000000000000000000..a26e5d0646c4ee7c5a1f9719e0d1cddf882d308f --- /dev/null +++ b/reference/torch_histc.html @@ -0,0 +1,234 @@ + + + + + + + + +Histc — torch_histc • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Histc

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    bins

    (int) number of histogram bins

    min

    (int) lower end of the range (inclusive)

    max

    (int) upper end of the range (inclusive)

    out

    (Tensor, optional) the output tensor.

    + +

    histc(input, bins=100, min=0, max=0, out=None) -> Tensor

    + + + + +

    Computes the histogram of a tensor.

    +

    The elements are sorted into equal width bins between min and +max. If min and max are both zero, the minimum and +maximum values of the data are used.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_histc(torch_tensor(c(1., 2, 1)), bins=4, min=0, max=3) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ifft.html b/reference/torch_ifft.html new file mode 100644 index 0000000000000000000000000000000000000000..5a017422746092ab26f4e957da89b527ee0bab93 --- /dev/null +++ b/reference/torch_ifft.html @@ -0,0 +1,259 @@ + + + + + + + + +Ifft — torch_ifft • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ifft

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of at least signal_ndim + 1 dimensions

    signal_ndim

    (int) the number of dimensions in each signal. signal_ndim can only be 1, 2 or 3

    normalized

    (bool, optional) controls whether to return normalized results. Default: False

    + +

    Note

    + + +
    For CUDA tensors, an LRU cache is used for cuFFT plans to speed up
    +repeatedly running FFT methods on tensors of same geometry with same
    +configuration. See cufft-plan-cache for more details on how to
    +monitor and control the cache.
    +
    + +

    ifft(input, signal_ndim, normalized=False) -> Tensor

    + + + + +

    Complex-to-complex Inverse Discrete Fourier Transform

    +

    This method computes the complex-to-complex inverse discrete Fourier +transform. Ignoring the batch dimensions, it computes the following +expression:

    +

    $$ + X[\omega_1, \dots, \omega_d] = + \frac{1}{\prod_{i=1}^d N_i} \sum_{n_1=0}^{N_1-1} \dots \sum_{n_d=0}^{N_d-1} x[n_1, \dots, n_d] + e^{\ j\ 2 \pi \sum_{i=0}^d \frac{\omega_i n_i}{N_i}}, +$$ +where \(d\) = signal_ndim is number of dimensions for the +signal, and \(N_i\) is the size of signal dimension \(i\).

    +

    The argument specifications are almost identical with torch_fft. +However, if normalized is set to True, this instead returns the +results multiplied by \(\sqrt{\prod_{i=1}^d N_i}\), to become a unitary +operator. Therefore, to invert a torch_fft, the normalized +argument should be set identically for torch_fft.

    +

    Returns the real and the imaginary parts together as one tensor of the same +shape of input.

    +

    The inverse of this function is torch_fft.

    +

    Warning

    + + + +

    For CPU tensors, this method is currently only available with MKL. Use +torch_backends.mkl.is_available to check if MKL is installed.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(3, 3, 2)) +x +y = torch_fft(x, 2) +torch_ifft(y, 2) # recover x +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_iinfo.html b/reference/torch_iinfo.html new file mode 100644 index 0000000000000000000000000000000000000000..a0831c39ddf4a84ed79f38140b6c6adbf5efbf15 --- /dev/null +++ b/reference/torch_iinfo.html @@ -0,0 +1,207 @@ + + + + + + + + +Integer type info — torch_iinfo • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A list that represents the numerical properties of a integer +type.

    +
    + +
    torch_iinfo(dtype)
    + +

    Arguments

    + + + + + + +
    dtype

    dtype to get information from.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_imag.html b/reference/torch_imag.html new file mode 100644 index 0000000000000000000000000000000000000000..9f80c7a99287df775c5122d1797393850037fa35 --- /dev/null +++ b/reference/torch_imag.html @@ -0,0 +1,228 @@ + + + + + + + + +Imag — torch_imag • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Imag

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    imag(input, out=None) -> Tensor

    + + + + +

    Returns the imaginary part of the input tensor.

    +

    Warning

    + + + +

    Not yet implemented.

    +

    $$ + \mbox{out}_{i} = imag(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +torch_imag(torch_tensor(c(-1 + 1i, -2 + 2i, 3 - 3i))) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_index_select.html b/reference/torch_index_select.html new file mode 100644 index 0000000000000000000000000000000000000000..822e1f827583ce4dabe08b723486b4c5776bb97c --- /dev/null +++ b/reference/torch_index_select.html @@ -0,0 +1,241 @@ + + + + + + + + +Index_select — torch_index_select • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Index_select

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension in which we index

    index

    (LongTensor) the 1-D tensor containing the indices to index

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    The returned tensor does not use the same storage as the original +tensor. If out has a different shape than expected, we +silently change it to the correct shape, reallocating the underlying +storage if necessary.

    +

    index_select(input, dim, index, out=None) -> Tensor

    + + + + +

    Returns a new tensor which indexes the input tensor along dimension +dim using the entries in index which is a LongTensor.

    +

    The returned tensor has the same number of dimensions as the original tensor +(input). The dim\ th dimension has the same size as the length +of index; other dimensions have the same size as in the original tensor.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(3, 4)) +x +indices = torch_tensor(c(1, 3), dtype = torch_int64()) +torch_index_select(x, 1, indices) +torch_index_select(x, 2, indices) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_inverse.html b/reference/torch_inverse.html new file mode 100644 index 0000000000000000000000000000000000000000..8ed140865ffc13406170c0d0f910541527a913e3 --- /dev/null +++ b/reference/torch_inverse.html @@ -0,0 +1,238 @@ + + + + + + + + +Inverse — torch_inverse • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Inverse

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor of size \((*, n, n)\) where * is zero or more batch dimensions

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + + +
    Irrespective of the original strides, the returned tensors will be
    +transposed, i.e. with strides like `input.contiguous().transpose(-2, -1).stride()`
    +
    + +

    inverse(input, out=None) -> Tensor

    + + + + +

    Takes the inverse of the square matrix input. input can be batches +of 2D square tensors, in which case this function would return a tensor composed of +individual inverses.

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +x = torch_rand(c(4, 4)) +y = torch_inverse(x) +z = torch_mm(x, y) +z +torch_max(torch_abs(z - torch_eye(4))) # Max non-zero +# Batched inverse example +x = torch_randn(c(2, 3, 4, 4)) +y = torch_inverse(x) +z = torch_matmul(x, y) +torch_max(torch_abs(z - torch_eye(4)$expand_as(x))) # Max non-zero +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_irfft.html b/reference/torch_irfft.html new file mode 100644 index 0000000000000000000000000000000000000000..cdc3378c04e66db863e02c02ff7495c40c1db88a --- /dev/null +++ b/reference/torch_irfft.html @@ -0,0 +1,285 @@ + + + + + + + + +Irfft — torch_irfft • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Irfft

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of at least signal_ndim + 1 dimensions

    signal_ndim

    (int) the number of dimensions in each signal. signal_ndim can only be 1, 2 or 3

    normalized

    (bool, optional) controls whether to return normalized results. Default: False

    onesided

    (bool, optional) controls whether input was halfed to avoid redundancy, e.g., by torch_rfft(). Default: True

    signal_sizes

    (list or torch.Size, optional) the size of the original signal (without batch dimension). Default: None

    + +

    Note

    + + +
    Due to the conjugate symmetry, `input` do not need to contain the full
    +complex frequency values. Roughly half of the values will be sufficient, as
    +is the case when `input` is given by [`~torch.rfft`] with
    +``rfft(signal, onesided=True)``. In such case, set the `onesided`
    +argument of this method to ``True``. Moreover, the original signal shape
    +information can sometimes be lost, optionally set `signal_sizes` to be
    +the size of the original signal (without the batch dimensions if in batched
    +mode) to recover it with correct shape.
    +
    +Therefore, to invert an [torch_rfft()], the `normalized` and
    +`onesided` arguments should be set identically for [torch_irfft()],
    +and preferably a `signal_sizes` is given to avoid size mismatch. See the
    +example below for a case of size mismatch.
    +
    +See [torch_rfft()] for details on conjugate symmetry.
    +
    + +

    The inverse of this function is torch_rfft().

    +
    For CUDA tensors, an LRU cache is used for cuFFT plans to speed up
    +repeatedly running FFT methods on tensors of same geometry with same
    +configuration. See cufft-plan-cache for more details on how to
    +monitor and control the cache.
    +
    + +

    irfft(input, signal_ndim, normalized=False, onesided=True, signal_sizes=None) -> Tensor

    + + + + +

    Complex-to-real Inverse Discrete Fourier Transform

    +

    This method computes the complex-to-real inverse discrete Fourier transform. +It is mathematically equivalent with torch_ifft with differences only in +formats of the input and output.

    +

    The argument specifications are almost identical with torch_ifft. +Similar to torch_ifft, if normalized is set to True, +this normalizes the result by multiplying it with +\(\sqrt{\prod_{i=1}^K N_i}\) so that the operator is unitary, where +\(N_i\) is the size of signal dimension \(i\).

    +

    Warning

    + + + +

    Generally speaking, input to this function should contain values +following conjugate symmetry. Note that even if onesided is +True, often symmetry on some part is still needed. When this +requirement is not satisfied, the behavior of torch_irfft is +undefined. Since torch_autograd.gradcheck estimates numerical +Jacobian with point perturbations, torch_irfft will almost +certainly fail the check.

    + +

    For CPU tensors, this method is currently only available with MKL. Use +torch_backends.mkl.is_available to check if MKL is installed.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(4, 4)) +torch_rfft(x, 2, onesided=TRUE) +x = torch_randn(c(4, 5)) +torch_rfft(x, 2, onesided=TRUE) +y = torch_rfft(x, 2, onesided=TRUE) +torch_irfft(y, 2, onesided=TRUE, signal_sizes=c(4,5)) # recover x +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_is_complex.html b/reference/torch_is_complex.html new file mode 100644 index 0000000000000000000000000000000000000000..d587f5c9f904ea0150e9cafeb9b8e43dd9461aa6 --- /dev/null +++ b/reference/torch_is_complex.html @@ -0,0 +1,211 @@ + + + + + + + + +Is_complex — torch_is_complex • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Is_complex

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) the PyTorch tensor to test

    + +

    is_complex(input) -> (bool)

    + + + + +

    Returns True if the data type of input is a complex data type i.e., +one of torch_complex64, and torch.complex128.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_is_floating_point.html b/reference/torch_is_floating_point.html new file mode 100644 index 0000000000000000000000000000000000000000..eb4c5990a48390dfc3e676458e01ab46b14d62e8 --- /dev/null +++ b/reference/torch_is_floating_point.html @@ -0,0 +1,211 @@ + + + + + + + + +Is_floating_point — torch_is_floating_point • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Is_floating_point

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) the PyTorch tensor to test

    + +

    is_floating_point(input) -> (bool)

    + + + + +

    Returns True if the data type of input is a floating point data type i.e., +one of torch_float64, torch.float32 and torch.float16.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_is_installed.html b/reference/torch_is_installed.html new file mode 100644 index 0000000000000000000000000000000000000000..1089b25c5bc992b361b4d0107bd32dc480f7ee3f --- /dev/null +++ b/reference/torch_is_installed.html @@ -0,0 +1,197 @@ + + + + + + + + +Verifies if torch is installed — torch_is_installed • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Verifies if torch is installed

    +
    + +
    torch_is_installed()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_isfinite.html b/reference/torch_isfinite.html new file mode 100644 index 0000000000000000000000000000000000000000..0ede72b832c05ea306a0863a7aa5c95739674b9b --- /dev/null +++ b/reference/torch_isfinite.html @@ -0,0 +1,215 @@ + + + + + + + + +Isfinite — torch_isfinite • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Isfinite

    +
    + + +

    Arguments

    + + + + + + +
    tensor

    (Tensor) A tensor to check

    + +

    TEST

    + + + + +

    Returns a new tensor with boolean elements representing if each element is Finite or not.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_isfinite(torch_tensor(c(1, Inf, 2, -Inf, NaN))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_isinf.html b/reference/torch_isinf.html new file mode 100644 index 0000000000000000000000000000000000000000..ea14b5955feec8600089055edcca816bd1bc5a21 --- /dev/null +++ b/reference/torch_isinf.html @@ -0,0 +1,215 @@ + + + + + + + + +Isinf — torch_isinf • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Isinf

    +
    + + +

    Arguments

    + + + + + + +
    tensor

    (Tensor) A tensor to check

    + +

    TEST

    + + + + +

    Returns a new tensor with boolean elements representing if each element is +/-INF or not.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_isinf(torch_tensor(c(1, Inf, 2, -Inf, NaN))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_isnan.html b/reference/torch_isnan.html new file mode 100644 index 0000000000000000000000000000000000000000..1073fb0d60453ef1f5699e1f9807f05bf2161c18 --- /dev/null +++ b/reference/torch_isnan.html @@ -0,0 +1,215 @@ + + + + + + + + +Isnan — torch_isnan • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Isnan

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) A tensor to check

    + +

    TEST

    + + + + +

    Returns a new tensor with boolean elements representing if each element is NaN or not.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_isnan(torch_tensor(c(1, NaN, 2))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_kthvalue.html b/reference/torch_kthvalue.html new file mode 100644 index 0000000000000000000000000000000000000000..02ad2db1e4b5b94ff5d33d550b9de96ccedeaa0b --- /dev/null +++ b/reference/torch_kthvalue.html @@ -0,0 +1,244 @@ + + + + + + + + +Kthvalue — torch_kthvalue • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Kthvalue

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    k

    (int) k for the k-th smallest element

    dim

    (int, optional) the dimension to find the kth value along

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (tuple, optional) the output tuple of (Tensor, LongTensor) can be optionally given to be used as output buffers

    + +

    kthvalue(input, k, dim=None, keepdim=False, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns a namedtuple (values, indices) where values is the k th +smallest element of each row of the input tensor in the given dimension +dim. And indices is the index location of each element found.

    +

    If dim is not given, the last dimension of the input is chosen.

    +

    If keepdim is True, both the values and indices tensors +are the same size as input, except in the dimension dim where +they are of size 1. Otherwise, dim is squeezed +(see torch_squeeze), resulting in both the values and +indices tensors having 1 fewer dimension than the input tensor.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_arange(1., 6.) +x +torch_kthvalue(x, 4) +x=torch_arange(1.,7.)$resize_(c(2,3)) +x +torch_kthvalue(x, 2, 1, TRUE) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_layout.html b/reference/torch_layout.html new file mode 100644 index 0000000000000000000000000000000000000000..b29d3c16d5feb735e67595274abdbafc3ab45568 --- /dev/null +++ b/reference/torch_layout.html @@ -0,0 +1,199 @@ + + + + + + + + +Creates the corresponding layout — torch_layout • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates the corresponding layout

    +
    + +
    torch_strided()
    +
    +torch_sparse_coo()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_le.html b/reference/torch_le.html new file mode 100644 index 0000000000000000000000000000000000000000..75f36495520a741d1ae508a18eabd2192c20a5e0 --- /dev/null +++ b/reference/torch_le.html @@ -0,0 +1,226 @@ + + + + + + + + +Le — torch_le • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Le

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to compare

    other

    (Tensor or float) the tensor or value to compare

    out

    (Tensor, optional) the output tensor that must be a BoolTensor

    + +

    le(input, other, out=None) -> Tensor

    + + + + +

    Computes \(\mbox{input} \leq \mbox{other}\) element-wise.

    +

    The second argument can be a number or a tensor whose shape is +broadcastable with the first argument.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_le(torch_tensor(matrix(1:4, ncol = 2, byrow=TRUE)), + torch_tensor(matrix(c(1,1,4,4), ncol = 2, byrow=TRUE))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_lerp.html b/reference/torch_lerp.html new file mode 100644 index 0000000000000000000000000000000000000000..d84cdc0ff3faffc5b4ced7df142becf464c1f363 --- /dev/null +++ b/reference/torch_lerp.html @@ -0,0 +1,239 @@ + + + + + + + + +Lerp — torch_lerp • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Lerp

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor with the starting points

    end

    (Tensor) the tensor with the ending points

    weight

    (float or tensor) the weight for the interpolation formula

    out

    (Tensor, optional) the output tensor.

    + +

    lerp(input, end, weight, out=None)

    + + + + +

    Does a linear interpolation of two tensors start (given by input) and end based +on a scalar or tensor weight and returns the resulting out tensor.

    +

    $$ + \mbox{out}_i = \mbox{start}_i + \mbox{weight}_i \times (\mbox{end}_i - \mbox{start}_i) +$$ +The shapes of start and end must be +broadcastable . If weight is a tensor, then +the shapes of weight, start, and end must be broadcastable .

    + +

    Examples

    +
    if (torch_is_installed()) { + +start = torch_arange(1., 5.) +end = torch_empty(4)$fill_(10) +start +end +torch_lerp(start, end, 0.5) +torch_lerp(start, end, torch_full_like(start, 0.5)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_lgamma.html b/reference/torch_lgamma.html new file mode 100644 index 0000000000000000000000000000000000000000..a47be6b845d9d333c9fcee819af934c5c3bea279 --- /dev/null +++ b/reference/torch_lgamma.html @@ -0,0 +1,223 @@ + + + + + + + + +Lgamma — torch_lgamma • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Lgamma

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    lgamma(input, out=None) -> Tensor

    + + + + +

    Computes the logarithm of the gamma function on input.

    +

    $$ + \mbox{out}_{i} = \log \Gamma(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_arange(0.5, 2, 0.5) +torch_lgamma(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_linspace.html b/reference/torch_linspace.html new file mode 100644 index 0000000000000000000000000000000000000000..b54e612cf96380ab8427b8e42ed17f0582f5b32c --- /dev/null +++ b/reference/torch_linspace.html @@ -0,0 +1,248 @@ + + + + + + + + +Linspace — torch_linspace • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Linspace

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    start

    (float) the starting value for the set of points

    end

    (float) the ending value for the set of points

    steps

    (int) number of points to sample between start and end. Default: 100.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    linspace(start, end, steps=100, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a one-dimensional tensor of steps +equally spaced points between start and end.

    +

    The output tensor is 1-D of size steps.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_linspace(3, 10, steps=5) +torch_linspace(-10, 10, steps=5) +torch_linspace(start=-10, end=10, steps=5) +torch_linspace(start=-10, end=10, steps=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_load.html b/reference/torch_load.html new file mode 100644 index 0000000000000000000000000000000000000000..31471fb05607f427a04e9816ed78d7e6a9fdd010 --- /dev/null +++ b/reference/torch_load.html @@ -0,0 +1,209 @@ + + + + + + + + +Loads a saved object — torch_load • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Loads a saved object

    +
    + +
    torch_load(path)
    + +

    Arguments

    + + + + + + +
    path

    a path to the saved object

    + +

    See also

    + +

    Other torch_save: +torch_save()

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_log.html b/reference/torch_log.html new file mode 100644 index 0000000000000000000000000000000000000000..2e0c86dad55e5bd0a23e30bc986fe611870161bb --- /dev/null +++ b/reference/torch_log.html @@ -0,0 +1,225 @@ + + + + + + + + +Log — torch_log • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Log

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    log(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the natural logarithm of the elements +of input.

    +

    $$ + y_{i} = \log_{e} (x_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(5)) +a +torch_log(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_log10.html b/reference/torch_log10.html new file mode 100644 index 0000000000000000000000000000000000000000..3951e04bad166e61be4c5f0d4f77ca4d3247e53c --- /dev/null +++ b/reference/torch_log10.html @@ -0,0 +1,225 @@ + + + + + + + + +Log10 — torch_log10 • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Log10

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    log10(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the logarithm to the base 10 of the elements +of input.

    +

    $$ + y_{i} = \log_{10} (x_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_rand(5) +a +torch_log10(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_log1p.html b/reference/torch_log1p.html new file mode 100644 index 0000000000000000000000000000000000000000..c0cb2f3833eb38dfb2c44d22e67438b0f0614ea4 --- /dev/null +++ b/reference/torch_log1p.html @@ -0,0 +1,228 @@ + + + + + + + + +Log1p — torch_log1p • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Log1p

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    This function is more accurate than torch_log for small +values of input

    +

    log1p(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the natural logarithm of (1 + input).

    +

    $$ + y_i = \log_{e} (x_i + 1) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(5)) +a +torch_log1p(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_log2.html b/reference/torch_log2.html new file mode 100644 index 0000000000000000000000000000000000000000..e310004a59ad1d1ed860650d14845f135eb39e93 --- /dev/null +++ b/reference/torch_log2.html @@ -0,0 +1,225 @@ + + + + + + + + +Log2 — torch_log2 • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Log2

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    log2(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the logarithm to the base 2 of the elements +of input.

    +

    $$ + y_{i} = \log_{2} (x_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_rand(5) +a +torch_log2(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_logdet.html b/reference/torch_logdet.html new file mode 100644 index 0000000000000000000000000000000000000000..dc91f18031fb3c062a8f229cf052b3f4a9771128 --- /dev/null +++ b/reference/torch_logdet.html @@ -0,0 +1,233 @@ + + + + + + + + +Logdet — torch_logdet • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Logdet

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) the input tensor of size (*, n, n) where * is zero or more batch dimensions.

    + +

    Note

    + + +
    Result is ``-inf`` if `input` has zero log determinant, and is ``nan`` if
    +`input` has negative determinant.
    +
    + +
    Backward through `logdet` internally uses SVD results when `input`
    +is not invertible. In this case, double backward through `logdet` will
    +be unstable in when `input` doesn't have distinct singular values. See
    +`~torch.svd` for details.
    +
    + +

    logdet(input) -> Tensor

    + + + + +

    Calculates log determinant of a square matrix or batches of square matrices.

    + +

    Examples

    +
    if (torch_is_installed()) { + +A = torch_randn(c(3, 3)) +torch_det(A) +torch_logdet(A) +A +A$det() +A$det()$log() +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_logical_and.html b/reference/torch_logical_and.html new file mode 100644 index 0000000000000000000000000000000000000000..ec06ac730e91e14a3d32e99b2eeaf7be8ca70b62 --- /dev/null +++ b/reference/torch_logical_and.html @@ -0,0 +1,230 @@ + + + + + + + + +Logical_and — torch_logical_and • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Logical_and

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    other

    (Tensor) the tensor to compute AND with

    out

    (Tensor, optional) the output tensor.

    + +

    logical_and(input, other, out=None) -> Tensor

    + + + + +

    Computes the element-wise logical AND of the given input tensors. Zeros are treated as False and nonzeros are +treated as True.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_logical_and(torch_tensor(c(TRUE, FALSE, TRUE)), torch_tensor(c(TRUE, FALSE, FALSE))) +a = torch_tensor(c(0, 1, 10, 0), dtype=torch_int8()) +b = torch_tensor(c(4, 0, 1, 0), dtype=torch_int8()) +torch_logical_and(a, b) +if (FALSE) { +torch_logical_and(a, b, out=torch_empty(4, dtype=torch_bool())) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_logical_not.html b/reference/torch_logical_not.html new file mode 100644 index 0000000000000000000000000000000000000000..d21c26aeead3224d6bd8791fa7ec02bc5983c876 --- /dev/null +++ b/reference/torch_logical_not.html @@ -0,0 +1,222 @@ + + + + + + + + +Logical_not — torch_logical_not • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Logical_not

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    logical_not(input, out=None) -> Tensor

    + + + + +

    Computes the element-wise logical NOT of the given input tensor. If not specified, the output tensor will have the bool +dtype. If the input tensor is not a bool tensor, zeros are treated as False and non-zeros are treated as True.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_logical_not(torch_tensor(c(TRUE, FALSE))) +torch_logical_not(torch_tensor(c(0, 1, -10), dtype=torch_int8())) +torch_logical_not(torch_tensor(c(0., 1.5, -10.), dtype=torch_double())) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_logical_or.html b/reference/torch_logical_or.html new file mode 100644 index 0000000000000000000000000000000000000000..b825759ba788de32f5be1489bf7bed9c753ec327 --- /dev/null +++ b/reference/torch_logical_or.html @@ -0,0 +1,232 @@ + + + + + + + + +Logical_or — torch_logical_or • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Logical_or

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    other

    (Tensor) the tensor to compute OR with

    out

    (Tensor, optional) the output tensor.

    + +

    logical_or(input, other, out=None) -> Tensor

    + + + + +

    Computes the element-wise logical OR of the given input tensors. Zeros are treated as False and nonzeros are +treated as True.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_logical_or(torch_tensor(c(TRUE, FALSE, TRUE)), torch_tensor(c(TRUE, FALSE, FALSE))) +a = torch_tensor(c(0, 1, 10, 0), dtype=torch_int8()) +b = torch_tensor(c(4, 0, 1, 0), dtype=torch_int8()) +torch_logical_or(a, b) +if (FALSE) { +torch_logical_or(a$double(), b$double()) +torch_logical_or(a$double(), b) +torch_logical_or(a, b, out=torch_empty(4, dtype=torch_bool())) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_logical_xor.html b/reference/torch_logical_xor.html new file mode 100644 index 0000000000000000000000000000000000000000..3c9ea182f76a4bac8b8e815f6289b5524a1eb2c0 --- /dev/null +++ b/reference/torch_logical_xor.html @@ -0,0 +1,229 @@ + + + + + + + + +Logical_xor — torch_logical_xor • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Logical_xor

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    other

    (Tensor) the tensor to compute XOR with

    out

    (Tensor, optional) the output tensor.

    + +

    logical_xor(input, other, out=None) -> Tensor

    + + + + +

    Computes the element-wise logical XOR of the given input tensors. Zeros are treated as False and nonzeros are +treated as True.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_logical_xor(torch_tensor(c(TRUE, FALSE, TRUE)), torch_tensor(c(TRUE, FALSE, FALSE))) +a = torch_tensor(c(0, 1, 10, 0), dtype=torch_int8()) +b = torch_tensor(c(4, 0, 1, 0), dtype=torch_int8()) +torch_logical_xor(a, b) +torch_logical_xor(a$to(dtype=torch_double()), b$to(dtype=torch_double())) +torch_logical_xor(a$to(dtype=torch_double()), b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_logspace.html b/reference/torch_logspace.html new file mode 100644 index 0000000000000000000000000000000000000000..60b7755749e5664a01fc0698475c2b90ab66382f --- /dev/null +++ b/reference/torch_logspace.html @@ -0,0 +1,253 @@ + + + + + + + + +Logspace — torch_logspace • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Logspace

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    start

    (float) the starting value for the set of points

    end

    (float) the ending value for the set of points

    steps

    (int) number of points to sample between start and end. Default: 100.

    base

    (float) base of the logarithm function. Default: 10.0.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    logspace(start, end, steps=100, base=10.0, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a one-dimensional tensor of steps points +logarithmically spaced with base base between +\({\mbox{base}}^{\mbox{start}}\) and \({\mbox{base}}^{\mbox{end}}\).

    +

    The output tensor is 1-D of size steps.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_logspace(start=-10, end=10, steps=5) +torch_logspace(start=0.1, end=1.0, steps=5) +torch_logspace(start=0.1, end=1.0, steps=1) +torch_logspace(start=2, end=2, steps=1, base=2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_logsumexp.html b/reference/torch_logsumexp.html new file mode 100644 index 0000000000000000000000000000000000000000..e770f51b0fb5e5d92816b17f63245a407d6afe38 --- /dev/null +++ b/reference/torch_logsumexp.html @@ -0,0 +1,238 @@ + + + + + + + + +Logsumexp — torch_logsumexp • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Logsumexp

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int or tuple of ints) the dimension or dimensions to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (Tensor, optional) the output tensor.

    + +

    logsumexp(input, dim, keepdim=False, out=None)

    + + + + +

    Returns the log of summed exponentials of each row of the input +tensor in the given dimension dim. The computation is numerically +stabilized.

    +

    For summation index \(j\) given by dim and other indices \(i\), the result is

    +

    $$ + \mbox{logsumexp}(x)_{i} = \log \sum_j \exp(x_{ij}) +$$

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension(s) dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in the +output tensor having 1 (or len(dim)) fewer dimension(s).

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3, 3)) +torch_logsumexp(a, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_lstsq.html b/reference/torch_lstsq.html new file mode 100644 index 0000000000000000000000000000000000000000..a3a89b6da3138fa44dab1d45da4f9ec538e4eb67 --- /dev/null +++ b/reference/torch_lstsq.html @@ -0,0 +1,262 @@ + + + + + + + + +Lstsq — torch_lstsq • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Lstsq

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the matrix \(B\)

    A

    (Tensor) the \(m\) by \(n\) matrix \(A\)

    out

    (tuple, optional) the optional destination tensor

    + +

    Note

    + + +
    The case when \eqn{m &lt; n} is not supported on the GPU.
    +
    + +

    lstsq(input, A, out=None) -> Tensor

    + + + + +

    Computes the solution to the least squares and least norm problems for a full +rank matrix \(A\) of size \((m \times n)\) and a matrix \(B\) of +size \((m \times k)\).

    +

    If \(m \geq n\), torch_lstsq() solves the least-squares problem:

    +

    $$ + \begin{array}{ll} + \min_X & \|AX-B\|_2. + \end{array} +$$ +If \(m < n\), torch_lstsq() solves the least-norm problem:

    +

    $$ + \begin{array}{llll} + \min_X & \|X\|_2 & \mbox{subject to} & AX = B. + \end{array} +$$ +Returned tensor \(X\) has shape \((\mbox{max}(m, n) \times k)\). The first \(n\) +rows of \(X\) contains the solution. If \(m \geq n\), the residual sum of squares +for the solution in each column is given by the sum of squares of elements in the +remaining \(m - n\) rows of that column.

    + +

    Examples

    +
    if (torch_is_installed()) { + +A = torch_tensor(rbind( + c(1,1,1), + c(2,3,4), + c(3,5,2), + c(4,2,5), + c(5,4,3) +)) +B = torch_tensor(rbind( + c(-10, -3), + c(12, 14), + c(14, 12), + c(16, 16), + c(18, 16) +)) +out = torch_lstsq(B, A) +out[[1]] +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_lt.html b/reference/torch_lt.html new file mode 100644 index 0000000000000000000000000000000000000000..b6ed4a3f8a7564787a84ddf1637de349ff57dc28 --- /dev/null +++ b/reference/torch_lt.html @@ -0,0 +1,226 @@ + + + + + + + + +Lt — torch_lt • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Lt

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to compare

    other

    (Tensor or float) the tensor or value to compare

    out

    (Tensor, optional) the output tensor that must be a BoolTensor

    + +

    lt(input, other, out=None) -> Tensor

    + + + + +

    Computes \(\mbox{input} < \mbox{other}\) element-wise.

    +

    The second argument can be a number or a tensor whose shape is +broadcastable with the first argument.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_lt(torch_tensor(matrix(1:4, ncol = 2, byrow=TRUE)), + torch_tensor(matrix(c(1,1,4,4), ncol = 2, byrow=TRUE))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_lu.html b/reference/torch_lu.html new file mode 100644 index 0000000000000000000000000000000000000000..464f98d666459ffb756d244ec6a30ee28778ed1f --- /dev/null +++ b/reference/torch_lu.html @@ -0,0 +1,230 @@ + + + + + + + + +LU — torch_lu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Computes the LU factorization of a matrix or batches of matrices A. Returns a +tuple containing the LU factorization and pivots of A. Pivoting is done if pivot +is set to True.

    +
    + +
    torch_lu(A, pivot = TRUE, get_infos = FALSE, out = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    A

    (Tensor) the tensor to factor of size (, m, n)(,m,n)

    pivot

    (bool, optional) – controls whether pivoting is done. Default: TRUE

    get_infos

    (bool, optional) – if set to True, returns an info IntTensor. Default: FALSE

    out

    (tuple, optional) – optional output tuple. If get_infos is True, then the elements +in the tuple are Tensor, IntTensor, and IntTensor. If get_infos is False, then the +elements in the tuple are Tensor, IntTensor. Default: NULL

    + + +

    Examples

    +
    if (torch_is_installed()) { + +A = torch_randn(c(2, 3, 3)) +torch_lu(A) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_lu_solve.html b/reference/torch_lu_solve.html new file mode 100644 index 0000000000000000000000000000000000000000..a4d9c6696b10dde4d0f532c2004f56ac75cee098 --- /dev/null +++ b/reference/torch_lu_solve.html @@ -0,0 +1,231 @@ + + + + + + + + +Lu_solve — torch_lu_solve • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Lu_solve

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    b

    (Tensor) the RHS tensor of size \((*, m, k)\), where \(*\) is zero or more batch dimensions.

    LU_data

    (Tensor) the pivoted LU factorization of A from torch_lu of size \((*, m, m)\), where \(*\) is zero or more batch dimensions.

    LU_pivots

    (IntTensor) the pivots of the LU factorization from torch_lu of size \((*, m)\), where \(*\) is zero or more batch dimensions. The batch dimensions of LU_pivots must be equal to the batch dimensions of LU_data.

    out

    (Tensor, optional) the output tensor.

    + +

    lu_solve(input, LU_data, LU_pivots, out=None) -> Tensor

    + + + + +

    Returns the LU solve of the linear system \(Ax = b\) using the partially pivoted +LU factorization of A from torch_lu.

    + +

    Examples

    +
    if (torch_is_installed()) { +A = torch_randn(c(2, 3, 3)) +b = torch_randn(c(2, 3, 1)) +out = torch_lu(A) +x = torch_lu_solve(b, out[[1]], out[[2]]) +torch_norm(torch_bmm(A, x) - b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_manual_seed.html b/reference/torch_manual_seed.html new file mode 100644 index 0000000000000000000000000000000000000000..98df88a52c52f95bfb9e534a6726ef2b82b2a1c7 --- /dev/null +++ b/reference/torch_manual_seed.html @@ -0,0 +1,205 @@ + + + + + + + + +Sets the seed for generating random numbers. — torch_manual_seed • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sets the seed for generating random numbers.

    +
    + +
    torch_manual_seed(seed)
    + +

    Arguments

    + + + + + + +
    seed

    integer seed.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_masked_select.html b/reference/torch_masked_select.html new file mode 100644 index 0000000000000000000000000000000000000000..b645ce82c90f6f1867a2432ff5197cc96f7b92b6 --- /dev/null +++ b/reference/torch_masked_select.html @@ -0,0 +1,234 @@ + + + + + + + + +Masked_select — torch_masked_select • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Masked_select

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    mask

    (BoolTensor) the tensor containing the binary mask to index with

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    The returned tensor does not use the same storage +as the original tensor

    +

    masked_select(input, mask, out=None) -> Tensor

    + + + + +

    Returns a new 1-D tensor which indexes the input tensor according to +the boolean mask mask which is a BoolTensor.

    +

    The shapes of the mask tensor and the input tensor don't need +to match, but they must be broadcastable .

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(3, 4)) +x +mask = x$ge(0.5) +mask +torch_masked_select(x, mask) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_matmul.html b/reference/torch_matmul.html new file mode 100644 index 0000000000000000000000000000000000000000..73f7441874314afd816d06e257edd55df38bbdd8 --- /dev/null +++ b/reference/torch_matmul.html @@ -0,0 +1,267 @@ + + + + + + + + +Matmul — torch_matmul • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Matmul

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the first tensor to be multiplied

    other

    (Tensor) the second tensor to be multiplied

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + + +
    The 1-dimensional dot product version of this function does not support an `out` parameter.
    +
    + +

    matmul(input, other, out=None) -> Tensor

    + + + + +

    Matrix product of two tensors.

    +

    The behavior depends on the dimensionality of the tensors as follows:

      +
    • If both tensors are 1-dimensional, the dot product (scalar) is returned.

    • +
    • If both arguments are 2-dimensional, the matrix-matrix product is returned.

    • +
    • If the first argument is 1-dimensional and the second argument is 2-dimensional, +a 1 is prepended to its dimension for the purpose of the matrix multiply. +After the matrix multiply, the prepended dimension is removed.

    • +
    • If the first argument is 2-dimensional and the second argument is 1-dimensional, +the matrix-vector product is returned.

    • +
    • If both arguments are at least 1-dimensional and at least one argument is +N-dimensional (where N > 2), then a batched matrix multiply is returned. If the first +argument is 1-dimensional, a 1 is prepended to its dimension for the purpose of the +batched matrix multiply and removed after. If the second argument is 1-dimensional, a +1 is appended to its dimension for the purpose of the batched matrix multiple and removed after. +The non-matrix (i.e. batch) dimensions are broadcasted (and thus +must be broadcastable). For example, if input is a +\((j \times 1 \times n \times m)\) tensor and other is a \((k \times m \times p)\) +tensor, out will be an \((j \times k \times n \times p)\) tensor.

    • +
    + + +

    Examples

    +
    if (torch_is_installed()) { + +# vector x vector +tensor1 = torch_randn(c(3)) +tensor2 = torch_randn(c(3)) +torch_matmul(tensor1, tensor2) +# matrix x vector +tensor1 = torch_randn(c(3, 4)) +tensor2 = torch_randn(c(4)) +torch_matmul(tensor1, tensor2) +# batched matrix x broadcasted vector +tensor1 = torch_randn(c(10, 3, 4)) +tensor2 = torch_randn(c(4)) +torch_matmul(tensor1, tensor2) +# batched matrix x batched matrix +tensor1 = torch_randn(c(10, 3, 4)) +tensor2 = torch_randn(c(10, 4, 5)) +torch_matmul(tensor1, tensor2) +# batched matrix x broadcasted matrix +tensor1 = torch_randn(c(10, 3, 4)) +tensor2 = torch_randn(c(4, 5)) +torch_matmul(tensor1, tensor2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_matrix_power.html b/reference/torch_matrix_power.html new file mode 100644 index 0000000000000000000000000000000000000000..40a2ff180da3d49e969bf46ceea698e764a898f9 --- /dev/null +++ b/reference/torch_matrix_power.html @@ -0,0 +1,226 @@ + + + + + + + + +Matrix_power — torch_matrix_power • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Matrix_power

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    n

    (int) the power to raise the matrix to

    + +

    matrix_power(input, n) -> Tensor

    + + + + +

    Returns the matrix raised to the power n for square matrices. +For batch of matrices, each individual matrix is raised to the power n.

    +

    If n is negative, then the inverse of the matrix (if invertible) is +raised to the power n. For a batch of matrices, the batched inverse +(if invertible) is raised to the power n. If n is 0, then an identity matrix +is returned.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(2, 2, 2)) +a +torch_matrix_power(a, 3) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_matrix_rank.html b/reference/torch_matrix_rank.html new file mode 100644 index 0000000000000000000000000000000000000000..fb0d87f18e75b8b3ca46b9f124532e44efc5bfb6 --- /dev/null +++ b/reference/torch_matrix_rank.html @@ -0,0 +1,232 @@ + + + + + + + + +Matrix_rank — torch_matrix_rank • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Matrix_rank

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input 2-D tensor

    tol

    (float, optional) the tolerance value. Default: None

    symmetric

    (bool, optional) indicates whether input is symmetric. Default: False

    + +

    matrix_rank(input, tol=None, symmetric=False) -> Tensor

    + + + + +

    Returns the numerical rank of a 2-D tensor. The method to compute the +matrix rank is done using SVD by default. If symmetric is True, +then input is assumed to be symmetric, and the computation of the +rank is done by obtaining the eigenvalues.

    +

    tol is the threshold below which the singular values (or the eigenvalues +when symmetric is True) are considered to be 0. If tol is not +specified, tol is set to S.max() * max(S.size()) * eps where S is the +singular values (or the eigenvalues when symmetric is True), and eps +is the epsilon value for the datatype of input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_eye(10) +torch_matrix_rank(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_max.html b/reference/torch_max.html new file mode 100644 index 0000000000000000000000000000000000000000..107e105398e09c9eb2524d8aa0d9e2d2dad47b04 --- /dev/null +++ b/reference/torch_max.html @@ -0,0 +1,282 @@ + + + + + + + + +Max — torch_max • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Max

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not. Default: False.

    out

    (tuple, optional) the result tuple of two output tensors (max, max_indices)

    other

    (Tensor) the second input tensor

    + +

    Note

    + +

    When the shapes do not match, the shape of the returned output tensor +follows the broadcasting rules .

    +

    max(input) -> Tensor

    + + + + +

    Returns the maximum value of all elements in the input tensor.

    +

    max(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns a namedtuple (values, indices) where values is the maximum +value of each row of the input tensor in the given dimension +dim. And indices is the index location of each maximum value found +(argmax).

    +

    Warning

    + + + +

    indices does not necessarily contain the first occurrence of each +maximal value found, unless it is unique. +The exact implementation details are device-specific. +Do not expect the same result when run on CPU and GPU in general.

    +

    If keepdim is True, the output tensors are of the same size +as input except in the dimension dim where they are of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting +in the output tensors having 1 fewer dimension than input.

    +

    max(input, other, out=None) -> Tensor

    + + + + +

    Each element of the tensor input is compared with the corresponding +element of the tensor other and an element-wise maximum is taken.

    +

    The shapes of input and other don't need to match, +but they must be broadcastable .

    +

    $$ + \mbox{out}_i = \max(\mbox{tensor}_i, \mbox{other}_i) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_max(a) + + +a = torch_randn(c(4, 4)) +a +torch_max(a, dim = 1) + + +a = torch_randn(c(4)) +a +b = torch_randn(c(4)) +b +torch_max(a, other = b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_mean.html b/reference/torch_mean.html new file mode 100644 index 0000000000000000000000000000000000000000..fafbe6cbbea302fcafa85c9bd99b1287c9ce5329 --- /dev/null +++ b/reference/torch_mean.html @@ -0,0 +1,247 @@ + + + + + + + + +Mean — torch_mean • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Mean

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int or tuple of ints) the dimension or dimensions to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (Tensor, optional) the output tensor.

    + +

    mean(input) -> Tensor

    + + + + +

    Returns the mean value of all elements in the input tensor.

    +

    mean(input, dim, keepdim=False, out=None) -> Tensor

    + + + + +

    Returns the mean value of each row of the input tensor in the given +dimension dim. If dim is a list of dimensions, +reduce over all of them.

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension(s) dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in the +output tensor having 1 (or len(dim)) fewer dimension(s).

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_mean(a) + + +a = torch_randn(c(4, 4)) +a +torch_mean(a, 1) +torch_mean(a, 1, TRUE) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_median.html b/reference/torch_median.html new file mode 100644 index 0000000000000000000000000000000000000000..7b38174c924bb627bdcd149c77bc76cd4a4c752f --- /dev/null +++ b/reference/torch_median.html @@ -0,0 +1,247 @@ + + + + + + + + +Median — torch_median • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Median

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (tuple, optional) the result tuple of two output tensors (max, max_indices)

    + +

    median(input) -> Tensor

    + + + + +

    Returns the median value of all elements in the input tensor.

    +

    median(input, dim=-1, keepdim=False, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns a namedtuple (values, indices) where values is the median +value of each row of the input tensor in the given dimension +dim. And indices is the index location of each median value found.

    +

    By default, dim is the last dimension of the input tensor.

    +

    If keepdim is True, the output tensors are of the same size +as input except in the dimension dim where they are of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in +the outputs tensor having 1 fewer dimension than input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_median(a) + + +a = torch_randn(c(4, 5)) +a +torch_median(a, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_memory_format.html b/reference/torch_memory_format.html new file mode 100644 index 0000000000000000000000000000000000000000..2c6f2d17b34d2000c4ed73d4912d93fbca6311ad --- /dev/null +++ b/reference/torch_memory_format.html @@ -0,0 +1,201 @@ + + + + + + + + +Memory format — torch_memory_format • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Returns the correspondent memory format.

    +
    + +
    torch_contiguous_format()
    +
    +torch_preserve_format()
    +
    +torch_channels_last_format()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_meshgrid.html b/reference/torch_meshgrid.html new file mode 100644 index 0000000000000000000000000000000000000000..1c8fd45c66aefb671ab8f418ba500d979182193c --- /dev/null +++ b/reference/torch_meshgrid.html @@ -0,0 +1,224 @@ + + + + + + + + +Meshgrid — torch_meshgrid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Meshgrid

    +
    + + +

    Arguments

    + + + + + + + + + + +
    tensors

    (list of Tensor) list of scalars or 1 dimensional tensors. Scalars will be

    treated

    (1,)

    + +

    TEST

    + + + + +

    Take \(N\) tensors, each of which can be either scalar or 1-dimensional +vector, and create \(N\) N-dimensional grids, where the \(i\) th grid is defined by +expanding the \(i\) th input over dimensions defined by other inputs.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_tensor(c(1, 2, 3)) +y = torch_tensor(c(4, 5, 6)) +out = torch_meshgrid(list(x, y)) +out +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_min.html b/reference/torch_min.html new file mode 100644 index 0000000000000000000000000000000000000000..b28e8b24bfa4676402e2d0957b56c3f2eade70d4 --- /dev/null +++ b/reference/torch_min.html @@ -0,0 +1,283 @@ + + + + + + + + +Min — torch_min • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Min

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (tuple, optional) the tuple of two output tensors (min, min_indices)

    other

    (Tensor) the second input tensor

    + +

    Note

    + +

    When the shapes do not match, the shape of the returned output tensor +follows the broadcasting rules .

    +

    min(input) -> Tensor

    + + + + +

    Returns the minimum value of all elements in the input tensor.

    +

    min(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns a namedtuple (values, indices) where values is the minimum +value of each row of the input tensor in the given dimension +dim. And indices is the index location of each minimum value found +(argmin).

    +

    Warning

    + + + +

    indices does not necessarily contain the first occurrence of each +minimal value found, unless it is unique. +The exact implementation details are device-specific. +Do not expect the same result when run on CPU and GPU in general.

    +

    If keepdim is True, the output tensors are of the same size as +input except in the dimension dim where they are of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in +the output tensors having 1 fewer dimension than input.

    +

    min(input, other, out=None) -> Tensor

    + + + + +

    Each element of the tensor input is compared with the corresponding +element of the tensor other and an element-wise minimum is taken. +The resulting tensor is returned.

    +

    The shapes of input and other don't need to match, +but they must be broadcastable .

    +

    $$ + \mbox{out}_i = \min(\mbox{tensor}_i, \mbox{other}_i) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_min(a) + + +a = torch_randn(c(4, 4)) +a +torch_min(a, dim = 1) + + +a = torch_randn(c(4)) +a +b = torch_randn(c(4)) +b +torch_min(a, other = b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_mm.html b/reference/torch_mm.html new file mode 100644 index 0000000000000000000000000000000000000000..15291832b2cfa58e4bf2cec95496a103b28716aa --- /dev/null +++ b/reference/torch_mm.html @@ -0,0 +1,231 @@ + + + + + + + + +Mm — torch_mm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Mm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the first matrix to be multiplied

    mat2

    (Tensor) the second matrix to be multiplied

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    This function does not broadcast . +For broadcasting matrix products, see torch_matmul.

    +

    mm(input, mat2, out=None) -> Tensor

    + + + + +

    Performs a matrix multiplication of the matrices input and mat2.

    +

    If input is a \((n \times m)\) tensor, mat2 is a +\((m \times p)\) tensor, out will be a \((n \times p)\) tensor.

    + +

    Examples

    +
    if (torch_is_installed()) { + +mat1 = torch_randn(c(2, 3)) +mat2 = torch_randn(c(3, 3)) +torch_mm(mat1, mat2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_mode.html b/reference/torch_mode.html new file mode 100644 index 0000000000000000000000000000000000000000..6aa47b2020d38ec93be2ce6e498a5030919f9e92 --- /dev/null +++ b/reference/torch_mode.html @@ -0,0 +1,240 @@ + + + + + + + + +Mode — torch_mode • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Mode

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the dimension to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (tuple, optional) the result tuple of two output tensors (values, indices)

    + +

    Note

    + +

    This function is not defined for torch_cuda.Tensor yet.

    +

    mode(input, dim=-1, keepdim=False, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns a namedtuple (values, indices) where values is the mode +value of each row of the input tensor in the given dimension +dim, i.e. a value which appears most often +in that row, and indices is the index location of each mode value found.

    +

    By default, dim is the last dimension of the input tensor.

    +

    If keepdim is True, the output tensors are of the same size as +input except in the dimension dim where they are of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting +in the output tensors having 1 fewer dimension than input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randint(0, 50, size = list(5)) +a +torch_mode(a, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_mul.html b/reference/torch_mul.html new file mode 100644 index 0000000000000000000000000000000000000000..bee50879cf34629904b7c5bd982522de5789a1e7 --- /dev/null +++ b/reference/torch_mul.html @@ -0,0 +1,259 @@ + + + + + + + + +Mul — torch_mul • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Mul

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    NA

    value

    (Number) the number to be multiplied to each element of input

    out

    NA

    input

    (Tensor) the first multiplicand tensor

    other

    (Tensor) the second multiplicand tensor

    out

    (Tensor, optional) the output tensor.

    + +

    mul(input, other, out=None)

    + + + + +

    Multiplies each element of the input input with the scalar +other and returns a new resulting tensor.

    +

    $$ + \mbox{out}_i = \mbox{other} \times \mbox{input}_i +$$ +If input is of type FloatTensor or DoubleTensor, other +should be a real number, otherwise it should be an integer

    + + +

    Each element of the tensor input is multiplied by the corresponding +element of the Tensor other. The resulting tensor is returned.

    +

    The shapes of input and other must be +broadcastable .

    +

    $$ + \mbox{out}_i = \mbox{input}_i \times \mbox{other}_i +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3)) +a +torch_mul(a, 100) + + +a = torch_randn(c(4, 1)) +a +b = torch_randn(c(1, 4)) +b +torch_mul(a, b) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_multinomial.html b/reference/torch_multinomial.html new file mode 100644 index 0000000000000000000000000000000000000000..366ded30f3781156fb475f798d0b58edec8df2a1 --- /dev/null +++ b/reference/torch_multinomial.html @@ -0,0 +1,256 @@ + + + + + + + + +Multinomial — torch_multinomial • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Multinomial

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor containing probabilities

    num_samples

    (int) number of samples to draw

    replacement

    (bool, optional) whether to draw with replacement or not

    generator

    (torch.Generator, optional) a pseudorandom number generator for sampling

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + + +
    The rows of `input` do not need to sum to one (in which case we use
    +the values as weights), but must be non-negative, finite and have
    +a non-zero sum.
    +
    + +

    Indices are ordered from left to right according to when each was sampled +(first samples are placed in first column).

    +

    If input is a vector, out is a vector of size num_samples.

    +

    If input is a matrix with m rows, out is an matrix of shape +\((m \times \mbox{num\_samples})\).

    +

    If replacement is True, samples are drawn with replacement.

    +

    If not, they are drawn without replacement, which means that when a +sample index is drawn for a row, it cannot be drawn again for that row.

    +
    When drawn without replacement, `num_samples` must be lower than
    +number of non-zero elements in `input` (or the min number of non-zero
    +elements in each row of `input` if it is a matrix).
    +
    + +

    multinomial(input, num_samples, replacement=False, *, generator=None, out=None) -> LongTensor

    + + + + +

    Returns a tensor where each row contains num_samples indices sampled +from the multinomial probability distribution located in the corresponding row +of tensor input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +weights = torch_tensor(c(0, 10, 3, 0), dtype=torch_float()) # create a tensor of weights +torch_multinomial(weights, 2) +torch_multinomial(weights, 4, replacement=TRUE) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_mv.html b/reference/torch_mv.html new file mode 100644 index 0000000000000000000000000000000000000000..4d48670492a6a85c64e54fc373719493eb16dadc --- /dev/null +++ b/reference/torch_mv.html @@ -0,0 +1,231 @@ + + + + + + + + +Mv — torch_mv • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Mv

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) matrix to be multiplied

    vec

    (Tensor) vector to be multiplied

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    This function does not broadcast .

    +

    mv(input, vec, out=None) -> Tensor

    + + + + +

    Performs a matrix-vector product of the matrix input and the vector +vec.

    +

    If input is a \((n \times m)\) tensor, vec is a 1-D tensor of +size \(m\), out will be 1-D of size \(n\).

    + +

    Examples

    +
    if (torch_is_installed()) { + +mat = torch_randn(c(2, 3)) +vec = torch_randn(c(3)) +torch_mv(mat, vec) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_mvlgamma.html b/reference/torch_mvlgamma.html new file mode 100644 index 0000000000000000000000000000000000000000..dacaf4f2a4010a88c4ea5b6f005e61645c453bb2 --- /dev/null +++ b/reference/torch_mvlgamma.html @@ -0,0 +1,227 @@ + + + + + + + + +Mvlgamma — torch_mvlgamma • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Mvlgamma

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the tensor to compute the multivariate log-gamma function

    p

    (int) the number of dimensions

    + +

    mvlgamma(input, p) -> Tensor

    + + + + +

    Computes the multivariate log-gamma function <https://en.wikipedia.org/wiki/Multivariate_gamma_function>_) with dimension +\(p\) element-wise, given by

    +

    $$ + \log(\Gamma_{p}(a)) = C + \displaystyle \sum_{i=1}^{p} \log\left(\Gamma\left(a - \frac{i - 1}{2}\right)\right) +$$ +where \(C = \log(\pi) \times \frac{p (p - 1)}{4}\) and \(\Gamma(\cdot)\) is the Gamma function.

    +

    All elements must be greater than \(\frac{p - 1}{2}\), otherwise an error would be thrown.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_empty(c(2, 3))$uniform_(1, 2) +a +torch_mvlgamma(a, 2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_narrow.html b/reference/torch_narrow.html new file mode 100644 index 0000000000000000000000000000000000000000..a67a3f72763e9d59c04d0d56824976aa7e2b545f --- /dev/null +++ b/reference/torch_narrow.html @@ -0,0 +1,231 @@ + + + + + + + + +Narrow — torch_narrow • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Narrow

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to narrow

    dim

    (int) the dimension along which to narrow

    start

    (int) the starting dimension

    length

    (int) the distance to the ending dimension

    + +

    narrow(input, dim, start, length) -> Tensor

    + + + + +

    Returns a new tensor that is a narrowed version of input tensor. The +dimension dim is input from start to start + length. The +returned tensor and input tensor share the same underlying storage.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_tensor(matrix(c(1:9), ncol = 3, byrow= TRUE)) +torch_narrow(x, 1, torch_tensor(0L)$sum(dim = 1), 2) +torch_narrow(x, 2, torch_tensor(1L)$sum(dim = 1), 2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ne.html b/reference/torch_ne.html new file mode 100644 index 0000000000000000000000000000000000000000..37f322f60a5f0c24499af8fe14783f48c3e49cc9 --- /dev/null +++ b/reference/torch_ne.html @@ -0,0 +1,226 @@ + + + + + + + + +Ne — torch_ne • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ne

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the tensor to compare

    other

    (Tensor or float) the tensor or value to compare

    out

    (Tensor, optional) the output tensor that must be a BoolTensor

    + +

    ne(input, other, out=None) -> Tensor

    + + + + +

    Computes \(input \neq other\) element-wise.

    +

    The second argument can be a number or a tensor whose shape is +broadcastable with the first argument.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_ne(torch_tensor(matrix(1:4, ncol = 2, byrow=TRUE)), + torch_tensor(matrix(rep(c(1,4), each = 2), ncol = 2, byrow=TRUE))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_neg.html b/reference/torch_neg.html new file mode 100644 index 0000000000000000000000000000000000000000..762f3f36dddfac06b92f0149347b15066cb2545d --- /dev/null +++ b/reference/torch_neg.html @@ -0,0 +1,224 @@ + + + + + + + + +Neg — torch_neg • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Neg

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    neg(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the negative of the elements of input.

    +

    $$ + \mbox{out} = -1 \times \mbox{input} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(5)) +a +torch_neg(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_nonzero.html b/reference/torch_nonzero.html new file mode 100644 index 0000000000000000000000000000000000000000..c3a5791e133d45a0e22183321228256005de757f --- /dev/null +++ b/reference/torch_nonzero.html @@ -0,0 +1,249 @@ + + + + + + + + +Nonzero — torch_nonzero • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Nonzero

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (LongTensor, optional) the output tensor containing indices

    + +

    Note

    + + +
    [`torch_nonzero(..., as_tuple=False) &lt;torch.nonzero&gt;`] (default) returns a
    +2-D tensor where each row is the index for a nonzero value.
    +
    +[`torch_nonzero(..., as_tuple=True) &lt;torch.nonzero&gt;`] returns a tuple of 1-D
    +index tensors, allowing for advanced indexing, so ``x[x.nonzero(as_tuple=True)]``
    +gives all nonzero values of tensor ``x``. Of the returned tuple, each index tensor
    +contains nonzero indices for a certain dimension.
    +
    +See below for more details on the two behaviors.
    +
    + +

    nonzero(input, *, out=None, as_tuple=False) -> LongTensor or tuple of LongTensors

    + + + + +

    When as_tuple is False (default):

    +

    Returns a tensor containing the indices of all non-zero elements of +input. Each row in the result contains the indices of a non-zero +element in input. The result is sorted lexicographically, with +the last index changing the fastest (C-style).

    +

    If input has \(n\) dimensions, then the resulting indices tensor +out is of size \((z \times n)\), where \(z\) is the total number of +non-zero elements in the input tensor.

    +

    When as_tuple is True:

    +

    Returns a tuple of 1-D tensors, one for each dimension in input, +each containing the indices (in that dimension) of all non-zero elements of +input .

    +

    If input has \(n\) dimensions, then the resulting tuple contains \(n\) +tensors of size \(z\), where \(z\) is the total number of +non-zero elements in the input tensor.

    +

    As a special case, when input has zero dimensions and a nonzero scalar +value, it is treated as a one-dimensional tensor with one element.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_nonzero(torch_tensor(c(1, 1, 1, 0, 1))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_norm.html b/reference/torch_norm.html new file mode 100644 index 0000000000000000000000000000000000000000..7c1f26165eb6da47f1f5fa86b7962e3b0ebc4d9b --- /dev/null +++ b/reference/torch_norm.html @@ -0,0 +1,241 @@ + + + + + + + + +Norm — torch_norm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Norm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor

    p

    (int, float, inf, -inf, 'fro', 'nuc', optional) the order of norm. Default: 'fro' The following norms can be calculated: ===== ============================ ========================== ord matrix norm vector norm ===== ============================ ========================== None Frobenius norm 2-norm 'fro' Frobenius norm -- 'nuc' nuclear norm -- Other as vec norm when dim is None sum(abs(x)ord)(1./ord) ===== ============================ ==========================

    dim

    (int, 2-tuple of ints, 2-list of ints, optional) If it is an int, vector norm will be calculated, if it is 2-tuple of ints, matrix norm will be calculated. If the value is None, matrix norm will be calculated when the input tensor only has two dimensions, vector norm will be calculated when the input tensor only has one dimension. If the input tensor has more than two dimensions, the vector norm will be applied to last dimension.

    keepdim

    (bool, optional) whether the output tensors have dim retained or not. Ignored if dim = None and out = None. Default: False

    out

    (Tensor, optional) the output tensor. Ignored if dim = None and out = None.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. If specified, the input tensor is casted to 'dtype' while performing the operation. Default: None.

    + +

    TEST

    + + + + +

    Returns the matrix norm or vector norm of a given tensor.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_arange(0, 9, dtype = torch_float()) +b = a$reshape(list(3, 3)) +torch_norm(a) +torch_norm(b) +torch_norm(a, Inf) +torch_norm(b, Inf) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_normal.html b/reference/torch_normal.html new file mode 100644 index 0000000000000000000000000000000000000000..36704cbd1189b344d2a54715970b78c32bf697e1 --- /dev/null +++ b/reference/torch_normal.html @@ -0,0 +1,274 @@ + + + + + + + + +Normal — torch_normal • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Normal

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    mean

    (Tensor) the tensor of per-element means

    std

    (Tensor) the tensor of per-element standard deviations

    generator

    (torch.Generator, optional) a pseudorandom number generator for sampling

    out

    (Tensor, optional) the output tensor.

    size

    (int...) a sequence of integers defining the shape of the output tensor.

    + +

    Note

    + +

    When the shapes do not match, the shape of mean +is used as the shape for the returned output tensor

    +

    normal(mean, std, *, generator=None, out=None) -> Tensor

    + + + + +

    Returns a tensor of random numbers drawn from separate normal distributions +whose mean and standard deviation are given.

    +

    The mean is a tensor with the mean of +each output element's normal distribution

    +

    The std is a tensor with the standard deviation of +each output element's normal distribution

    +

    The shapes of mean and std don't need to match, but the +total number of elements in each tensor need to be the same.

    +

    normal(mean=0.0, std, out=None) -> Tensor

    + + + + +

    Similar to the function above, but the means are shared among all drawn +elements.

    +

    normal(mean, std=1.0, out=None) -> Tensor

    + + + + +

    Similar to the function above, but the standard-deviations are shared among +all drawn elements.

    +

    normal(mean, std, size, *, out=None) -> Tensor

    + + + + +

    Similar to the function above, but the means and standard deviations are shared +among all drawn elements. The resulting tensor has size given by size.

    + +

    Examples

    +
    if (torch_is_installed()) { + +if (FALSE) { +torch_normal(mean=0, std=torch_arange(1, 0, -0.1)) + + +torch_normal(mean=0.5, std=torch_arange(1., 6.)) + + +torch_normal(mean=torch_arange(1., 6.)) + + +torch_normal(2, 3, size=list(1, 4)) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ones.html b/reference/torch_ones.html new file mode 100644 index 0000000000000000000000000000000000000000..af7fbcf0b3183b89186ebdebfddd44c143452494 --- /dev/null +++ b/reference/torch_ones.html @@ -0,0 +1,237 @@ + + + + + + + + +Ones — torch_ones • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ones

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    size

    (int...) a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    ones(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a tensor filled with the scalar value 1, with the shape defined +by the variable argument size.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_ones(c(2, 3)) +torch_ones(c(5)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ones_like.html b/reference/torch_ones_like.html new file mode 100644 index 0000000000000000000000000000000000000000..41167901b87f82dddc657fd60bb6e6d5089279a2 --- /dev/null +++ b/reference/torch_ones_like.html @@ -0,0 +1,245 @@ + + + + + + + + +Ones_like — torch_ones_like • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ones_like

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the size of input will determine size of the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned Tensor. Default: if None, defaults to the dtype of input.

    layout

    (torch.layout, optional) the desired layout of returned tensor. Default: if None, defaults to the layout of input.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, defaults to the device of input.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_preserve_format.

    + +

    ones_like(input, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor

    + + + + +

    Returns a tensor filled with the scalar value 1, with the same size as +input. torch_ones_like(input) is equivalent to +torch_ones(input.size(), dtype=input.dtype, layout=input.layout, device=input.device).

    +

    Warning

    + + + +

    As of 0.4, this function does not support an out keyword. As an alternative, +the old torch_ones_like(input, out=output) is equivalent to +torch_ones(input.size(), out=output).

    + +

    Examples

    +
    if (torch_is_installed()) { + +input = torch_empty(c(2, 3)) +torch_ones_like(input) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_orgqr.html b/reference/torch_orgqr.html new file mode 100644 index 0000000000000000000000000000000000000000..3b951a483a69a5f4ab01a8b30631936000c7b11c --- /dev/null +++ b/reference/torch_orgqr.html @@ -0,0 +1,217 @@ + + + + + + + + +Orgqr — torch_orgqr • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Orgqr

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the a from torch_geqrf.

    input2

    (Tensor) the tau from torch_geqrf.

    + +

    orgqr(input, input2) -> Tensor

    + + + + +

    Computes the orthogonal matrix Q of a QR factorization, from the (input, input2) +tuple returned by torch_geqrf.

    +

    This directly calls the underlying LAPACK function ?orgqr. +See LAPACK documentation for orgqr_ for further details.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_ormqr.html b/reference/torch_ormqr.html new file mode 100644 index 0000000000000000000000000000000000000000..292b985ff6d5fc6d9d33032f6a9d641f09df03ab --- /dev/null +++ b/reference/torch_ormqr.html @@ -0,0 +1,221 @@ + + + + + + + + +Ormqr — torch_ormqr • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Ormqr

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the a from torch_geqrf.

    input2

    (Tensor) the tau from torch_geqrf.

    input3

    (Tensor) the matrix to be multiplied.

    + +

    ormqr(input, input2, input3, left=True, transpose=False) -> Tensor

    + + + + +

    Multiplies mat (given by input3) by the orthogonal Q matrix of the QR factorization +formed by torch_geqrf that is represented by (a, tau) (given by (input, input2)).

    +

    This directly calls the underlying LAPACK function ?ormqr. +See LAPACK documentation for ormqr_ for further details.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_pdist.html b/reference/torch_pdist.html new file mode 100644 index 0000000000000000000000000000000000000000..c3b4036b52c4e3b9f1c73cefcadf09b343b3fb79 --- /dev/null +++ b/reference/torch_pdist.html @@ -0,0 +1,223 @@ + + + + + + + + +Pdist — torch_pdist • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Pdist

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    NA input tensor of shape \(N \times M\).

    p

    NA p value for the p-norm distance to calculate between each vector pair \(\in [0, \infty]\).

    + +

    pdist(input, p=2) -> Tensor

    + + + + +

    Computes the p-norm distance between every pair of row vectors in the input. +This is identical to the upper triangular portion, excluding the diagonal, of +torch_norm(input[:, None] - input, dim=2, p=p). This function will be faster +if the rows are contiguous.

    +

    If input has shape \(N \times M\) then the output will have shape +\(\frac{1}{2} N (N - 1)\).

    +

    This function is equivalent to scipy.spatial.distance.pdist(input, 'minkowski', p=p) if \(p \in (0, \infty)\). When \(p = 0\) it is +equivalent to scipy.spatial.distance.pdist(input, 'hamming') * M. +When \(p = \infty\), the closest scipy function is +scipy.spatial.distance.pdist(xn, lambda x, y: np.abs(x - y).max()).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_pinverse.html b/reference/torch_pinverse.html new file mode 100644 index 0000000000000000000000000000000000000000..6cc6b09cf7b01957f08c410e4089accaf0d87608 --- /dev/null +++ b/reference/torch_pinverse.html @@ -0,0 +1,239 @@ + + + + + + + + +Pinverse — torch_pinverse • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Pinverse

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) The input tensor of size \((*, m, n)\) where \(*\) is zero or more batch dimensions

    rcond

    (float) A floating point value to determine the cutoff for small singular values. Default: 1e-15

    + +

    Note

    + + +
    This method is implemented using the Singular Value Decomposition.
    +
    + +
    The pseudo-inverse is not necessarily a continuous function in the elements of the matrix `[1]`_.
    +Therefore, derivatives are not always existent, and exist for a constant rank only `[2]`_.
    +However, this method is backprop-able due to the implementation by using SVD results, and
    +could be unstable. Double-backward will also be unstable due to the usage of SVD internally.
    +See `~torch.svd` for more details.
    +
    + +

    pinverse(input, rcond=1e-15) -> Tensor

    + + + + +

    Calculates the pseudo-inverse (also known as the Moore-Penrose inverse) of a 2D tensor. +Please look at Moore-Penrose inverse_ for more details

    + +

    Examples

    +
    if (torch_is_installed()) { + +input = torch_randn(c(3, 5)) +input +torch_pinverse(input) +# Batched pinverse example +a = torch_randn(c(2,6,3)) +b = torch_pinverse(a) +torch_matmul(b, a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_pixel_shuffle.html b/reference/torch_pixel_shuffle.html new file mode 100644 index 0000000000000000000000000000000000000000..b10d078b6560c1550a8407fc7e51875c205c1c90 --- /dev/null +++ b/reference/torch_pixel_shuffle.html @@ -0,0 +1,221 @@ + + + + + + + + +Pixel_shuffle — torch_pixel_shuffle • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Pixel_shuffle

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor

    upscale_factor

    (int) factor to increase spatial resolution by

    + +

    Rearranges elements in a tensor of shape

    + +

    math:(*, C \times r^2, H, W) to a :

    +

    Rearranges elements in a tensor of shape \((*, C \times r^2, H, W)\) to a +tensor of shape \((*, C, H \times r, W \times r)\).

    +

    See ~torch.nn.PixelShuffle for details.

    + +

    Examples

    +
    if (torch_is_installed()) { + +input = torch_randn(c(1, 9, 4, 4)) +output = nnf_pixel_shuffle(input, 3) +print(output$size()) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_poisson.html b/reference/torch_poisson.html new file mode 100644 index 0000000000000000000000000000000000000000..ca3ff62b4b2993ee578ff4cd4f90a1f58af63277 --- /dev/null +++ b/reference/torch_poisson.html @@ -0,0 +1,225 @@ + + + + + + + + +Poisson — torch_poisson • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Poisson

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor containing the rates of the Poisson distribution

    generator

    (torch.Generator, optional) a pseudorandom number generator for sampling

    + +

    poisson(input *, generator=None) -> Tensor

    + + + + +

    Returns a tensor of the same size as input with each element +sampled from a Poisson distribution with rate parameter given by the corresponding +element in input i.e.,

    +

    $$ + \mbox{out}_i \sim \mbox{Poisson}(\mbox{input}_i) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +rates = torch_rand(c(4, 4)) * 5 # rate parameter between 0 and 5 +torch_poisson(rates) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_polygamma.html b/reference/torch_polygamma.html new file mode 100644 index 0000000000000000000000000000000000000000..efb6f408ce4b856c6dc74a2c445e7b9071cea2c1 --- /dev/null +++ b/reference/torch_polygamma.html @@ -0,0 +1,235 @@ + + + + + + + + +Polygamma — torch_polygamma • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Polygamma

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    n

    (int) the order of the polygamma function

    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + + +
    This function is not implemented for \eqn{n \geq 2}.
    +
    + +

    polygamma(n, input, out=None) -> Tensor

    + + + + +

    Computes the \(n^{th}\) derivative of the digamma function on input. +\(n \geq 0\) is called the order of the polygamma function.

    +

    $$ + \psi^{(n)}(x) = \frac{d^{(n)}}{dx^{(n)}} \psi(x) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +a = torch_tensor(c(1, 0.5)) +torch_polygamma(1, a) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_pow.html b/reference/torch_pow.html new file mode 100644 index 0000000000000000000000000000000000000000..08a69fc34aeaa35ef28c538fa3fc593525e24882 --- /dev/null +++ b/reference/torch_pow.html @@ -0,0 +1,263 @@ + + + + + + + + +Pow — torch_pow • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Pow

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    exponent

    (float or tensor) the exponent value

    out

    (Tensor, optional) the output tensor.

    self

    (float) the scalar base value for the power operation

    + +

    pow(input, exponent, out=None) -> Tensor

    + + + + +

    Takes the power of each element in input with exponent and +returns a tensor with the result.

    +

    exponent can be either a single float number or a Tensor +with the same number of elements as input.

    +

    When exponent is a scalar value, the operation applied is:

    +

    $$ + \mbox{out}_i = x_i^{\mbox{exponent}} +$$ +When exponent is a tensor, the operation applied is:

    +

    $$ + \mbox{out}_i = x_i^{\mbox{exponent}_i} +$$ +When exponent is a tensor, the shapes of input +and exponent must be broadcastable .

    +

    pow(self, exponent, out=None) -> Tensor

    + + + + +

    self is a scalar float value, and exponent is a tensor. +The returned tensor out is of the same shape as exponent

    +

    The operation applied is:

    +

    $$ + \mbox{out}_i = \mbox{self} ^ {\mbox{exponent}_i} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_pow(a, 2) +exp = torch_arange(1., 5.) +a = torch_arange(1., 5.) +a +exp +torch_pow(a, exp) + + +exp = torch_arange(1., 5.) +base = 2 +torch_pow(base, exp) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_prod.html b/reference/torch_prod.html new file mode 100644 index 0000000000000000000000000000000000000000..cfc0b8384c42c1e6e5b939cdb4ed587c3021dcf0 --- /dev/null +++ b/reference/torch_prod.html @@ -0,0 +1,245 @@ + + + + + + + + +Prod — torch_prod • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Prod

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.

    dim

    (int) the dimension to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    + +

    prod(input, dtype=None) -> Tensor

    + + + + +

    Returns the product of all elements in the input tensor.

    +

    prod(input, dim, keepdim=False, dtype=None) -> Tensor

    + + + + +

    Returns the product of each row of the input tensor in the given +dimension dim.

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in +the output tensor having 1 fewer dimension than input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_prod(a) + + +a = torch_randn(c(4, 2)) +a +torch_prod(a, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_promote_types.html b/reference/torch_promote_types.html new file mode 100644 index 0000000000000000000000000000000000000000..cd585e580579b724b046b17e286e891cead58810 --- /dev/null +++ b/reference/torch_promote_types.html @@ -0,0 +1,223 @@ + + + + + + + + +Promote_types — torch_promote_types • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Promote_types

    +
    + + +

    Arguments

    + + + + + + + + + + +
    type1

    (torch.dtype)

    type2

    (torch.dtype)

    + +

    promote_types(type1, type2) -> dtype

    + + + + +

    Returns the torch_dtype with the smallest size and scalar kind that is +not smaller nor of lower kind than either type1 or type2. See type promotion +documentation for more information on the type +promotion logic.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_promote_types(torch_int32(), torch_float32()) +torch_promote_types(torch_uint8(), torch_long()) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_qr.html b/reference/torch_qr.html new file mode 100644 index 0000000000000000000000000000000000000000..818e3d152aa4501e0cb73d16c25be846145f00d7 --- /dev/null +++ b/reference/torch_qr.html @@ -0,0 +1,240 @@ + + + + + + + + +Qr — torch_qr • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Qr

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of size \((*, m, n)\) where * is zero or more batch dimensions consisting of matrices of dimension \(m \times n\).

    some

    (bool, optional) Set to True for reduced QR decomposition and False for complete QR decomposition.

    out

    (tuple, optional) tuple of Q and R tensors satisfying input = torch.matmul(Q, R). The dimensions of Q and R are \((*, m, k)\) and \((*, k, n)\) respectively, where \(k = \min(m, n)\) if some: is True and \(k = m\) otherwise.

    + +

    Note

    + +

    precision may be lost if the magnitudes of the elements of input +are large

    +

    While it should always give you a valid decomposition, it may not +give you the same one across platforms - it will depend on your +LAPACK implementation.

    +

    qr(input, some=True, out=None) -> (Tensor, Tensor)

    + + + + +

    Computes the QR decomposition of a matrix or a batch of matrices input, +and returns a namedtuple (Q, R) of tensors such that \(\mbox{input} = Q R\) +with \(Q\) being an orthogonal matrix or batch of orthogonal matrices and +\(R\) being an upper triangular matrix or batch of upper triangular matrices.

    +

    If some is True, then this function returns the thin (reduced) QR factorization. +Otherwise, if some is False, this function returns the complete QR factorization.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_tensor(matrix(c(12., -51, 4, 6, 167, -68, -4, 24, -41), ncol = 3, byrow = TRUE)) +out = torch_qr(a) +q = out[[1]] +r = out[[2]] +torch_mm(q, r)$round() +torch_mm(q$t(), q)$round() +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_qscheme.html b/reference/torch_qscheme.html new file mode 100644 index 0000000000000000000000000000000000000000..5f216f1fdc32dbc554023ab15ccfa01a63e80bb6 --- /dev/null +++ b/reference/torch_qscheme.html @@ -0,0 +1,203 @@ + + + + + + + + +Creates the corresponding Scheme object — torch_qscheme • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates the corresponding Scheme object

    +
    + +
    torch_per_channel_affine()
    +
    +torch_per_tensor_affine()
    +
    +torch_per_channel_symmetric()
    +
    +torch_per_tensor_symmetric()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_quantize_per_channel.html b/reference/torch_quantize_per_channel.html new file mode 100644 index 0000000000000000000000000000000000000000..28c79fcdbb1a717a47116d5355648aa5f302a531 --- /dev/null +++ b/reference/torch_quantize_per_channel.html @@ -0,0 +1,234 @@ + + + + + + + + +Quantize_per_channel — torch_quantize_per_channel • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Quantize_per_channel

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) float tensor to quantize

    scales

    (Tensor) float 1D tensor of scales to use, size should match input.size(axis)

    zero_points

    (int) integer 1D tensor of offset to use, size should match input.size(axis)

    axis

    (int) dimension on which apply per-channel quantization

    dtype

    (torch.dtype) the desired data type of returned tensor. Has to be one of the quantized dtypes: torch_quint8, torch.qint8, torch.qint32

    + +

    quantize_per_channel(input, scales, zero_points, axis, dtype) -> Tensor

    + + + + +

    Converts a float tensor to per-channel quantized tensor with given scales and zero points.

    + +

    Examples

    +
    if (torch_is_installed()) { +x = torch_tensor(matrix(c(-1.0, 0.0, 1.0, 2.0), ncol = 2, byrow = TRUE)) +torch_quantize_per_channel(x, torch_tensor(c(0.1, 0.01)), + torch_tensor(c(10L, 0L)), 0, torch_quint8()) +torch_quantize_per_channel(x, torch_tensor(c(0.1, 0.01)), + torch_tensor(c(10L, 0L)), 0, torch_quint8())$int_repr() +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_quantize_per_tensor.html b/reference/torch_quantize_per_tensor.html new file mode 100644 index 0000000000000000000000000000000000000000..5bbe149bc11a8569c709e50fba07456b4a5d4059 --- /dev/null +++ b/reference/torch_quantize_per_tensor.html @@ -0,0 +1,227 @@ + + + + + + + + +Quantize_per_tensor — torch_quantize_per_tensor • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Quantize_per_tensor

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) float tensor to quantize

    scale

    (float) scale to apply in quantization formula

    zero_point

    (int) offset in integer value that maps to float zero

    dtype

    (torch.dtype) the desired data type of returned tensor. Has to be one of the quantized dtypes: torch_quint8, torch.qint8, torch.qint32

    + +

    quantize_per_tensor(input, scale, zero_point, dtype) -> Tensor

    + + + + +

    Converts a float tensor to quantized tensor with given scale and zero point.

    + +

    Examples

    +
    if (torch_is_installed()) { +torch_quantize_per_tensor(torch_tensor(c(-1.0, 0.0, 1.0, 2.0)), 0.1, 10, torch_quint8()) +torch_quantize_per_tensor(torch_tensor(c(-1.0, 0.0, 1.0, 2.0)), 0.1, 10, torch_quint8())$int_repr() +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_rand.html b/reference/torch_rand.html new file mode 100644 index 0000000000000000000000000000000000000000..597af55400d6db116e237d478c39c159f84220c2 --- /dev/null +++ b/reference/torch_rand.html @@ -0,0 +1,238 @@ + + + + + + + + +Rand — torch_rand • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Rand

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    size

    (int...) a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    rand(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a tensor filled with random numbers from a uniform distribution +on the interval \([0, 1)\)

    +

    The shape of the tensor is defined by the variable argument size.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_rand(4) +torch_rand(c(2, 3)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_rand_like.html b/reference/torch_rand_like.html new file mode 100644 index 0000000000000000000000000000000000000000..4aa4cf3c4f1f27f1b9a82dcc2b51c74950dd671b --- /dev/null +++ b/reference/torch_rand_like.html @@ -0,0 +1,233 @@ + + + + + + + + +Rand_like — torch_rand_like • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Rand_like

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the size of input will determine size of the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned Tensor. Default: if None, defaults to the dtype of input.

    layout

    (torch.layout, optional) the desired layout of returned tensor. Default: if None, defaults to the layout of input.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, defaults to the device of input.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_preserve_format.

    + +

    rand_like(input, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor

    + + + + +

    Returns a tensor with the same size as input that is filled with +random numbers from a uniform distribution on the interval \([0, 1)\). +torch_rand_like(input) is equivalent to +torch_rand(input.size(), dtype=input.dtype, layout=input.layout, device=input.device).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_randint.html b/reference/torch_randint.html new file mode 100644 index 0000000000000000000000000000000000000000..1b471858b6b6f5fca21d352ff7c08a1f9411a8d7 --- /dev/null +++ b/reference/torch_randint.html @@ -0,0 +1,255 @@ + + + + + + + + +Randint — torch_randint • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randint

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    low

    (int, optional) Lowest integer to be drawn from the distribution. Default: 0.

    high

    (int) One above the highest integer to be drawn from the distribution.

    size

    (tuple) a tuple defining the shape of the output tensor.

    generator

    (torch.Generator, optional) a pseudorandom number generator for sampling

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    randint(low=0, high, size, *, generator=None, out=None, \

    + + + + +

    dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    +

    Returns a tensor filled with random integers generated uniformly +between low (inclusive) and high (exclusive).

    +

    The shape of the tensor is defined by the variable argument size.

    +

    .. note: +With the global dtype default (torch_float32), this function returns +a tensor with dtype torch_int64.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_randint(3, 5, list(3)) +torch_randint(0, 10, size = list(2, 2)) +torch_randint(3, 10, list(2, 2)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_randint_like.html b/reference/torch_randint_like.html new file mode 100644 index 0000000000000000000000000000000000000000..aac459ebe9981f2710d0d75f7cd73c87f6799623 --- /dev/null +++ b/reference/torch_randint_like.html @@ -0,0 +1,244 @@ + + + + + + + + +Randint_like — torch_randint_like • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randint_like

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the size of input will determine size of the output tensor.

    low

    (int, optional) Lowest integer to be drawn from the distribution. Default: 0.

    high

    (int) One above the highest integer to be drawn from the distribution.

    dtype

    (torch.dtype, optional) the desired data type of returned Tensor. Default: if None, defaults to the dtype of input.

    layout

    (torch.layout, optional) the desired layout of returned tensor. Default: if None, defaults to the layout of input.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, defaults to the device of input.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_preserve_format.

    + +

    randint_like(input, low=0, high, dtype=None, layout=torch.strided, device=None, requires_grad=False,

    + + + + +

    memory_format=torch.preserve_format) -> Tensor

    +

    Returns a tensor with the same shape as Tensor input filled with +random integers generated uniformly between low (inclusive) and +high (exclusive).

    +

    .. note: +With the global dtype default (torch_float32), this function returns +a tensor with dtype torch_int64.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_randn.html b/reference/torch_randn.html new file mode 100644 index 0000000000000000000000000000000000000000..537b2f5cc077e1583aa1a47b0366ff50e0142742 --- /dev/null +++ b/reference/torch_randn.html @@ -0,0 +1,242 @@ + + + + + + + + +Randn — torch_randn • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randn

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    size

    (int...) a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    randn(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a tensor filled with random numbers from a normal distribution +with mean 0 and variance 1 (also called the standard normal +distribution).

    +

    $$ + \mbox{out}_{i} \sim \mathcal{N}(0, 1) +$$ +The shape of the tensor is defined by the variable argument size.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_randn(c(4)) +torch_randn(c(2, 3)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_randn_like.html b/reference/torch_randn_like.html new file mode 100644 index 0000000000000000000000000000000000000000..0b584a133068505fa31707572ea83184a69a9d60 --- /dev/null +++ b/reference/torch_randn_like.html @@ -0,0 +1,233 @@ + + + + + + + + +Randn_like — torch_randn_like • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randn_like

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the size of input will determine size of the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned Tensor. Default: if None, defaults to the dtype of input.

    layout

    (torch.layout, optional) the desired layout of returned tensor. Default: if None, defaults to the layout of input.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, defaults to the device of input.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_preserve_format.

    + +

    randn_like(input, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor

    + + + + +

    Returns a tensor with the same size as input that is filled with +random numbers from a normal distribution with mean 0 and variance 1. +torch_randn_like(input) is equivalent to +torch_randn(input.size(), dtype=input.dtype, layout=input.layout, device=input.device).

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_randperm.html b/reference/torch_randperm.html new file mode 100644 index 0000000000000000000000000000000000000000..50a510009556c61c28008b0824015a74f3efdca8 --- /dev/null +++ b/reference/torch_randperm.html @@ -0,0 +1,235 @@ + + + + + + + + +Randperm — torch_randperm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Randperm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    n

    (int) the upper bound (exclusive)

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: torch_int64.

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    randperm(n, out=None, dtype=torch.int64, layout=torch.strided, device=None, requires_grad=False) -> LongTensor

    + + + + +

    Returns a random permutation of integers from 0 to n - 1.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_randperm(4) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_range.html b/reference/torch_range.html new file mode 100644 index 0000000000000000000000000000000000000000..85365e828160be29cffdcdfa0443178503183840 --- /dev/null +++ b/reference/torch_range.html @@ -0,0 +1,254 @@ + + + + + + + + +Range — torch_range • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Range

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    start

    (float) the starting value for the set of points. Default: 0.

    end

    (float) the ending value for the set of points

    step

    (float) the gap between each pair of adjacent points. Default: 1.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type). If dtype is not given, infer the data type from the other input arguments. If any of start, end, or stop are floating-point, the dtype is inferred to be the default dtype, see ~torch.get_default_dtype. Otherwise, the dtype is inferred to be torch.int64.

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    range(start=0, end, step=1, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a 1-D tensor of size \(\left\lfloor \frac{\mbox{end} - \mbox{start}}{\mbox{step}} \right\rfloor + 1\) +with values from start to end with step step. Step is +the gap between two values in the tensor.

    +

    $$ + \mbox{out}_{i+1} = \mbox{out}_i + \mbox{step}. +$$

    +

    Warning

    + + + +

    This function is deprecated in favor of torch_arange.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_range(1, 4) +torch_range(1, 4, 0.5) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_real.html b/reference/torch_real.html new file mode 100644 index 0000000000000000000000000000000000000000..d58a9b10456ce1e91ff5d35659ad3872eba2f6a7 --- /dev/null +++ b/reference/torch_real.html @@ -0,0 +1,230 @@ + + + + + + + + +Real — torch_real • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Real

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    real(input, out=None) -> Tensor

    + + + + +

    Returns the real part of the input tensor. If +input is a real (non-complex) tensor, this function just +returns it.

    +

    Warning

    + + + +

    Not yet implemented for complex tensors.

    +

    $$ + \mbox{out}_{i} = real(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +torch_real(torch_tensor(c(-1 + 1i, -2 + 2i, 3 - 3i))) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_reciprocal.html b/reference/torch_reciprocal.html new file mode 100644 index 0000000000000000000000000000000000000000..a74cfe70a5f9ab01f8977db0a99436a549d0f6e2 --- /dev/null +++ b/reference/torch_reciprocal.html @@ -0,0 +1,224 @@ + + + + + + + + +Reciprocal — torch_reciprocal • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Reciprocal

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    reciprocal(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the reciprocal of the elements of input

    +

    $$ + \mbox{out}_{i} = \frac{1}{\mbox{input}_{i}} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_reciprocal(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_reduction.html b/reference/torch_reduction.html new file mode 100644 index 0000000000000000000000000000000000000000..02993c03299838010d04777d59c1afa1803ec1f2 --- /dev/null +++ b/reference/torch_reduction.html @@ -0,0 +1,201 @@ + + + + + + + + +Creates the reduction objet — torch_reduction • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Creates the reduction objet

    +
    + +
    torch_reduction_sum()
    +
    +torch_reduction_mean()
    +
    +torch_reduction_none()
    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_relu_.html b/reference/torch_relu_.html new file mode 100644 index 0000000000000000000000000000000000000000..5cffd040581284f479ca0ccc0af787fda2362e19 --- /dev/null +++ b/reference/torch_relu_.html @@ -0,0 +1,202 @@ + + + + + + + + +Relu_ — torch_relu_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Relu_

    +
    + + + +

    relu_(input) -> Tensor

    + + + + +

    In-place version of torch_relu.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_remainder.html b/reference/torch_remainder.html new file mode 100644 index 0000000000000000000000000000000000000000..42a5ec3e2ebb9f2668bf85527315aa752d666c62 --- /dev/null +++ b/reference/torch_remainder.html @@ -0,0 +1,228 @@ + + + + + + + + +Remainder — torch_remainder • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Remainder

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the dividend

    other

    (Tensor or float) the divisor that may be either a number or a Tensor of the same shape as the dividend

    out

    (Tensor, optional) the output tensor.

    + +

    remainder(input, other, out=None) -> Tensor

    + + + + +

    Computes the element-wise remainder of division.

    +

    The divisor and dividend may contain both for integer and floating point +numbers. The remainder has the same sign as the divisor.

    +

    When other is a tensor, the shapes of input and +other must be broadcastable .

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_remainder(torch_tensor(c(-3., -2, -1, 1, 2, 3)), 2) +torch_remainder(torch_tensor(c(1., 2, 3, 4, 5)), 1.5) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_renorm.html b/reference/torch_renorm.html new file mode 100644 index 0000000000000000000000000000000000000000..bf58e756b099f44a049e198718e6dade2cf77d0d --- /dev/null +++ b/reference/torch_renorm.html @@ -0,0 +1,239 @@ + + + + + + + + +Renorm — torch_renorm • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Renorm

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    p

    (float) the power for the norm computation

    dim

    (int) the dimension to slice over to get the sub-tensors

    maxnorm

    (float) the maximum norm to keep each sub-tensor under

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    If the norm of a row is lower than maxnorm, the row is unchanged

    +

    renorm(input, p, dim, maxnorm, out=None) -> Tensor

    + + + + +

    Returns a tensor where each sub-tensor of input along dimension +dim is normalized such that the p-norm of the sub-tensor is lower +than the value maxnorm

    + +

    Examples

    +
    if (torch_is_installed()) { +x = torch_ones(c(3, 3)) +x[2,]$fill_(2) +x[3,]$fill_(3) +x +torch_renorm(x, 1, 1, 5) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_repeat_interleave.html b/reference/torch_repeat_interleave.html new file mode 100644 index 0000000000000000000000000000000000000000..eb0271ec4a2c75a722ccbedbe9d0d7d7315124af --- /dev/null +++ b/reference/torch_repeat_interleave.html @@ -0,0 +1,243 @@ + + + + + + + + +Repeat_interleave — torch_repeat_interleave • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Repeat_interleave

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    repeats

    (Tensor or int) The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

    dim

    (int, optional) The dimension along which to repeat values. By default, use the flattened input array, and return a flat output array.

    + +

    repeat_interleave(input, repeats, dim=None) -> Tensor

    + + + + +

    Repeat elements of a tensor.

    +

    Warning

    + + +
    This is different from `torch_Tensor.repeat` but similar to ``numpy.repeat``.
    +
    + +

    repeat_interleave(repeats) -> Tensor

    + + + + +

    If the repeats is tensor([n1, n2, n3, ...]), then the output will be +tensor([0, 0, ..., 1, 1, ..., 2, 2, ..., ...]) where 0 appears n1 times, +1 appears n2 times, 2 appears n3 times, etc.

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +x = torch_tensor(c(1, 2, 3)) +x$repeat_interleave(2) +y = torch_tensor(matrix(c(1, 2, 3, 4), ncol = 2, byrow=TRUE)) +torch_repeat_interleave(y, 2) +torch_repeat_interleave(y, 3, dim=1) +torch_repeat_interleave(y, torch_tensor(c(1, 2)), dim=1) +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_reshape.html b/reference/torch_reshape.html new file mode 100644 index 0000000000000000000000000000000000000000..59ce4686deecd74402b68ead1fdb472e8176872a --- /dev/null +++ b/reference/torch_reshape.html @@ -0,0 +1,229 @@ + + + + + + + + +Reshape — torch_reshape • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Reshape

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the tensor to be reshaped

    shape

    (tuple of ints) the new shape

    + +

    reshape(input, shape) -> Tensor

    + + + + +

    Returns a tensor with the same data and number of elements as input, +but with the specified shape. When possible, the returned tensor will be a view +of input. Otherwise, it will be a copy. Contiguous inputs and inputs +with compatible strides can be reshaped without copying, but you should not +depend on the copying vs. viewing behavior.

    +

    See torch_Tensor.view on when it is possible to return a view.

    +

    A single dimension may be -1, in which case it's inferred from the remaining +dimensions and the number of elements in input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_arange(0, 4) +torch_reshape(a, list(2, 2)) +b = torch_tensor(matrix(c(0, 1, 2, 3), ncol = 2, byrow=TRUE)) +torch_reshape(b, list(-1)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_result_type.html b/reference/torch_result_type.html new file mode 100644 index 0000000000000000000000000000000000000000..231d9d03e515836292eff0e75a2567c0ae266ff3 --- /dev/null +++ b/reference/torch_result_type.html @@ -0,0 +1,221 @@ + + + + + + + + +Result_type — torch_result_type • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Result_type

    +
    + + +

    Arguments

    + + + + + + + + + + +
    tensor1

    (Tensor or Number) an input tensor or number

    tensor2

    (Tensor or Number) an input tensor or number

    + +

    result_type(tensor1, tensor2) -> dtype

    + + + + +

    Returns the torch_dtype that would result from performing an arithmetic +operation on the provided input tensors. See type promotion documentation +for more information on the type promotion logic.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_result_type(tensor = torch_tensor(c(1, 2), dtype=torch_int()), 1.0) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_rfft.html b/reference/torch_rfft.html new file mode 100644 index 0000000000000000000000000000000000000000..3294dff22ea8901d358a57a81c3bbf820748c131 --- /dev/null +++ b/reference/torch_rfft.html @@ -0,0 +1,265 @@ + + + + + + + + +Rfft — torch_rfft • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Rfft

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of at least signal_ndim dimensions

    signal_ndim

    (int) the number of dimensions in each signal. signal_ndim can only be 1, 2 or 3

    normalized

    (bool, optional) controls whether to return normalized results. Default: False

    onesided

    (bool, optional) controls whether to return half of results to avoid redundancy. Default: True

    + +

    Note

    + + +
    For CUDA tensors, an LRU cache is used for cuFFT plans to speed up
    +repeatedly running FFT methods on tensors of same geometry with same
    +configuration. See cufft-plan-cache for more details on how to
    +monitor and control the cache.
    +
    + +

    rfft(input, signal_ndim, normalized=False, onesided=True) -> Tensor

    + + + + +

    Real-to-complex Discrete Fourier Transform

    +

    This method computes the real-to-complex discrete Fourier transform. It is +mathematically equivalent with torch_fft with differences only in +formats of the input and output.

    +

    This method supports 1D, 2D and 3D real-to-complex transforms, indicated +by signal_ndim. input must be a tensor with at least +signal_ndim dimensions with optionally arbitrary number of leading batch +dimensions. If normalized is set to True, this normalizes the result +by dividing it with \(\sqrt{\prod_{i=1}^K N_i}\) so that the operator is +unitary, where \(N_i\) is the size of signal dimension \(i\).

    +

    The real-to-complex Fourier transform results follow conjugate symmetry:

    +

    $$ + X[\omega_1, \dots, \omega_d] = X^*[N_1 - \omega_1, \dots, N_d - \omega_d], +$$ +where the index arithmetic is computed modulus the size of the corresponding +dimension, \(\ ^*\) is the conjugate operator, and +\(d\) = signal_ndim. onesided flag controls whether to avoid +redundancy in the output results. If set to True (default), the output will +not be full complex result of shape \((*, 2)\), where \(*\) is the shape +of input, but instead the last dimension will be halfed as of size +\(\lfloor \frac{N_d}{2} \rfloor + 1\).

    +

    The inverse of this function is torch_irfft.

    +

    Warning

    + + + +

    For CPU tensors, this method is currently only available with MKL. Use +torch_backends.mkl.is_available to check if MKL is installed.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(5, 5)) +torch_rfft(x, 2) +torch_rfft(x, 2, onesided=FALSE) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_roll.html b/reference/torch_roll.html new file mode 100644 index 0000000000000000000000000000000000000000..714a92c08c2ba022edf913487467af1fbde18a12 --- /dev/null +++ b/reference/torch_roll.html @@ -0,0 +1,230 @@ + + + + + + + + +Roll — torch_roll • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Roll

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    shifts

    (int or tuple of ints) The number of places by which the elements of the tensor are shifted. If shifts is a tuple, dims must be a tuple of the same size, and each dimension will be rolled by the corresponding value

    dims

    (int or tuple of ints) Axis along which to roll

    + +

    roll(input, shifts, dims=None) -> Tensor

    + + + + +

    Roll the tensor along the given dimension(s). Elements that are shifted beyond the +last position are re-introduced at the first position. If a dimension is not +specified, the tensor will be flattened before rolling and then restored +to the original shape.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_tensor(c(1, 2, 3, 4, 5, 6, 7, 8))$view(c(4, 2)) +x +torch_roll(x, 1, 1) +torch_roll(x, -1, 1) +torch_roll(x, shifts=list(2, 1), dims=list(1, 2)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_rot90.html b/reference/torch_rot90.html new file mode 100644 index 0000000000000000000000000000000000000000..03d739ff9e8f1de50bcd9eaf20e71c21357732d6 --- /dev/null +++ b/reference/torch_rot90.html @@ -0,0 +1,229 @@ + + + + + + + + +Rot90 — torch_rot90 • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Rot90

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    k

    (int) number of times to rotate

    dims

    (a list or tuple) axis to rotate

    + +

    rot90(input, k, dims) -> Tensor

    + + + + +

    Rotate a n-D tensor by 90 degrees in the plane specified by dims axis. +Rotation direction is from the first towards the second axis if k > 0, and from the second towards the first for k < 0.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_arange(0, 4)$view(c(2, 2)) +x +torch_rot90(x, 1, c(1, 2)) +x = torch_arange(0, 8)$view(c(2, 2, 2)) +x +torch_rot90(x, 1, c(1, 2)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_round.html b/reference/torch_round.html new file mode 100644 index 0000000000000000000000000000000000000000..e4479b4d22fa249ea5c4c95c4e3ff70d8e5d5b79 --- /dev/null +++ b/reference/torch_round.html @@ -0,0 +1,222 @@ + + + + + + + + +Round — torch_round • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Round

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    round(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with each of the elements of input rounded +to the closest integer.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_round(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_rrelu_.html b/reference/torch_rrelu_.html new file mode 100644 index 0000000000000000000000000000000000000000..c17dadfc0a98e5d6c3d4994a9d19c5c49aa01086 --- /dev/null +++ b/reference/torch_rrelu_.html @@ -0,0 +1,202 @@ + + + + + + + + +Rrelu_ — torch_rrelu_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Rrelu_

    +
    + + + +

    rrelu_(input, lower=1./8, upper=1./3, training=False) -> Tensor

    + + + + +

    In-place version of torch_rrelu.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_rsqrt.html b/reference/torch_rsqrt.html new file mode 100644 index 0000000000000000000000000000000000000000..e872b498f43a8093a3ba2749f87696969ca8cb3e --- /dev/null +++ b/reference/torch_rsqrt.html @@ -0,0 +1,225 @@ + + + + + + + + +Rsqrt — torch_rsqrt • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Rsqrt

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    rsqrt(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the reciprocal of the square-root of each of +the elements of input.

    +

    $$ + \mbox{out}_{i} = \frac{1}{\sqrt{\mbox{input}_{i}}} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_rsqrt(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_save.html b/reference/torch_save.html new file mode 100644 index 0000000000000000000000000000000000000000..c883bd5df7da0b6984ca05e3afdb9b373997891c --- /dev/null +++ b/reference/torch_save.html @@ -0,0 +1,219 @@ + + + + + + + + +Saves an object to a disk file. — torch_save • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This function is experimental, don't use for long +term storage.

    +
    + +
    torch_save(obj, path, ...)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    obj

    the saved object

    path

    a connection or the name of the file to save.

    ...

    not currently used.

    + +

    See also

    + +

    Other torch_save: +torch_load()

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_selu_.html b/reference/torch_selu_.html new file mode 100644 index 0000000000000000000000000000000000000000..685e6cfa8ccc7305aac695a97c5a513daefb2eaf --- /dev/null +++ b/reference/torch_selu_.html @@ -0,0 +1,202 @@ + + + + + + + + +Selu_ — torch_selu_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Selu_

    +
    + + + +

    selu_(input) -> Tensor

    + + + + +

    In-place version of toch_selu.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sigmoid.html b/reference/torch_sigmoid.html new file mode 100644 index 0000000000000000000000000000000000000000..dc01cb329e7179c975b0ddfbe918f3bb5f91961e --- /dev/null +++ b/reference/torch_sigmoid.html @@ -0,0 +1,224 @@ + + + + + + + + +Sigmoid — torch_sigmoid • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sigmoid

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    sigmoid(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the sigmoid of the elements of input.

    +

    $$ + \mbox{out}_{i} = \frac{1}{1 + e^{-\mbox{input}_{i}}} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_sigmoid(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sign.html b/reference/torch_sign.html new file mode 100644 index 0000000000000000000000000000000000000000..b82124b256722ae711a0bb3f845666a4c6c337fd --- /dev/null +++ b/reference/torch_sign.html @@ -0,0 +1,224 @@ + + + + + + + + +Sign — torch_sign • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sign

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    sign(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the signs of the elements of input.

    +

    $$ + \mbox{out}_{i} = \mbox{sgn}(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_tensor(c(0.7, -1.2, 0., 2.3)) +a +torch_sign(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sin.html b/reference/torch_sin.html new file mode 100644 index 0000000000000000000000000000000000000000..2a816b49ac1d09648325e0f196b58040e575a1ff --- /dev/null +++ b/reference/torch_sin.html @@ -0,0 +1,224 @@ + + + + + + + + +Sin — torch_sin • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sin

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    sin(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the sine of the elements of input.

    +

    $$ + \mbox{out}_{i} = \sin(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_sin(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sinh.html b/reference/torch_sinh.html new file mode 100644 index 0000000000000000000000000000000000000000..2047475c78cbbacda79246ee3d722ea3514b4777 --- /dev/null +++ b/reference/torch_sinh.html @@ -0,0 +1,225 @@ + + + + + + + + +Sinh — torch_sinh • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sinh

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    sinh(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the hyperbolic sine of the elements of +input.

    +

    $$ + \mbox{out}_{i} = \sinh(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_sinh(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_slogdet.html b/reference/torch_slogdet.html new file mode 100644 index 0000000000000000000000000000000000000000..582ef4d856c162c6d23946747b465096c1a179ae --- /dev/null +++ b/reference/torch_slogdet.html @@ -0,0 +1,231 @@ + + + + + + + + +Slogdet — torch_slogdet • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Slogdet

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) the input tensor of size (*, n, n) where * is zero or more batch dimensions.

    + +

    Note

    + + +
    If ``input`` has zero determinant, this returns ``(0, -inf)``.
    +
    + +
    Backward through `slogdet` internally uses SVD results when `input`
    +is not invertible. In this case, double backward through `slogdet`
    +will be unstable in when `input` doesn't have distinct singular values.
    +See `~torch.svd` for details.
    +
    + +

    slogdet(input) -> (Tensor, Tensor)

    + + + + +

    Calculates the sign and log absolute value of the determinant(s) of a square matrix or batches of square matrices.

    + +

    Examples

    +
    if (torch_is_installed()) { + +A = torch_randn(c(3, 3)) +A +torch_det(A) +torch_logdet(A) +torch_slogdet(A) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_solve.html b/reference/torch_solve.html new file mode 100644 index 0000000000000000000000000000000000000000..fa7d8806ae3ee49e1714cc48f506e0156630f5f0 --- /dev/null +++ b/reference/torch_solve.html @@ -0,0 +1,256 @@ + + + + + + + + +Solve — torch_solve • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Solve

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) input matrix \(B\) of size \((*, m, k)\) , where \(*\) is zero or more batch dimensions.

    A

    (Tensor) input square matrix of size \((*, m, m)\), where \(*\) is zero or more batch dimensions.

    out

    ((Tensor, Tensor) optional output tuple.

    + +

    Note

    + + +
    Irrespective of the original strides, the returned matrices
    +`solution` and `LU` will be transposed, i.e. with strides like
    +`B.contiguous().transpose(-1, -2).stride()` and
    +`A.contiguous().transpose(-1, -2).stride()` respectively.
    +
    + +

    torch.solve(input, A, out=None) -> (Tensor, Tensor)

    + + + + +

    This function returns the solution to the system of linear +equations represented by \(AX = B\) and the LU factorization of +A, in order as a namedtuple solution, LU.

    +

    LU contains L and U factors for LU factorization of A.

    +

    torch_solve(B, A) can take in 2D inputs B, A or inputs that are +batches of 2D matrices. If the inputs are batches, then returns +batched outputs solution, LU.

    + +

    Examples

    +
    if (torch_is_installed()) { + +A = torch_tensor(rbind(c(6.80, -2.11, 5.66, 5.97, 8.23), + c(-6.05, -3.30, 5.36, -4.44, 1.08), + c(-0.45, 2.58, -2.70, 0.27, 9.04), + c(8.32, 2.71, 4.35, -7.17, 2.14), + c(-9.67, -5.14, -7.26, 6.08, -6.87)))$t() +B = torch_tensor(rbind(c(4.02, 6.19, -8.22, -7.57, -3.03), + c(-1.56, 4.00, -8.67, 1.75, 2.86), + c(9.81, -4.09, -4.57, -8.61, 8.99)))$t() +out = torch_solve(B, A) +X = out[[1]] +LU = out[[2]] +torch_dist(B, torch_mm(A, X)) +# Batched solver example +A = torch_randn(c(2, 3, 1, 4, 4)) +B = torch_randn(c(2, 3, 1, 4, 6)) +out = torch_solve(B, A) +X = out[[1]] +LU = out[[2]] +torch_dist(B, A$matmul(X)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sort.html b/reference/torch_sort.html new file mode 100644 index 0000000000000000000000000000000000000000..9c3ce03025c6777dd47cab77ca17849a294d00e5 --- /dev/null +++ b/reference/torch_sort.html @@ -0,0 +1,238 @@ + + + + + + + + +Sort — torch_sort • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sort

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int, optional) the dimension to sort along

    descending

    (bool, optional) controls the sorting order (ascending or descending)

    out

    (tuple, optional) the output tuple of (Tensor, LongTensor) that can be optionally given to be used as output buffers

    + +

    sort(input, dim=-1, descending=False, out=None) -> (Tensor, LongTensor)

    + + + + +

    Sorts the elements of the input tensor along a given dimension +in ascending order by value.

    +

    If dim is not given, the last dimension of the input is chosen.

    +

    If descending is True then the elements are sorted in descending +order by value.

    +

    A namedtuple of (values, indices) is returned, where the values are the +sorted values and indices are the indices of the elements in the original +input tensor.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(3, 4)) +out = torch_sort(x) +out +out = torch_sort(x, 1) +out +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sparse_coo_tensor.html b/reference/torch_sparse_coo_tensor.html new file mode 100644 index 0000000000000000000000000000000000000000..b6d1b28fc2f8fd05f7b74ad450f9cd568f7c4f54 --- /dev/null +++ b/reference/torch_sparse_coo_tensor.html @@ -0,0 +1,253 @@ + + + + + + + + +Sparse_coo_tensor — torch_sparse_coo_tensor • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sparse_coo_tensor

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    indices

    (array_like) Initial data for the tensor. Can be a list, tuple, NumPy ndarray, scalar, and other types. Will be cast to a torch_LongTensor internally. The indices are the coordinates of the non-zero values in the matrix, and thus should be two-dimensional where the first dimension is the number of tensor dimensions and the second dimension is the number of non-zero values.

    values

    (array_like) Initial values for the tensor. Can be a list, tuple, NumPy ndarray, scalar, and other types.

    size

    (list, tuple, or torch.Size, optional) Size of the sparse tensor. If not provided the size will be inferred as the minimum size big enough to hold all non-zero elements.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, infers data type from values.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    sparse_coo_tensor(indices, values, size=None, dtype=None, device=None, requires_grad=False) -> Tensor

    + + + + +

    Constructs a sparse tensors in COO(rdinate) format with non-zero elements at the given indices +with the given values. A sparse tensor can be uncoalesced, in that case, there are duplicate +coordinates in the indices, and the value at that index is the sum of all duplicate value entries: +torch_sparse_.

    + +

    Examples

    +
    if (torch_is_installed()) { + +i = torch_tensor(matrix(c(1, 2, 2, 3, 1, 3), ncol = 3, byrow = TRUE), dtype=torch_int64()) +v = torch_tensor(c(3, 4, 5), dtype=torch_float32()) +torch_sparse_coo_tensor(i, v) +torch_sparse_coo_tensor(i, v, c(2, 4)) + +# create empty sparse tensors +S = torch_sparse_coo_tensor( + torch_empty(c(1, 0), dtype = torch_int64()), + torch_tensor(numeric(), dtype = torch_float32()), + c(1) +) +S = torch_sparse_coo_tensor( + torch_empty(c(1, 0), dtype = torch_int64()), + torch_empty(c(0, 2)), + c(1, 2) +) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_split.html b/reference/torch_split.html new file mode 100644 index 0000000000000000000000000000000000000000..826e94241239cdbe72b3b31189748c1cd83f0fa1 --- /dev/null +++ b/reference/torch_split.html @@ -0,0 +1,227 @@ + + + + + + + + +Split — torch_split • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Split

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    tensor

    (Tensor) tensor to split.

    split_size_or_sections

    (int) size of a single chunk or list of sizes for each chunk

    dim

    (int) dimension along which to split the tensor.

    + +

    TEST

    + + + + +

    Splits the tensor into chunks. Each chunk is a view of the original tensor.

    If `split_size_or_sections` is an integer type, then `tensor` will
    +be split into equally sized chunks (if possible). Last chunk will be smaller if
    +the tensor size along the given dimension `dim` is not divisible by
    +`split_size`.
    +
    +If `split_size_or_sections` is a list, then `tensor` will be split
    +into ``len(split_size_or_sections)`` chunks with sizes in `dim` according
    +to `split_size_or_sections`.
    +
    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sqrt.html b/reference/torch_sqrt.html new file mode 100644 index 0000000000000000000000000000000000000000..e0b4f7c3bdc843b55890afa1ed65c70b1204d53e --- /dev/null +++ b/reference/torch_sqrt.html @@ -0,0 +1,224 @@ + + + + + + + + +Sqrt — torch_sqrt • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sqrt

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    sqrt(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the square-root of the elements of input.

    +

    $$ + \mbox{out}_{i} = \sqrt{\mbox{input}_{i}} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_sqrt(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_square.html b/reference/torch_square.html new file mode 100644 index 0000000000000000000000000000000000000000..c20402d73f335c613db7505b6e5962b1dd1f67b0 --- /dev/null +++ b/reference/torch_square.html @@ -0,0 +1,221 @@ + + + + + + + + +Square — torch_square • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Square

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    square(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the square of the elements of input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_square(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_squeeze.html b/reference/torch_squeeze.html new file mode 100644 index 0000000000000000000000000000000000000000..8368d121adf75a39a28a81a51ee8cb5f07f519b8 --- /dev/null +++ b/reference/torch_squeeze.html @@ -0,0 +1,241 @@ + + + + + + + + +Squeeze — torch_squeeze • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Squeeze

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int, optional) if given, the input will be squeezed only in this dimension

    out

    (Tensor, optional) the output tensor.

    + +

    Note

    + +

    The returned tensor shares the storage with the input tensor, +so changing the contents of one will change the contents of the other.

    +

    squeeze(input, dim=None, out=None) -> Tensor

    + + + + +

    Returns a tensor with all the dimensions of input of size 1 removed.

    +

    For example, if input is of shape: +\((A \times 1 \times B \times C \times 1 \times D)\) then the out tensor +will be of shape: \((A \times B \times C \times D)\).

    +

    When dim is given, a squeeze operation is done only in the given +dimension. If input is of shape: \((A \times 1 \times B)\), +squeeze(input, 0) leaves the tensor unchanged, but squeeze(input, 1) +will squeeze the tensor to the shape \((A \times B)\).

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_zeros(c(2, 1, 2, 1, 2)) +x +y = torch_squeeze(x) +y +y = torch_squeeze(x, 1) +y +y = torch_squeeze(x, 2) +y +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_stack.html b/reference/torch_stack.html new file mode 100644 index 0000000000000000000000000000000000000000..7af361470287ab8b4518c270c514f23da79c331d --- /dev/null +++ b/reference/torch_stack.html @@ -0,0 +1,219 @@ + + + + + + + + +Stack — torch_stack • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Stack

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    tensors

    (sequence of Tensors) sequence of tensors to concatenate

    dim

    (int) dimension to insert. Has to be between 0 and the number of dimensions of concatenated tensors (inclusive)

    out

    (Tensor, optional) the output tensor.

    + +

    stack(tensors, dim=0, out=None) -> Tensor

    + + + + +

    Concatenates sequence of tensors along a new dimension.

    +

    All tensors need to be of the same size.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_std.html b/reference/torch_std.html new file mode 100644 index 0000000000000000000000000000000000000000..fd0c1066b87c2af6ca9b1cc74703a5b03b27f861 --- /dev/null +++ b/reference/torch_std.html @@ -0,0 +1,254 @@ + + + + + + + + +Std — torch_std • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Std

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    unbiased

    (bool) whether to use the unbiased estimation or not

    dim

    (int or tuple of ints) the dimension or dimensions to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (Tensor, optional) the output tensor.

    + +

    std(input, unbiased=True) -> Tensor

    + + + + +

    Returns the standard-deviation of all elements in the input tensor.

    +

    If unbiased is False, then the standard-deviation will be calculated +via the biased estimator. Otherwise, Bessel's correction will be used.

    +

    std(input, dim, unbiased=True, keepdim=False, out=None) -> Tensor

    + + + + +

    Returns the standard-deviation of each row of the input tensor in the +dimension dim. If dim is a list of dimensions, +reduce over all of them.

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension(s) dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in the +output tensor having 1 (or len(dim)) fewer dimension(s).

    +

    If unbiased is False, then the standard-deviation will be calculated +via the biased estimator. Otherwise, Bessel's correction will be used.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_std(a) + + +a = torch_randn(c(4, 4)) +a +torch_std(a, dim=1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_std_mean.html b/reference/torch_std_mean.html new file mode 100644 index 0000000000000000000000000000000000000000..b8a1c9d10ea3e55dff8513f8ca1accdd67d6f1ee --- /dev/null +++ b/reference/torch_std_mean.html @@ -0,0 +1,250 @@ + + + + + + + + +Std_mean — torch_std_mean • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Std_mean

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    unbiased

    (bool) whether to use the unbiased estimation or not

    dim

    (int or tuple of ints) the dimension or dimensions to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    + +

    std_mean(input, unbiased=True) -> (Tensor, Tensor)

    + + + + +

    Returns the standard-deviation and mean of all elements in the input tensor.

    +

    If unbiased is False, then the standard-deviation will be calculated +via the biased estimator. Otherwise, Bessel's correction will be used.

    +

    std_mean(input, dim, unbiased=True, keepdim=False) -> (Tensor, Tensor)

    + + + + +

    Returns the standard-deviation and mean of each row of the input tensor in the +dimension dim. If dim is a list of dimensions, +reduce over all of them.

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension(s) dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in the +output tensor having 1 (or len(dim)) fewer dimension(s).

    +

    If unbiased is False, then the standard-deviation will be calculated +via the biased estimator. Otherwise, Bessel's correction will be used.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_std_mean(a) + + +a = torch_randn(c(4, 4)) +a +torch_std_mean(a, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_stft.html b/reference/torch_stft.html new file mode 100644 index 0000000000000000000000000000000000000000..7084d55dcc5d7ff8eb16a00edf9da7883788fc80 --- /dev/null +++ b/reference/torch_stft.html @@ -0,0 +1,296 @@ + + + + + + + + +Stft — torch_stft • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Stft

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor

    n_fft

    (int) size of Fourier transform

    hop_length

    (int, optional) the distance between neighboring sliding window frames. Default: None (treated as equal to floor(n_fft / 4))

    win_length

    (int, optional) the size of window frame and STFT filter. Default: None (treated as equal to n_fft)

    window

    (Tensor, optional) the optional window function. Default: None (treated as window of all \(1\) s)

    center

    (bool, optional) whether to pad input on both sides so that the \(t\)-th frame is centered at time \(t \times \mbox{hop\_length}\). Default: True

    pad_mode

    (string, optional) controls the padding method used when center is True. Default: "reflect"

    normalized

    (bool, optional) controls whether to return the normalized STFT results Default: False

    onesided

    (bool, optional) controls whether to return half of results to avoid redundancy Default: True

    + +

    Short-time Fourier transform (STFT).

    + + + + +

    Short-time Fourier transform (STFT).

    Ignoring the optional batch dimension, this method computes the following
    +expression:
    +
    + +

    $$ + X[m, \omega] = \sum_{k = 0}^{\mbox{win\_length-1}}% + \mbox{window}[k]\ \mbox{input}[m \times \mbox{hop\_length} + k]\ % + \exp\left(- j \frac{2 \pi \cdot \omega k}{\mbox{win\_length}}\right), +$$ +where \(m\) is the index of the sliding window, and \(\omega\) is +the frequency that \(0 \leq \omega < \mbox{n\_fft}\). When +onesided is the default value True,

    * `input` must be either a 1-D time sequence or a 2-D batch of time
    +  sequences.
    +
    +* If `hop_length` is ``None`` (default), it is treated as equal to
    +  ``floor(n_fft / 4)``.
    +
    +* If `win_length` is ``None`` (default), it is treated as equal to
    +  `n_fft`.
    +
    +* `window` can be a 1-D tensor of size `win_length`, e.g., from
    +  `torch_hann_window`. If `window` is ``None`` (default), it is
    +  treated as if having \eqn{1} everywhere in the window. If
    +  \eqn{\mbox{win\_length} &lt; \mbox{n\_fft}}, `window` will be padded on
    +  both sides to length `n_fft` before being applied.
    +
    +* If `center` is ``True`` (default), `input` will be padded on
    +  both sides so that the \eqn{t}-th frame is centered at time
    +  \eqn{t \times \mbox{hop\_length}}. Otherwise, the \eqn{t}-th frame
    +  begins at time  \eqn{t \times \mbox{hop\_length}}.
    +
    +* `pad_mode` determines the padding method used on `input` when
    +  `center` is ``True``. See `torch_nn.functional.pad` for
    +  all available options. Default is ``"reflect"``.
    +
    +* If `onesided` is ``True`` (default), only values for \eqn{\omega}
    +  in \eqn{\left[0, 1, 2, \dots, \left\lfloor \frac{\mbox{n\_fft}}{2} \right\rfloor + 1\right]}
    +  are returned because the real-to-complex Fourier transform satisfies the
    +  conjugate symmetry, i.e., \eqn{X[m, \omega] = X[m, \mbox{n\_fft} - \omega]^*}.
    +
    +* If `normalized` is ``True`` (default is ``False``), the function
    +  returns the normalized STFT results, i.e., multiplied by \eqn{(\mbox{frame\_length})^{-0.5}}.
    +
    +Returns the real and the imaginary parts together as one tensor of size
    +\eqn{(* \times N \times T \times 2)}, where \eqn{*} is the optional
    +batch size of `input`, \eqn{N} is the number of frequencies where
    +STFT is applied, \eqn{T} is the total number of frames used, and each pair
    +in the last dimension represents a complex number as the real part and the
    +imaginary part.
    +
    +.. warning::
    +  This function changed signature at version 0.4.1. Calling with the
    +  previous signature may cause error or return incorrect result.
    +
    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_sum.html b/reference/torch_sum.html new file mode 100644 index 0000000000000000000000000000000000000000..3f4cfe1203cb4634a70d6766d82f625a54108339 --- /dev/null +++ b/reference/torch_sum.html @@ -0,0 +1,248 @@ + + + + + + + + +Sum — torch_sum • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Sum

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.

    dim

    (int or tuple of ints) the dimension or dimensions to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    + +

    sum(input, dtype=None) -> Tensor

    + + + + +

    Returns the sum of all elements in the input tensor.

    +

    sum(input, dim, keepdim=False, dtype=None) -> Tensor

    + + + + +

    Returns the sum of each row of the input tensor in the given +dimension dim. If dim is a list of dimensions, +reduce over all of them.

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension(s) dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in the +output tensor having 1 (or len(dim)) fewer dimension(s).

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_sum(a) + + +a = torch_randn(c(4, 4)) +a +torch_sum(a, 1) +b = torch_arange(0, 4 * 5 * 6)$view(c(4, 5, 6)) +torch_sum(b, list(2, 1)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_svd.html b/reference/torch_svd.html new file mode 100644 index 0000000000000000000000000000000000000000..0effce248c0523ad788eebaebac1fbc245a072fd --- /dev/null +++ b/reference/torch_svd.html @@ -0,0 +1,266 @@ + + + + + + + + +Svd — torch_svd • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Svd

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of size \((*, m, n)\) where * is zero or more batch dimensions consisting of \(m \times n\) matrices.

    some

    (bool, optional) controls the shape of returned U and V

    compute_uv

    (bool, optional) option whether to compute U and V or not

    out

    (tuple, optional) the output tuple of tensors

    + +

    Note

    + +

    The singular values are returned in descending order. If input is a batch of matrices, +then the singular values of each matrix in the batch is returned in descending order.

    +

    The implementation of SVD on CPU uses the LAPACK routine ?gesdd (a divide-and-conquer +algorithm) instead of ?gesvd for speed. Analogously, the SVD on GPU uses the MAGMA routine +gesdd as well.

    +

    Irrespective of the original strides, the returned matrix U +will be transposed, i.e. with strides U.contiguous().transpose(-2, -1).stride()

    +

    Extra care needs to be taken when backward through U and V +outputs. Such operation is really only stable when input is +full rank with all distinct singular values. Otherwise, NaN can +appear as the gradients are not properly defined. Also, notice that +double backward will usually do an additional backward through U and +V even if the original backward is only on S.

    +

    When some = False, the gradients on U[..., :, min(m, n):] +and V[..., :, min(m, n):] will be ignored in backward as those vectors +can be arbitrary bases of the subspaces.

    +

    When compute_uv = False, backward cannot be performed since U and V +from the forward pass is required for the backward operation.

    +

    svd(input, some=True, compute_uv=True, out=None) -> (Tensor, Tensor, Tensor)

    + + + + +

    This function returns a namedtuple (U, S, V) which is the singular value +decomposition of a input real matrix or batches of real matrices input such that +\(input = U \times diag(S) \times V^T\).

    +

    If some is True (default), the method returns the reduced singular value decomposition +i.e., if the last two dimensions of input are m and n, then the returned +U and V matrices will contain only \(min(n, m)\) orthonormal columns.

    +

    If compute_uv is False, the returned U and V matrices will be zero matrices +of shape \((m \times m)\) and \((n \times n)\) respectively. some will be ignored here.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(5, 3)) +a +out = torch_svd(a) +u = out[[1]] +s = out[[2]] +v = out[[3]] +torch_dist(a, torch_mm(torch_mm(u, torch_diag(s)), v$t())) +a_big = torch_randn(c(7, 5, 3)) +out = torch_svd(a_big) +u = out[[1]] +s = out[[2]] +v = out[[3]] +torch_dist(a_big, torch_matmul(torch_matmul(u, torch_diag_embed(s)), v$transpose(-2, -1))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_symeig.html b/reference/torch_symeig.html new file mode 100644 index 0000000000000000000000000000000000000000..cd6b67d07daeb8fe685830612a844f5abad27a08 --- /dev/null +++ b/reference/torch_symeig.html @@ -0,0 +1,260 @@ + + + + + + + + +Symeig — torch_symeig • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Symeig

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor of size \((*, n, n)\) where * is zero or more batch dimensions consisting of symmetric matrices.

    eigenvectors

    (boolean, optional) controls whether eigenvectors have to be computed

    upper

    (boolean, optional) controls whether to consider upper-triangular or lower-triangular region

    out

    (tuple, optional) the output tuple of (Tensor, Tensor)

    + +

    Note

    + +

    The eigenvalues are returned in ascending order. If input is a batch of matrices, +then the eigenvalues of each matrix in the batch is returned in ascending order.

    +

    Irrespective of the original strides, the returned matrix V will +be transposed, i.e. with strides V.contiguous().transpose(-1, -2).stride().

    +

    Extra care needs to be taken when backward through outputs. Such +operation is really only stable when all eigenvalues are distinct. +Otherwise, NaN can appear as the gradients are not properly defined.

    +

    symeig(input, eigenvectors=False, upper=True, out=None) -> (Tensor, Tensor)

    + + + + +

    This function returns eigenvalues and eigenvectors +of a real symmetric matrix input or a batch of real symmetric matrices, +represented by a namedtuple (eigenvalues, eigenvectors).

    +

    This function calculates all eigenvalues (and vectors) of input +such that \(\mbox{input} = V \mbox{diag}(e) V^T\).

    +

    The boolean argument eigenvectors defines computation of +both eigenvectors and eigenvalues or eigenvalues only.

    +

    If it is False, only eigenvalues are computed. If it is True, +both eigenvalues and eigenvectors are computed.

    +

    Since the input matrix input is supposed to be symmetric, +only the upper triangular portion is used by default.

    +

    If upper is False, then lower triangular portion is used.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(5, 5)) +a = a + a$t() # To make a symmetric +a +o = torch_symeig(a, eigenvectors=TRUE) +e = o[[1]] +v = o[[2]] +e +v +a_big = torch_randn(c(5, 2, 2)) +a_big = a_big + a_big$transpose(-2, -1) # To make a_big symmetric +o = a_big$symeig(eigenvectors=TRUE) +e = o[[1]] +v = o[[2]] +torch_allclose(torch_matmul(v, torch_matmul(e$diag_embed(), v$transpose(-2, -1))), a_big) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_t.html b/reference/torch_t.html new file mode 100644 index 0000000000000000000000000000000000000000..6c1cf8d2dcced4c8c157f584e69a68b157ec926c --- /dev/null +++ b/reference/torch_t.html @@ -0,0 +1,226 @@ + + + + + + + + +T — torch_t • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    T

    +
    + + +

    Arguments

    + + + + + + +
    input

    (Tensor) the input tensor.

    + +

    t(input) -> Tensor

    + + + + +

    Expects input to be <= 2-D tensor and transposes dimensions 0 +and 1.

    +

    0-D and 1-D tensors are returned as is. When input is a 2-D tensor this +is equivalent to transpose(input, 0, 1).

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(2,3)) +x +torch_t(x) +x = torch_randn(c(3)) +x +torch_t(x) +x = torch_randn(c(2, 3)) +x +torch_t(x) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_take.html b/reference/torch_take.html new file mode 100644 index 0000000000000000000000000000000000000000..1ec9aea7f3dde63e5368d6882c66df7b1bc39bba --- /dev/null +++ b/reference/torch_take.html @@ -0,0 +1,222 @@ + + + + + + + + +Take — torch_take • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Take

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    indices

    (LongTensor) the indices into tensor

    + +

    take(input, index) -> Tensor

    + + + + +

    Returns a new tensor with the elements of input at the given indices. +The input tensor is treated as if it were viewed as a 1-D tensor. The result +takes the same shape as the indices.

    + +

    Examples

    +
    if (torch_is_installed()) { + +src = torch_tensor(matrix(c(4,3,5,6,7,8), ncol = 3, byrow = TRUE)) +torch_take(src, torch_tensor(c(1, 2, 5), dtype = torch_int64())) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_tan.html b/reference/torch_tan.html new file mode 100644 index 0000000000000000000000000000000000000000..17d0d0229650f47741ab413504a8eeced1ac36f7 --- /dev/null +++ b/reference/torch_tan.html @@ -0,0 +1,224 @@ + + + + + + + + +Tan — torch_tan • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Tan

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    tan(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the tangent of the elements of input.

    +

    $$ + \mbox{out}_{i} = \tan(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_tan(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_tanh.html b/reference/torch_tanh.html new file mode 100644 index 0000000000000000000000000000000000000000..e9e950dabf6bbbb5d19196adda0953c04357753d --- /dev/null +++ b/reference/torch_tanh.html @@ -0,0 +1,225 @@ + + + + + + + + +Tanh — torch_tanh • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Tanh

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    tanh(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the hyperbolic tangent of the elements +of input.

    +

    $$ + \mbox{out}_{i} = \tanh(\mbox{input}_{i}) +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_tanh(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_tensor.html b/reference/torch_tensor.html new file mode 100644 index 0000000000000000000000000000000000000000..dd50a725f415c9b673a13cd093bc7ee6663b9d4a --- /dev/null +++ b/reference/torch_tensor.html @@ -0,0 +1,233 @@ + + + + + + + + +Converts R objects to a torch tensor — torch_tensor • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Converts R objects to a torch tensor

    +
    + +
    torch_tensor(
    +  data,
    +  dtype = NULL,
    +  device = NULL,
    +  requires_grad = FALSE,
    +  pin_memory = FALSE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    data

    an R atomic vector, matrix or array

    dtype

    a torch_dtype instance

    device

    a device creted with torch_device()

    requires_grad

    if autograd should record operations on the returned tensor.

    pin_memory

    If set, returned tensor would be allocated in the pinned memory.

    + + +

    Examples

    +
    if (torch_is_installed()) { +torch_tensor(c(1,2,3,4)) +torch_tensor(c(1,2,3,4), dtype = torch_int()) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_tensordot.html b/reference/torch_tensordot.html new file mode 100644 index 0000000000000000000000000000000000000000..40fd6d99ce9116cd5090a551324537e5a8baee53 --- /dev/null +++ b/reference/torch_tensordot.html @@ -0,0 +1,232 @@ + + + + + + + + +Tensordot — torch_tensordot • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Tensordot

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    a

    (Tensor) Left tensor to contract

    b

    (Tensor) Right tensor to contract

    dims

    (int or tuple of two lists of integers) number of dimensions to contract or explicit lists of dimensions for a and b respectively

    + +

    TEST

    + + + + +

    Returns a contraction of a and b over multiple dimensions.

    `tensordot` implements a generalized matrix product.
    +
    + + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_arange(start = 0, end = 60.)$reshape(c(3, 4, 5)) +b = torch_arange(start = 0, end = 24.)$reshape(c(4, 3, 2)) +torch_tensordot(a, b, dims_self=c(2, 1), dims_other = c(1, 2)) +if (FALSE) { +a = torch_randn(3, 4, 5, device='cuda') +b = torch_randn(4, 5, 6, device='cuda') +c = torch_tensordot(a, b, dims=2)$cpu() +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_threshold_.html b/reference/torch_threshold_.html new file mode 100644 index 0000000000000000000000000000000000000000..bb17693d0910e1defaf0002795ca41a7a16564fa --- /dev/null +++ b/reference/torch_threshold_.html @@ -0,0 +1,202 @@ + + + + + + + + +Threshold_ — torch_threshold_ • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Threshold_

    +
    + + + +

    threshold_(input, threshold, value) -> Tensor

    + + + + +

    In-place version of torch_threshold.

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_topk.html b/reference/torch_topk.html new file mode 100644 index 0000000000000000000000000000000000000000..9f9ba22100fd435cec584901101c0abfed86cedf --- /dev/null +++ b/reference/torch_topk.html @@ -0,0 +1,244 @@ + + + + + + + + +Topk — torch_topk • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Topk

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    k

    (int) the k in "top-k"

    dim

    (int, optional) the dimension to sort along

    largest

    (bool, optional) controls whether to return largest or smallest elements

    sorted

    (bool, optional) controls whether to return the elements in sorted order

    out

    (tuple, optional) the output tuple of (Tensor, LongTensor) that can be optionally given to be used as output buffers

    + +

    topk(input, k, dim=None, largest=True, sorted=True, out=None) -> (Tensor, LongTensor)

    + + + + +

    Returns the k largest elements of the given input tensor along +a given dimension.

    +

    If dim is not given, the last dimension of the input is chosen.

    +

    If largest is False then the k smallest elements are returned.

    +

    A namedtuple of (values, indices) is returned, where the indices are the indices +of the elements in the original input tensor.

    +

    The boolean option sorted if True, will make sure that the returned +k elements are themselves sorted

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_arange(1., 6.) +x +torch_topk(x, 3) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_trace.html b/reference/torch_trace.html new file mode 100644 index 0000000000000000000000000000000000000000..601c5119a3d03dba97e4dcd51306a1e28a2d1743 --- /dev/null +++ b/reference/torch_trace.html @@ -0,0 +1,209 @@ + + + + + + + + +Trace — torch_trace • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Trace

    +
    + + + +

    trace(input) -> Tensor

    + + + + +

    Returns the sum of the elements of the diagonal of the input 2-D matrix.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_arange(1., 10.)$view(c(3, 3)) +x +torch_trace(x) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_transpose.html b/reference/torch_transpose.html new file mode 100644 index 0000000000000000000000000000000000000000..a91a4e02f415b84f7c1d9cbc9d5ab924faeede70 --- /dev/null +++ b/reference/torch_transpose.html @@ -0,0 +1,229 @@ + + + + + + + + +Transpose — torch_transpose • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Transpose

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim0

    (int) the first dimension to be transposed

    dim1

    (int) the second dimension to be transposed

    + +

    transpose(input, dim0, dim1) -> Tensor

    + + + + +

    Returns a tensor that is a transposed version of input. +The given dimensions dim0 and dim1 are swapped.

    +

    The resulting out tensor shares it's underlying storage with the +input tensor, so changing the content of one would change the content +of the other.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_randn(c(2, 3)) +x +torch_transpose(x, 1, 2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_trapz.html b/reference/torch_trapz.html new file mode 100644 index 0000000000000000000000000000000000000000..0cea8e36d311821ab7e98a830a4f5b344c89a2b6 --- /dev/null +++ b/reference/torch_trapz.html @@ -0,0 +1,237 @@ + + + + + + + + +Trapz — torch_trapz • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Trapz

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    y

    (Tensor) The values of the function to integrate

    x

    (Tensor) The points at which the function y is sampled. If x is not in ascending order, intervals on which it is decreasing contribute negatively to the estimated integral (i.e., the convention \(\int_a^b f = -\int_b^a f\) is followed).

    dim

    (int) The dimension along which to integrate. By default, use the last dimension.

    dx

    (float) The distance between points at which y is sampled.

    + +

    trapz(y, x, *, dim=-1) -> Tensor

    + + + + +

    Estimate \(\int y\,dx\) along dim, using the trapezoid rule.

    +

    trapz(y, *, dx=1, dim=-1) -> Tensor

    + + + + +

    As above, but the sample points are spaced uniformly at a distance of dx.

    + +

    Examples

    +
    if (torch_is_installed()) { + +y = torch_randn(list(2, 3)) +y +x = torch_tensor(matrix(c(1, 3, 4, 1, 2, 3), ncol = 3, byrow=TRUE)) +torch_trapz(y, x = x) + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_triangular_solve.html b/reference/torch_triangular_solve.html new file mode 100644 index 0000000000000000000000000000000000000000..f20f3e4b0f65a0c91aec489af29dcc939b127067 --- /dev/null +++ b/reference/torch_triangular_solve.html @@ -0,0 +1,241 @@ + + + + + + + + +Triangular_solve — torch_triangular_solve • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Triangular_solve

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) multiple right-hand sides of size \((*, m, k)\) where \(*\) is zero of more batch dimensions (\(b\))

    A

    (Tensor) the input triangular coefficient matrix of size \((*, m, m)\) where \(*\) is zero or more batch dimensions

    upper

    (bool, optional) whether to solve the upper-triangular system of equations (default) or the lower-triangular system of equations. Default: True.

    transpose

    (bool, optional) whether \(A\) should be transposed before being sent into the solver. Default: False.

    unitriangular

    (bool, optional) whether \(A\) is unit triangular. If True, the diagonal elements of \(A\) are assumed to be 1 and not referenced from \(A\). Default: False.

    + +

    triangular_solve(input, A, upper=True, transpose=False, unitriangular=False) -> (Tensor, Tensor)

    + + + + +

    Solves a system of equations with a triangular coefficient matrix \(A\) +and multiple right-hand sides \(b\).

    +

    In particular, solves \(AX = b\) and assumes \(A\) is upper-triangular +with the default keyword arguments.

    +

    torch_triangular_solve(b, A) can take in 2D inputs b, A or inputs that are +batches of 2D matrices. If the inputs are batches, then returns +batched outputs X

    + +

    Examples

    +
    if (torch_is_installed()) { + +A = torch_randn(c(2, 2))$triu() +A +b = torch_randn(c(2, 3)) +b +torch_triangular_solve(b, A) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_tril.html b/reference/torch_tril.html new file mode 100644 index 0000000000000000000000000000000000000000..3308fb068bb6868d133e02ac18aaae3725402757 --- /dev/null +++ b/reference/torch_tril.html @@ -0,0 +1,239 @@ + + + + + + + + +Tril — torch_tril • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Tril

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    diagonal

    (int, optional) the diagonal to consider

    out

    (Tensor, optional) the output tensor.

    + +

    tril(input, diagonal=0, out=None) -> Tensor

    + + + + +

    Returns the lower triangular part of the matrix (2-D tensor) or batch of matrices +input, the other elements of the result tensor out are set to 0.

    +

    The lower triangular part of the matrix is defined as the elements on and +below the diagonal.

    +

    The argument diagonal controls which diagonal to consider. If +diagonal = 0, all elements on and below the main diagonal are +retained. A positive value includes just as many diagonals above the main +diagonal, and similarly a negative value excludes just as many diagonals below +the main diagonal. The main diagonal are the set of indices +\(\lbrace (i, i) \rbrace\) for \(i \in [0, \min\{d_{1}, d_{2}\} - 1]\) where +\(d_{1}, d_{2}\) are the dimensions of the matrix.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3, 3)) +a +torch_tril(a) +b = torch_randn(c(4, 6)) +b +torch_tril(b, diagonal=1) +torch_tril(b, diagonal=-1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_tril_indices.html b/reference/torch_tril_indices.html new file mode 100644 index 0000000000000000000000000000000000000000..d05fc7ffc2124bd241cb6c522508deed2c71670b --- /dev/null +++ b/reference/torch_tril_indices.html @@ -0,0 +1,260 @@ + + + + + + + + +Tril_indices — torch_tril_indices • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Tril_indices

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    row

    (int) number of rows in the 2-D matrix.

    col

    (int) number of columns in the 2-D matrix.

    offset

    (int) diagonal offset from the main diagonal. Default: if not provided, 0.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, torch_long.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    layout

    (torch.layout, optional) currently only support torch_strided.

    + +

    Note

    + + +
    When running on CUDA, ``row * col`` must be less than \eqn{2^{59}} to
    +prevent overflow during calculation.
    +
    + +

    tril_indices(row, col, offset=0, dtype=torch.long, device='cpu', layout=torch.strided) -> Tensor

    + + + + +

    Returns the indices of the lower triangular part of a row-by- +col matrix in a 2-by-N Tensor, where the first row contains row +coordinates of all indices and the second row contains column coordinates. +Indices are ordered based on rows and then columns.

    +

    The lower triangular part of the matrix is defined as the elements on and +below the diagonal.

    +

    The argument offset controls which diagonal to consider. If +offset = 0, all elements on and below the main diagonal are +retained. A positive value includes just as many diagonals above the main +diagonal, and similarly a negative value excludes just as many diagonals below +the main diagonal. The main diagonal are the set of indices +\(\lbrace (i, i) \rbrace\) for \(i \in [0, \min\{d_{1}, d_{2}\} - 1]\) +where \(d_{1}, d_{2}\) are the dimensions of the matrix.

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +a = torch_tril_indices(3, 3) +a +a = torch_tril_indices(4, 3, -1) +a +a = torch_tril_indices(4, 3, 1) +a +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_triu.html b/reference/torch_triu.html new file mode 100644 index 0000000000000000000000000000000000000000..c24e1c4c06668f4ff52e924cd5f7f64d850b6923 --- /dev/null +++ b/reference/torch_triu.html @@ -0,0 +1,241 @@ + + + + + + + + +Triu — torch_triu • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Triu

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    diagonal

    (int, optional) the diagonal to consider

    out

    (Tensor, optional) the output tensor.

    + +

    triu(input, diagonal=0, out=None) -> Tensor

    + + + + +

    Returns the upper triangular part of a matrix (2-D tensor) or batch of matrices +input, the other elements of the result tensor out are set to 0.

    +

    The upper triangular part of the matrix is defined as the elements on and +above the diagonal.

    +

    The argument diagonal controls which diagonal to consider. If +diagonal = 0, all elements on and above the main diagonal are +retained. A positive value excludes just as many diagonals above the main +diagonal, and similarly a negative value includes just as many diagonals below +the main diagonal. The main diagonal are the set of indices +\(\lbrace (i, i) \rbrace\) for \(i \in [0, \min\{d_{1}, d_{2}\} - 1]\) where +\(d_{1}, d_{2}\) are the dimensions of the matrix.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(3, 3)) +a +torch_triu(a) +torch_triu(a, diagonal=1) +torch_triu(a, diagonal=-1) +b = torch_randn(c(4, 6)) +b +torch_triu(b, diagonal=1) +torch_triu(b, diagonal=-1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_triu_indices.html b/reference/torch_triu_indices.html new file mode 100644 index 0000000000000000000000000000000000000000..80eee66354434570c73f59b42c271d72427c6cd3 --- /dev/null +++ b/reference/torch_triu_indices.html @@ -0,0 +1,260 @@ + + + + + + + + +Triu_indices — torch_triu_indices • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Triu_indices

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    row

    (int) number of rows in the 2-D matrix.

    col

    (int) number of columns in the 2-D matrix.

    offset

    (int) diagonal offset from the main diagonal. Default: if not provided, 0.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, torch_long.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    layout

    (torch.layout, optional) currently only support torch_strided.

    + +

    Note

    + + +
    When running on CUDA, ``row * col`` must be less than \eqn{2^{59}} to
    +prevent overflow during calculation.
    +
    + +

    triu_indices(row, col, offset=0, dtype=torch.long, device='cpu', layout=torch.strided) -> Tensor

    + + + + +

    Returns the indices of the upper triangular part of a row by +col matrix in a 2-by-N Tensor, where the first row contains row +coordinates of all indices and the second row contains column coordinates. +Indices are ordered based on rows and then columns.

    +

    The upper triangular part of the matrix is defined as the elements on and +above the diagonal.

    +

    The argument offset controls which diagonal to consider. If +offset = 0, all elements on and above the main diagonal are +retained. A positive value excludes just as many diagonals above the main +diagonal, and similarly a negative value includes just as many diagonals below +the main diagonal. The main diagonal are the set of indices +\(\lbrace (i, i) \rbrace\) for \(i \in [0, \min\{d_{1}, d_{2}\} - 1]\) +where \(d_{1}, d_{2}\) are the dimensions of the matrix.

    + +

    Examples

    +
    if (torch_is_installed()) { +if (FALSE) { +a = torch_triu_indices(3, 3) +a +a = torch_triu_indices(4, 3, -1) +a +a = torch_triu_indices(4, 3, 1) +a +} +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_true_divide.html b/reference/torch_true_divide.html new file mode 100644 index 0000000000000000000000000000000000000000..ab7741573375ad69939dc85c7af7d91cec06560b --- /dev/null +++ b/reference/torch_true_divide.html @@ -0,0 +1,228 @@ + + + + + + + + +True_divide — torch_true_divide • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    True_divide

    +
    + + +

    Arguments

    + + + + + + + + + + +
    dividend

    (Tensor) the dividend

    divisor

    (Tensor or Scalar) the divisor

    + +

    true_divide(dividend, divisor) -> Tensor

    + + + + +

    Performs "true division" that always computes the division +in floating point. Analogous to division in Python 3 and equivalent to +torch_div except when both inputs have bool or integer scalar types, +in which case they are cast to the default (floating) scalar type before the division.

    +

    $$ + \mbox{out}_i = \frac{\mbox{dividend}_i}{\mbox{divisor}} +$$

    + +

    Examples

    +
    if (torch_is_installed()) { + +dividend = torch_tensor(c(5, 3), dtype=torch_int()) +divisor = torch_tensor(c(3, 2), dtype=torch_int()) +torch_true_divide(dividend, divisor) +torch_true_divide(dividend, 2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_trunc.html b/reference/torch_trunc.html new file mode 100644 index 0000000000000000000000000000000000000000..749ae67e8bc81a82164386dfe7b2abb1fe61bfc9 --- /dev/null +++ b/reference/torch_trunc.html @@ -0,0 +1,222 @@ + + + + + + + + +Trunc — torch_trunc • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Trunc

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    out

    (Tensor, optional) the output tensor.

    + +

    trunc(input, out=None) -> Tensor

    + + + + +

    Returns a new tensor with the truncated integer values of +the elements of input.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(4)) +a +torch_trunc(a) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_unbind.html b/reference/torch_unbind.html new file mode 100644 index 0000000000000000000000000000000000000000..c0895ae2bc1a602176363a8be3e1067fd21fa21d --- /dev/null +++ b/reference/torch_unbind.html @@ -0,0 +1,220 @@ + + + + + + + + +Unbind — torch_unbind • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Unbind

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the tensor to unbind

    dim

    (int) dimension to remove

    + +

    unbind(input, dim=0) -> seq

    + + + + +

    Removes a tensor dimension.

    +

    Returns a tuple of all slices along a given dimension, already without it.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_unbind(torch_tensor(matrix(1:9, ncol = 3, byrow=TRUE))) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_unique_consecutive.html b/reference/torch_unique_consecutive.html new file mode 100644 index 0000000000000000000000000000000000000000..d446706bde67181a6c331f25ac2a77a2c8f7947c --- /dev/null +++ b/reference/torch_unique_consecutive.html @@ -0,0 +1,234 @@ + + + + + + + + +Unique_consecutive — torch_unique_consecutive • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Unique_consecutive

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor

    return_inverse

    (bool) Whether to also return the indices for where elements in the original input ended up in the returned unique list.

    return_counts

    (bool) Whether to also return the counts for each unique element.

    dim

    (int) the dimension to apply unique. If None, the unique of the flattened input is returned. default: None

    + +

    TEST

    + + + + +

    Eliminates all but the first element from every consecutive group of equivalent elements.

    .. note:: This function is different from [`torch_unique`] in the sense that this function
    +    only eliminates consecutive duplicate values. This semantics is similar to `std::unique`
    +    in C++.
    +
    + + +

    Examples

    +
    if (torch_is_installed()) { +x = torch_tensor(c(1, 1, 2, 2, 3, 1, 1, 2)) +output = torch_unique_consecutive(x) +output +torch_unique_consecutive(x, return_inverse=TRUE) +torch_unique_consecutive(x, return_counts=TRUE) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_unsqueeze.html b/reference/torch_unsqueeze.html new file mode 100644 index 0000000000000000000000000000000000000000..1d210c698bb413ef82638fd760749ead33063dd1 --- /dev/null +++ b/reference/torch_unsqueeze.html @@ -0,0 +1,226 @@ + + + + + + + + +Unsqueeze — torch_unsqueeze • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Unsqueeze

    +
    + + +

    Arguments

    + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    dim

    (int) the index at which to insert the singleton dimension

    + +

    unsqueeze(input, dim) -> Tensor

    + + + + +

    Returns a new tensor with a dimension of size one inserted at the +specified position.

    +

    The returned tensor shares the same underlying data with this tensor.

    +

    A dim value within the range [-input.dim() - 1, input.dim() + 1) +can be used. Negative dim will correspond to unsqueeze +applied at dim = dim + input.dim() + 1.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x = torch_tensor(c(1, 2, 3, 4)) +torch_unsqueeze(x, 1) +torch_unsqueeze(x, 2) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_var.html b/reference/torch_var.html new file mode 100644 index 0000000000000000000000000000000000000000..90806c841117cbecca7b0b1eed1f12c38563861d --- /dev/null +++ b/reference/torch_var.html @@ -0,0 +1,253 @@ + + + + + + + + +Var — torch_var • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Var

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    unbiased

    (bool) whether to use the unbiased estimation or not

    dim

    (int or tuple of ints) the dimension or dimensions to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    out

    (Tensor, optional) the output tensor.

    + +

    var(input, unbiased=True) -> Tensor

    + + + + +

    Returns the variance of all elements in the input tensor.

    +

    If unbiased is False, then the variance will be calculated via the +biased estimator. Otherwise, Bessel's correction will be used.

    +

    var(input, dim, keepdim=False, unbiased=True, out=None) -> Tensor

    + + + + +

    Returns the variance of each row of the input tensor in the given +dimension dim.

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension(s) dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in the +output tensor having 1 (or len(dim)) fewer dimension(s).

    +

    If unbiased is False, then the variance will be calculated via the +biased estimator. Otherwise, Bessel's correction will be used.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_var(a) + + +a = torch_randn(c(4, 4)) +a +torch_var(a, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_var_mean.html b/reference/torch_var_mean.html new file mode 100644 index 0000000000000000000000000000000000000000..76ba2de27633ba76ccaadaa6f6c462c807567f94 --- /dev/null +++ b/reference/torch_var_mean.html @@ -0,0 +1,249 @@ + + + + + + + + +Var_mean — torch_var_mean • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Var_mean

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the input tensor.

    unbiased

    (bool) whether to use the unbiased estimation or not

    dim

    (int or tuple of ints) the dimension or dimensions to reduce.

    keepdim

    (bool) whether the output tensor has dim retained or not.

    + +

    var_mean(input, unbiased=True) -> (Tensor, Tensor)

    + + + + +

    Returns the variance and mean of all elements in the input tensor.

    +

    If unbiased is False, then the variance will be calculated via the +biased estimator. Otherwise, Bessel's correction will be used.

    +

    var_mean(input, dim, keepdim=False, unbiased=True) -> (Tensor, Tensor)

    + + + + +

    Returns the variance and mean of each row of the input tensor in the given +dimension dim.

    +

    If keepdim is True, the output tensor is of the same size +as input except in the dimension(s) dim where it is of size 1. +Otherwise, dim is squeezed (see torch_squeeze), resulting in the +output tensor having 1 (or len(dim)) fewer dimension(s).

    +

    If unbiased is False, then the variance will be calculated via the +biased estimator. Otherwise, Bessel's correction will be used.

    + +

    Examples

    +
    if (torch_is_installed()) { + +a = torch_randn(c(1, 3)) +a +torch_var_mean(a) + + +a = torch_randn(c(4, 4)) +a +torch_var_mean(a, 1) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_where.html b/reference/torch_where.html new file mode 100644 index 0000000000000000000000000000000000000000..36f28d634644d8cc19b4d2f85b52c628ea6f4d66 --- /dev/null +++ b/reference/torch_where.html @@ -0,0 +1,255 @@ + + + + + + + + +Where — torch_where • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Where

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + +
    condition

    (BoolTensor) When True (nonzero), yield x, otherwise yield y

    x

    (Tensor) values selected at indices where condition is True

    y

    (Tensor) values selected at indices where condition is False

    + +

    Note

    + + +
    The tensors `condition`, `x`, `y` must be broadcastable .
    +
    + +
    See also [`torch_nonzero`].
    +
    + +

    where(condition, x, y) -> Tensor

    + + + + +

    Return a tensor of elements selected from either x or y, depending on condition.

    +

    The operation is defined as:

    +

    $$ + \mbox{out}_i = \left\{ \begin{array}{ll} + \mbox{x}_i & \mbox{if } \mbox{condition}_i \\ + \mbox{y}_i & \mbox{otherwise} \\ + \end{array} + \right. +$$

    +

    where(condition) -> tuple of LongTensor

    + + + + +

    torch_where(condition) is identical to +torch_nonzero(condition, as_tuple=True).

    + +

    Examples

    +
    if (torch_is_installed()) { + +if (FALSE) { +x = torch_randn(c(3, 2)) +y = torch_ones(c(3, 2)) +x +torch_where(x > 0, x, y) +} + + + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_zeros.html b/reference/torch_zeros.html new file mode 100644 index 0000000000000000000000000000000000000000..f5f6d910bb36e28945ab6ee2ceb75edc9ac0b102 --- /dev/null +++ b/reference/torch_zeros.html @@ -0,0 +1,237 @@ + + + + + + + + +Zeros — torch_zeros • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Zeros

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    size

    (int...) a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.

    out

    (Tensor, optional) the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned tensor. Default: if None, uses a global default (see torch_set_default_tensor_type).

    layout

    (torch.layout, optional) the desired layout of returned Tensor. Default: torch_strided.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch_set_default_tensor_type). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    + +

    zeros(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor

    + + + + +

    Returns a tensor filled with the scalar value 0, with the shape defined +by the variable argument size.

    + +

    Examples

    +
    if (torch_is_installed()) { + +torch_zeros(c(2, 3)) +torch_zeros(c(5)) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/torch_zeros_like.html b/reference/torch_zeros_like.html new file mode 100644 index 0000000000000000000000000000000000000000..31b980bd5b91a5ddec0028bf4d1cea09122e84cf --- /dev/null +++ b/reference/torch_zeros_like.html @@ -0,0 +1,245 @@ + + + + + + + + +Zeros_like — torch_zeros_like • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Zeros_like

    +
    + + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    input

    (Tensor) the size of input will determine size of the output tensor.

    dtype

    (torch.dtype, optional) the desired data type of returned Tensor. Default: if None, defaults to the dtype of input.

    layout

    (torch.layout, optional) the desired layout of returned tensor. Default: if None, defaults to the layout of input.

    device

    (torch.device, optional) the desired device of returned tensor. Default: if None, defaults to the device of input.

    requires_grad

    (bool, optional) If autograd should record operations on the returned tensor. Default: False.

    memory_format

    (torch.memory_format, optional) the desired memory format of returned Tensor. Default: torch_preserve_format.

    + +

    zeros_like(input, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor

    + + + + +

    Returns a tensor filled with the scalar value 0, with the same size as +input. torch_zeros_like(input) is equivalent to +torch_zeros(input.size(), dtype=input.dtype, layout=input.layout, device=input.device).

    +

    Warning

    + + + +

    As of 0.4, this function does not support an out keyword. As an alternative, +the old torch_zeros_like(input, out=output) is equivalent to +torch_zeros(input.size(), out=output).

    + +

    Examples

    +
    if (torch_is_installed()) { + +input = torch_empty(c(2, 3)) +torch_zeros_like(input) +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/with_enable_grad.html b/reference/with_enable_grad.html new file mode 100644 index 0000000000000000000000000000000000000000..76fcaf7f4dd08706250933b05b2da480e28a6547 --- /dev/null +++ b/reference/with_enable_grad.html @@ -0,0 +1,224 @@ + + + + + + + + +Enable grad — with_enable_grad • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Context-manager that enables gradient calculation. +Enables gradient calculation, if it has been disabled via with_no_grad.

    +
    + +
    with_enable_grad(code)
    + +

    Arguments

    + + + + + + +
    code

    code to be executed with gradient recording.

    + +

    Details

    + +

    This context manager is thread local; it will not affect computation in +other threads.

    + +

    Examples

    +
    if (torch_is_installed()) { + +x <- torch_tensor(1, requires_grad=TRUE) +with_no_grad({ + with_enable_grad({ + y = x * 2 + }) +}) +y$backward() +x$grad + +}
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.5.1.

    +
    + +
    +
    + + + + + + + + diff --git a/reference/with_no_grad.html b/reference/with_no_grad.html new file mode 100644 index 0000000000000000000000000000000000000000..13a0b5ca9e519bfcb8eb9e6c76558800ff420c1d --- /dev/null +++ b/reference/with_no_grad.html @@ -0,0 +1,215 @@ + + + + + + + + +Temporarily modify gradient recording. — with_no_grad • torch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Temporarily modify gradient recording.

    +
    + +
    with_no_grad(code)
    + +

    Arguments

    + + + + + + +
    code

    code to be executed with no gradient recording.

    + + +

    Examples

    +
    if (torch_is_installed()) { +x <- torch_tensor(runif(5), requires_grad = TRUE) +with_no_grad({ + x$sub_(torch_tensor(as.numeric(1:5))) +}) +x +x$grad + +}
    +
    + +
    + + + +
    + + + + + + + +