使用numpy.tanh()打印矢量/矩阵元素的双曲正切值 使用Python的线性代数
Prerequisite:
先決條件:
Defining a Vector
定義向量
Defining a Matrix
定義矩陣
Numpy is the library of function that helps to construct or manipulate matrices and vectors. The function numpy.tanh(x) is a function used for generating a matrix / vector / variable with the Tangent Hyperbolic value of b x (as tanh(x)).
Numpy是一個功能庫,可幫助構造或操縱矩陣和向量。 函數numpy.tanh(x)是用于生成正切雙曲值為b x的矩陣/向量/變量(作為tanh(x) )的函數 。
Syntax:
句法:
numpy.tanh(x)Input parameter(s):
輸入參數:
x – could be a matrix or vector or a variable.
x –可以是矩陣,向量或變量。
Return value:
返回值:
A Matrix or vector or a variable of the same dimensions as input x with tanh(x) values (between 0 and 1) at each entry.
與輸入x尺寸相同的矩陣或向量或變量,每個條目處具有tanh(x)值(介于0和1之間)。
Applications:
應用范圍:
Machine Learning
機器學習
Neural Network
神經網絡
Python代碼將向量/矩陣元素的雙曲正切值 (Python code to hyperbolic tangent value of vector/matrix elements)
# Linear Algebra Learning Sequence # Printing hyperbolic tangent value of # vector/matrix elements using numpy.tanh()import numpy as np#Use of np.array() to define an Vector V = np.array([323,.623,823]) print("The Vector A : ",V)VV = np.array([[3,63,.78],[.315,32,42]]) print("\nThe Vector B : \n",VV)pro = V.dot(VV.T)print("\nProduct of two vectors : ", pro)print("\ntanh(AB) : ", np.tanh(pro)) print("\ntanh(A) : ", np.tanh(V)) print("\ntanh(B) : \n", np.tanh(VV))Output:
輸出:
The Vector A : [3.23e+02 6.23e-01 8.23e+02]The Vector B : [[ 3. 63. 0.78 ][ 0.315 32. 42. ]]Product of two vectors : [ 1650.189 34687.681]tanh(AB) : [1. 1.]tanh(A) : [1. 0.55321335 1. ]tanh(B) : [[0.99505475 1. 0.65270671][0.30497892 1. 1. ]]翻譯自: https://www.includehelp.com/python/printing-hyperbolic-tangent-value-of-vector-matrix-elements-using-numpy-tanh.aspx
總結
以上是生活随笔為你收集整理的使用numpy.tanh()打印矢量/矩阵元素的双曲正切值 使用Python的线性代数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极米投影仪 哪里生产的
- 下一篇: 向量余弦值python_向量/矩阵的余弦