Python TensorFlow:``tensorflow.math.ndtri()`` 函数与使用示例


发布日期 : 2024-11-07 18:16:48 UTC

访问量: 10 次浏览

Python – tensorflow.math.ndtri()

TensorFlow是谷歌设计的开源python库,用于开发机器学习模型和深度学习神经网络。 ndtri() 用于寻找标准正态的量化。

语法:
tf.math.ndtri(x, name)

参数 :

  • x:它是输入的张量。这个张量允许的 dtypefloatdouble
  • name(可选):它定义了操作的名称。

返回值:它返回x的逆向误差函数。

示例 1:

# Importing the library
import tensorflow as tf

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

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

# Calculating result
res = tf.math.ndtri(x = a)

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

输出:

Input: tf.Tensor([0.2 0.5 0.7 1. ], shape=(4, ), dtype=float64)
Result: tf.Tensor([-0.84162123 0. 0.52440051 inf], shape=(4, ), dtype=float64)

示例 2:

# importing the library
import tensorflow as tf

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

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

# Calculating result
res = tf.math.ndtri(x = a)

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

输出:

Input: tf.Tensor([-0.1 -0.2 -0.5 0.5 0.2 0.1], shape=(6, ), dtype=float64)
Result: tf.Tensor([ -inf -inf -inf 0. -0.84162123 -1.28155157], shape=(6, ), dtype=float64)