如何在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”
答案 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)