mlr3torch icon indicating copy to clipboard operation
mlr3torch copied to clipboard

deep clone for PipeOpModule

Open sebffischer opened this issue 2 years ago • 1 comments

sebffischer avatar Oct 13 '23 14:10 sebffischer

test code:

test_that("cloning works", { p1 = po("module", nn_linear(1, 1), id = "test1") unlockBinding(".additional_phash_input", get_private(p1)) get_private(p1, ".additional_phash_input") = function(...) NULL p1deep = p1$clone(deep = TRUE) unlockBinding(".additional_phash_input", get_private(p1)) get_private(p1deep, ".additional_phash_input") = function(...) NULL expect_deep_clone(p1, p1deep)

p1shallow = p1$clone(deep = FALSE) expect_false(identical(p1$module$parameters$weight, p1deep$module$parameters$weight)) expect_true(identical(p1$module$parameters$weight, p1shallow$module$parameters$weight))

})

sebffischer avatar Jan 25 '24 14:01 sebffischer