当我想连接当前层和模型中指定的前一层时,我无法使keras::layer_concatenate
工作。例如:
model = keras::keras_model_sequential(input_shape = inputShape,
batch_size = batchSize)
keras::layer_conv_2d(model, filters = 32, kernel_size = list(3L, 3L),
padding = "same", activation = "relu", name = "conv1")
keras::layer_max_pooling_2d(model, pool_size = c(2L, 2L), name = "pool1")
up1 = keras::layer_upsampling_2d(model, size = c(2L, 2L), name = "tmpUp1")
# Now I want to concatenate tmpUp1 and conv1:
keras::layer_concatenate(list(model$get_layer("conv1"),
model$get_layer("tmpUp1")))
# Error in py_call_impl(callable, dots$args, dots$keywords) :
# TypeError: object of type 'NoneType' has no len()
这怎么解决呢?
谢谢你!
1条答案
按热度按时间dm7nw8vv1#
layer_concatenate()
采用Tensor,而不是层。您可以使用layer$output
访问层的输出Tensor。