tests/testthat/test-regularizers.R

context("regularizers")



test_regularizer <- function(name) {
  regularizer_fn <- eval(parse(text = name))
  test_call_succeeds(name, {
    keras_model_sequential() %>%
      layer_dense(32, input_shape = c(784),
                  kernel_regularizer = regularizer_fn(),
                  activity_regularizer = regularizer_fn())
  })
}

test_regularizer("regularizer_l1")
test_regularizer("regularizer_l1_l2")
test_regularizer("regularizer_l2")

Try the keras package in your browser

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

keras documentation built on Aug. 21, 2021, 9:07 a.m.