TensorFlow是Google設計的開源Python庫,用於開發機器學習模型和深度學習神經網絡。
zeta() 用於計算 Hurwitz zeta 函數。它被定義為:
用法:tensorflow.math.zeta( x, q, name)
參數:
- x:這是一個張量。允許的數據類型是 float32 和 float64。
- q:它是一個與 x dtype 相同的張量。
- name(optional):它定義了操作的名稱。
返回值:
它返回與x相同dtype的張量。
範例1:
Python3
# importing the library
import tensorflow as tf
# Initializing the input tensor
a = tf.constant([ -5, -7, 2, 0, 7], dtype = tf.float64)
b = tf.constant([ 1, 3, 9, 4, 7], dtype = tf.float64)
# Printing the input tensor
print('a:', a)
print('b:', b)
# Calculating result
res = tf.math.zeta(a, b)
# Printing the result
print('Result:', res)
輸出:
a: tf.Tensor([-5. -7. 2. 0. 7.], shape=(5, ), dtype=float64) b: tf.Tensor([1. 3. 9. 4. 7.], shape=(5, ), dtype=float64) Result: tf.Tensor( [ nan nan 1.17512015e-01 nan 2.12260976e-06], shape=(5, ), dtype=float64)
範例2:
Python3
# importing the library
import tensorflow as tf
# Initializing the input tensor
a = tf.constant([ [-5, -7], [ 2, 0]], dtype = tf.float64)
b = tf.constant([ [1, 3], [9, 4]], dtype = tf.float64)
# Printing the input tensor
print('a:', a)
print('b:', b)
# Calculating result
res = tf.math.zeta(a, b)
# Printing the result
print('Result:', res)
輸出:
a: tf.Tensor( [[-5. -7.] [ 2. 0.]], shape=(2, 2), dtype=float64) b: tf.Tensor( [[1. 3.] [9. 4.]], shape=(2, 2), dtype=float64) Result: tf.Tensor( [[ nan nan] [0.11751201 nan]], shape=(2, 2), dtype=float64)
注:本文由純淨天空篩選整理自aman neekhara大神的英文原創作品 Python – tensorflow.math.zeta()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。