简体   繁体   中英

How to convert tensorflow tensor into keras tensor OR resize keras feature map?

How to resize the feature map in keras or convert tensorflow tensor into keras tensor?

I want to resize the out of keras layer, and I use K.resize_images , but I failed.

    block1_btchnorm2 = BatchNormalization(name ='b1_bn2')(block1_conv2)
    block1_conv3 = Conv2D(128, (3,3), activation='elu',name='b1_c3')(block1_btchnorm2)
    block1_btchnorm3 = BatchNormalization(name ='b1_bn3')(block1_conv3)
    block1_maxpooling =  MaxPooling2D(pool_size=(2,2),name ='b1_mp')(block1_btchnorm3)
    block1_out = K.resize_images(block1_maxpooling, height_factor =64/124 , width_factor = 64/124, data_format='channels_last')

AttributeError: 'Tensor' object has no attribute '_keras_history'

您必须使用Lambda图层将任何后端函数应用于keras张量:

block1_out = Lambda(lambda x: K.resize_images(x, height_factor =64/124 , width_factor = 64/124, data_format='channels_last'))(block1_maxpooling)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM