我正在学习keras Functional API,并试图描述“一种”残留神经网络。 这是我建立模型的方式:
当移动到#5时,它给出错误消息,如下所示:
Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: Graph disconnected: cannot obtain value for tensor Tensor("input_2:0", shape=(?, 28, 28, 1), dtype=float32) at layer "input_2". The following previous layers were accessed without issue: []
这是什么意思? 我试图通过在CV1上应用一维转换来将CV1和CV2的形状调整为c(14、14、16),但是它不起作用。 感谢您的建议。
K_input <- layer_input(c(28, 28,1), name = "INPUT")
CV1 <-
K_input %>%
layer_conv_2d(filters = 4, c(5,5), activation = "relu", padding = "same", name = "CV1_CV1") %>%
layer_max_pooling_2d(pool_size = c(2,2), name = "CV1_MX1")
summary(CV1)
#Tensor("CV1_MX1_1/MaxPool:0", shape=(?, 14, 14, 4), dtype=float32)
CV2 <-
K_input %>%
layer_conv_2d(filters = 4, c(3,3), activation = "relu", padding = "same", name = "CV2_CV1") %>%
layer_conv_2d(filters = 8, c(3,3), activation = "relu", padding = "same", name = "CV2_CV2") %>%
layer_conv_2d(filters = 16, c(3,3), activation = "relu", padding = "same", name = "CV2_CV3") %>%
layer_max_pooling_2d(c(2,2), name = "CV2_MX1")
summary(CV2)
#Tensor("CV2_MX1_1/MaxPool:0", shape=(?, 14, 14, 16), dtype=float32)
K _output <-
layer_concatenate(c(CV1, CV2) , name = "OUT_C") %>%
layer_flatten(name = "OUT_FLAT") %>%
layer_dense(units = 32, activation = "relu", name = "OUT_D1") %>%
layer_dense(units = 10, activation = "softmax", name = "OUT_D2")
summary(K_output)
model_API2 <- keras_model(inputs = K_input, outputs = K_output)
# When error msg comes
# Error in py_call_impl(callable, dots$args, dots$keywords) :
# ValueError: Graph disconnected: cannot obtain value for
# tensor Tensor("input_2:0", shape=(?, 28, 28, 1), dtype=float32) at layer "input_2".
# The following previous layers were accessed without issue: []