白云岛资源网 Design By www.pvray.com

不能再向以前一样使用

model.add(Merge([Model1,Model2]))

必须使用函数式

out = Concatenate()([model1.output, model2.output])

补充知识:keras 新版接口修改

1.

# b = MaxPooling2D((3, 3), strides=(1, 1), border_mode='valid', dim_ordering='tf')(x)

b = MaxPooling2D((3, 3), strides=(1, 1), padding='valid', data_format="channels_last")(x)

2.

from keras.layers.merge import concatenate
# x = merge([a, b], mode='concat', concat_axis=-1)
x = concatenate([a, b], axis=-1)

3.

from keras.engine import merge
m = merge([init, x], mode='sum')
Equivalent Keras 2.0.2 code:

from keras.layers import add
m = add([init, x])

4.

 # x = Convolution2D(32 // nb_filters_reduction_factor, 3, 3, subsample=(1, 1), activation='relu',
 #     init='he_normal', border_mode='valid', dim_ordering='tf')(x)
 x = Conv2D(32 // nb_filters_reduction_factor, (3, 3), activation="relu", strides=(1, 1), padding="valid",
    data_format="channels_last",
    kernel_initializer="he_normal")(x)

1.

# b = MaxPooling2D((3, 3), strides=(1, 1), border_mode='valid', dim_ordering='tf')(x)
b = MaxPooling2D((3, 3), strides=(1, 1), padding='valid', data_format="channels_last")(x)

2.

from keras.layers.merge import concatenate
# x = merge([a, b], mode='concat', concat_axis=-1)
x = concatenate([a, b], axis=-1)

3.

from keras.engine import merge
m = merge([init, x], mode='sum')
Equivalent Keras 2.0.2 code:

from keras.layers import add
m = add([init, x])

4.

 # x = Convolution2D(32 // nb_filters_reduction_factor, 3, 3, subsample=(1, 1), activation='relu',
 #     init='he_normal', border_mode='valid', dim_ordering='tf')(x)
 x = Conv2D(32 // nb_filters_reduction_factor, (3, 3), activation="relu", strides=(1, 1), padding="valid",
    data_format="channels_last",
    kernel_initializer="he_normal")(x)

以上这篇使用keras2.0 将Merge层改为函数式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

白云岛资源网 Design By www.pvray.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
白云岛资源网 Design By www.pvray.com