@@ -102,14 +102,19 @@ test_that("E2E: Customizing fit arguments works", {
102102 expect_lt(length(fit_obj $ fit $ history $ metrics $ loss ), 5 )
103103})
104104
105- test_that(" E2E: Setting num_blocks = 0 works" , {
105+ test_that(" E2E: Setting num_blocks = 0 works for sequential models " , {
106106 skip_if_no_keras()
107107
108108 input_block_zero <- function (model , input_shape ) {
109109 keras3 :: keras_model_sequential(input_shape = input_shape )
110110 }
111111 dense_block_zero <- function (model , units = 16 ) {
112- model | > keras3 :: layer_dense(units = units , activation = " relu" )
112+ model | >
113+ keras3 :: layer_dense(
114+ units = units ,
115+ activation = " relu" ,
116+ name = " i_should_not_exist"
117+ )
113118 }
114119 output_block_zero <- function (model ) {
115120 model | > keras3 :: layer_dense(units = 1 )
@@ -128,10 +133,18 @@ test_that("E2E: Setting num_blocks = 0 works", {
128133 mode = " regression"
129134 )
130135
131- spec <- e2e_mlp_zero(num_dense = 0 , fit_epochs = 2 ) | >
136+ spec <- e2e_mlp_zero(num_dense = 0 , fit_epochs = 1 ) | >
132137 parsnip :: set_engine(" keras" )
133- # This should fit a model with only an input and output layer
134- expect_no_error(parsnip :: fit(spec , mpg ~ . , data = mtcars ))
138+
139+ fit_obj <- parsnip :: fit(spec , mpg ~ . , data = mtcars )
140+
141+ # Check that the dense layer is NOT in the model
142+ keras_model <- fit_obj | > extract_keras_summary()
143+ expect_equal(length(keras_model $ layers ), 1 ) # Output layers only
144+
145+ # Check layer names explicitly
146+ layer_names <- sapply(keras_model $ layers , function (l ) l $ name )
147+ expect_false(" i_should_not_exist" %in% layer_names )
135148})
136149
137150test_that(" E2E: Error handling for reserved names works" , {
0 commit comments