tf.clip_by_value——tf2.1 Document

参考自tf2.1官方文档:
https://www.tensorflow.org/api_docs/python/tf/clip_by_value


Clips tensor values to a specified min and max.
"裁剪"张量使得张量的每个元素在给定的最小值和最大值之间。

tf.clip_by_value(
    t, clip_value_min, clip_value_max, name=None
)

Given a tensor t, this operation returns a tensor of the same type and shape as t with its values clipped to clip_value_min andclip_value_max.
Any values less thanclip_value_min are set to clip_value_min.
Any values greater than clip_value_max are set to clip_value_max.

给定一个张量 t ,此函数将返回与t具有相同类型和形状的张量,但是返回张量的所有元素将被裁剪到clip_value_min和clip_value_max之间。
返回张量的元素若小于clip_value_min,则被赋值为clip_value_min。
返回张量的元素若大于clip_value_max,则被赋值为clip_value_max。




Args:

  • t: A Tensor or IndexedSlices.

  • t : 一个张量或者索引切片

  • clip_value_min: A 0-D (scalar) Tensor, or a Tensor with the same shape as t. The minimum value to clip by.

  • 一个数字张量(可以看做一个数字),或者与张量t同形的张量。小于此值将被裁剪为此值。

  • clip_value_max: A 0-D (scalar) Tensor, or a Tensor with the same shape as t. The maximum value to clip by.

  • 一个数字张量(可以看做一个数字),或者与张量t同形的张量。大于此值将被裁剪为此值。

  • name: A name for the operation (optional).

  • (可选)该操作的名字




Returns:

  • A clipped Tensor or IndexedSlices.
  • 被裁剪过的张量或者索引切片。




Raises:

  • ValueError: If the clip tensors would trigger array broadcasting that would make the returned tensor larger than the input. (注:笔者没想明白这个输出比输入大是个什么意思,是形状大?维度大?还是什么别的意思)

  • ValueError:例如: 裁剪张量触发率数组广播机制,则输出张量将比输入张量大,则会raise ValueError

  • TypeError: If dtype of the input is int32 and dtype of the clip_value_min or clip_value_max is float32

  • TypeError: 例如: 输入的类型的是int32,而clip_value_min 或
    clip_value_max 是 float32,则会raise TypeError

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值