如何使用合并层"连接"与Keras 2.0?

时间:2017-03-25 07:49:19

标签: concatenation keras

我目前正在尝试更新Keras 2.0的this densenet implementation。一切正常,除了

make

我把它改成了

from keras.layers import Input, merge
[...]
concat_axis = 1 if K.image_dim_ordering() == "th" else -1

feature_list = [x]

for i in range(nb_layers):
    x = conv_block(x, growth_rate, bottleneck, dropout_rate, weight_decay)
    feature_list.append(x)
    x = merge(feature_list, mode='concat', concat_axis=concat_axis)
    nb_filter += growth_rate

return x, nb_filter

但是这给了

from keras.layers import Input, concatenate
[...]
feature_list = [x]

for i in range(nb_layers):
    x = conv_block(x, growth_rate, bottleneck, dropout_rate, weight_decay)
    feature_list.append(x)
    x = concatenate(feature_list, axis=concat_axis)
    nb_filter += growth_rate

return x, nb_filter

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

这是通过https://github.com/fchollet/keras/commit/c2321e61e1732f7a27841eca36cdaf34ed5d26dd确定的。

在此期间,您可以使用

x = concatenate(feature_list[:], axis=concat_axis)