如何将tensorflow张量转换为keras张量或调整keras特征图的大小?

时间:2019-05-21 13:00:48

标签: python tensorflow keras

如何在keras中调整特征图的大小或如何将tensorflow张量转换为keras张量?

我想调整keras层的大小,并使用K.resize_images,但是失败了。

    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:“张量”对象没有属性“ _keras_history”

1 个答案:

答案 0 :(得分:0)

您必须使用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)