gpt4 book ai didi

tensorflow - tensorflow 中的自定义中值池

转载 作者:行者123 更新时间:2023-12-01 09:17:00 31 4
gpt4 key购买 nike

我正在尝试在 tensorflow 中实现一个中值池化层。

但是,既没有 tf.nn.median_pool 也没有 tf.reduce_median

有没有办法用 python api 实现这样的池化层?

最佳答案

你可以使用类似的东西:

patches = tf.extract_image_patches(tensor, [1, k, k, 1], ...)
m_idx = int(k*k/2+1)
top = tf.top_k(patches, m_idx, sorted=True)
median = tf.slice(top, [0, 0, 0, m_idx-1], [-1, -1, -1, 1])

为了适应均匀大小的中值内核和多个 channel ,您需要扩展它,但这应该可以帮助您获得大部分 yield 。

关于tensorflow - tensorflow 中的自定义中值池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41522517/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com