tests/testthat/test-nn-init.R

context("nn-init")

test_that("nn_init_eye", {
  w <- torch_empty(5, 5, requires_grad = TRUE)
  nn_init_eye_(w)

  expect_true(w$requires_grad)
  expect_equal_to_r(w, diag(nrow = 5, ncol = 5))
})

Try the torch package in your browser

Any scripts or data that you put into this service are public.

torch documentation built on June 7, 2023, 6:19 p.m.