Tensorflow中random_channel_shift实现的问题

本文探讨了Tensorflow中random_channel_shift函数的实现,指出该函数可能存在的问题——使用同一个随机数对图像所有通道进行位移,而非为每个元素生成独立的随机数。通过对比网络上另一种实现方式,作者强调了Tensorflow当前实现可能缺乏真正的随机性。
摘要由CSDN通过智能技术生成

在Tensorflow中,有一个处理图像的函数random_channel_shift。其源代码如下:

def random_channel_shift(x, intensity_range, channel_axis=0):
    """Performs a random channel shift.
    # Arguments
        x: Input tensor. Must be 3D.
        intensity_range: Transformation intensity.
        channel_axis: Index of axis for channels in the input tensor.
    # Returns
        Numpy image tensor.
    """
    intensity = np.random.uniform(-intensity_range, intensity_range)
    return apply_channel_shift(x, intensity, channel_axis=channel_axis)

代码非常简单,就是生成以一个随机数(注意是一个随机数),然后调用apply_channel_shift。我的理解是应该针对图像的每一个对应元素生成一个随机数,而不是用一个相当于固定数的随机数去处理。在网络上有写好的random_channel_shift:

def random_channel_shift(x, intensity
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值