Using Tensorflow Layers in Keras

前端 未结 1 464
我寻月下人不归
我寻月下人不归 2020-12-09 05:15

I\'ve been trying to build a sequential model in Keras using the pooling layer tf.nn.fractional_max_pool. I know I could try making my own custom layer in Keras

相关标签:
1条回答
  • 2020-12-09 05:53

    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))
    
    0 讨论(0)
提交回复
热议问题