Python TensorFlow:``tensorflow.math.is_strictly_increasing()`` 使用详解


发布日期 : 2021-12-22 11:28:00 UTC

访问量: 10 次浏览

Python – tensorflow.math.is\_strictly\_increasing()

TensorFlow是谷歌设计的开源Python库,用于开发机器学习模型和深度学习神经网络。

is\_strictly\_increasing()如果x是严格递增的,则返回true。如果x的元素少于2个,它就是严格递增的。行大是用来比较元素的。

语法:
tensorflow.math.is_strictly_increasing( x, name)

参数:

  • x:它是一个数字张量。
  • name(可选):它定义了该操作的名称

返回:它返回一个dtype bool的张量。

示例 1:

# importing the library
import tensorflow as tf

# Initializing the input tensor
a = tf.constant([2, 3, 3, 5], dtype = tf.float64)

# Printing the input tensor
print('a: ', a)

# Calculating the result
res = tf.math.is_strictly_increasing(a)

# Printing the result
print('Result: ', res)

输出:

a: tf.Tensor([2. 3. 3. 5.], shape=(4, ), dtype=float64)
Result: tf.Tensor(False, shape=(), dtype=bool)

示例 2:

# Importing the library
import tensorflow as tf

# Initializing the input tensor
a = tf.constant([7, 8, 13, 17], dtype = tf.float64)

# Printing the input tensor
print('a: ', a)

# Calculating the result
res = tf.math.is_strictly_increasing(a)

# Printing the result
print('Result: ', res)

输出:

a: tf.Tensor([ 7. 8. 13. 17.], shape=(4, ), dtype=float64)
Result: tf.Tensor(True, shape=(), dtype=bool)