用来对张量里的值进行限定

import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

a=tf.range(10)

print(tf.maximum(a,4))
# tf.Tensor([4 4 4 4 4 5 6 7 8 9], shape=(10,), dtype=int32)
print(tf.minimum(a,4))
# tf.Tensor([0 1 2 3 4 4 4 4 4 4], shape=(10,), dtype=int32)
print(tf.clip_by_value(a,4,6))
# tf.Tensor([4 4 4 4 4 5 6 6 6 6], shape=(10,), dtype=int32)