Using Tensorflow Layers in Keras

孤街浪徒 提交于 2019-11-28 08:36:50
Bart C

Got it to work. For future reference, this is how you would need to implement it. Since tf.nn.fractional_max_pool returns 3 tensors, you need to get the first one only:

model.add(InputLayer(input_tensor=tf.nn.fractional_max_pool(model.layers[3].output, p_ratio)[0]))

Or using Lambda layer:

def frac_max_pool(x):
    return tf.nn.fractional_max_pool(x,p_ratio)[0]

With the model implementation being:

model.add(Lambda(frac_max_pool))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!