使用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:

應用范圍:

  1. Machine Learning

    機器學習

  2. 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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/376984.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/376984.shtml
英文地址,請注明出處:http://en.pswp.cn/news/376984.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Mahout kmeans聚類

Mahout K-means聚類 一、Kmeans 聚類原理 K-means算法是最為經典的基于劃分的聚類方法,是十大經典數據挖掘算法之一。K-means算法的基本思想是:以空間中k個點為中心進行聚類,對最靠近他們的對象歸類。通過迭代的方法,逐次更新各聚…

Web項目中獲取SpringBean——在非Spring組件中獲取SpringBean

最近在做項目的時候我發現一個問題:Spring的IOC容器不能在Web中被引用(或者說不能被任意地引用)。我們在配置文件中讓Spring自動裝配,但并沒有留住ApplicationContext的實例。我們如果希望在我們的項目中任何位置都能拿到同一個ApplicationContext來獲取…

postgresql對于HashJoin算法的Data skew優化與MCV處理

Data skew 很好理解,即數據傾斜。現實中的數據很多都不是正態分布的,譬如城市人口,東部沿海一個市的人口與西部地區一個市地區的人口相比,東部城市人口會多好幾倍。 postgresql的skew的優化核心思想是"避免磁盤IO"。 優…

JavaScript | 創建對象并通過JavaScript函數在表中顯示其內容

In this example, we created an object named employee with id, name, gender, city, and salary and assigned and displaying the values in the table using JavaScript function. 在此示例中,我們創建了一個名為employee的對象,其對象為id &#x…

基于socket的簡單文件傳輸系統

【實驗目的及要求】 在 Uinx/Linux/Windows 環境下通過 socket 方式實現一個基于 Client/Server 文件傳輸程序。 【實驗原理和步驟】 1. 確定傳輸模式:通過 socket 方式實現一個基于 Client/Server 或 P2P 模式的文件傳輸程序。 2. 如果選擇的是 Client/Server 模式的文件傳輸…

《GPU高性能編程-CUDA實戰》中例子頭文件使用

《GPU高性能編程-CUDA實戰(CUDA By Example)》中例子中使用的一些頭文件是CUDA中和C中本身沒有的,需要先下載這本書的源碼,可以在:https://developer.nvidia.com/content/cuda-example-introduction-general-purpose-g…

mcq 隊列_人工智能| AI解決問題| 才能問題解答(MCQ)| 套裝1

mcq 隊列1) Which of the following definitions correctly defines the State-space in an AI system? A state space can be defined as the collection of all the problem statesA state space is a state which exists in environment which is in outer spaceA state sp…

Postgresql的HashJoin狀態機流程圖整理

狀態機 可以放大觀看。 HashJoinState Hash Join運行期狀態結構體 typedef struct HashJoinState {JoinState js; /* 基類;its first field is NodeTag */ExprState *hashclauses;//hash連接條件List *hj_OuterHashKeys; /* 外表條件鏈表;list of …

Ajax和Jsonp實踐

之前一直使用jQuery的ajax方法,導致自己對瀏覽器原生的XMLHttpRequest對象不是很熟悉,于是決定自己寫下,以下是個人寫的deom,發表一下,聊表紀念。 Ajax 和 jsonp 的javascript 實現: /*! * ajax.js * …

得到前i-1個數中比A[i]小的最大值,使用set,然后二分查找

題目 有一個長度為 n 的序列 A&#xff0c;A[i] 表示序列中第 i 個數(1<i<n)。她定義序列中第 i 個數的 prev[i] 值 為前 i-1 個數中比 A[i] 小的最大的值&#xff0c;即滿足 1<j<i 且 A[j]<A[i] 中最大的 A[j]&#xff0c;若不存在這樣的數&#xff0c;則 pre…

學習語言貴在堅持

學習語言貴在堅持 轉自&#xff1a;http://zhidao.baidu.com/link?urlr2W_TfnRwipvCDLrhZkATQxdrfghXFpZhkLxqH1oUapLOr8jXW4tScbyOKRLEPVGCx0dUfIr-30n9XV75pWYfK給大家介紹幾本書和別處COPY來的學習C50個觀點 《Thinking In C》&#xff1a;《C編程思想》&#xff1b; 《The…

stl vector 函數_在C ++ STL中使用vector :: begin()和vector :: end()函數打印矢量的所有元素...

stl vector 函數打印向量的所有元素 (Printing all elements of a vector) To print all elements of a vector, we can use two functions 1) vector::begin() and vector::end() functions. 要打印矢量的所有元素&#xff0c;我們可以使用兩個函數&#xff1a;1) vector :: b…

JqueryUI入門

Jquery UI 是一套開源免費的、基于Jquery的插件&#xff0c;在這里記錄下Jquery UI 的初步使用。 第一、下載安裝 下載Jquery,官網&#xff1a;http://jquery.com;  下載Jquery UI&#xff0c;官網&#xff1a;http://jqueryui.com/ Jquery的部署就不說了&#xff0c;說下Jqu…

gp的分布、分區策略(概述)

對于大規模并行處理數據庫來說&#xff0c;一般由單master與多segment組成。 那么數據表的單行會被分配到一個或多個segment上&#xff0c;此時需要想一想分布策略 分布 在gp6中&#xff0c;共有三個策略&#xff1a; 哈希分布 隨機分布 復制分布 哈希分布 就是對分布鍵進行…

[ Java4Android ] Java基本概念

視頻來自&#xff1a;http://www.marschen.com/ 1.什么是環境變量 2.JDK里面有些什么&#xff1f; 3.什么是JRE&#xff1f; 什么是環境變量&#xff1f; 1.環境變量通常是指在操作系統當中&#xff0c;用來指定操作系統運行時需要的一些參數; 2.環境變量通常為一系列的鍵值對&…

_thread_in_vm_Java Thread類的靜態void sleep(long time_in_ms,int time_in_ns)方法,帶示例

_thread_in_vm線程類靜態無效睡眠(long time_in_ms&#xff0c;int time_in_ns) (Thread Class static void sleep(long time_in_ms, int time_in_ns)) This method is available in package java.lang.Thread.sleep(long time_in_ms, int time_in_ns). 軟件包java.lang.Thread…

大規模web服務開發技術(轉)

前段時間趁空把《大規模web服務開發技術》這本書看完了&#xff0c;今天用一下午時間重新翻了一遍&#xff0c;把其中的要點記了下來&#xff0c;權當復習和備忘。由于自己對數據壓縮、全文檢索等還算比較熟&#xff0c;所以筆記內容主要涉及前5章內容&#xff0c;后面的零星記…

IO多路復用的三種機制Select,Poll,Epoll

IO多路復用的本質是通過系統內核緩沖IO數據讓單個進程可以監視多個文件描述符&#xff0c;一旦某個進程描述符就緒(讀/寫就緒)&#xff0c;就能夠通知程序進行相應的讀寫操作。 select poll epoll都是Linux提供的IO復用方式&#xff0c;它們本質上都是同步IO&#xff0c;因為它…

qt中按鈕貼圖

一.QT之QPushButton按鈕貼圖 二.QT之QToolButton按鈕貼圖 一.QT之QPushButton按鈕貼圖具體操作流程 1. Qt Designer中拖入一Tool Button 2. 選擇圖標的圖片放入工程目錄下&#xff0c;如放在Resources內 3. 雙擊工程的Resource Files下的qrc文件&#xff0c;如圖 4. 在彈出的窗…

Ubuntu手動編譯gVim7.3修復終端啟動時與ibus的沖突

個bug伴隨著Ubuntu/ibus的升級苦憋已久&#xff0c;癥狀為終端啟動gvim時卡死&#xff0c;gvim -f可以緩解此問題&#xff0c;但偶爾還是要發作&#xff0c;況且每次末尾托個&也不方便。其實新版gvim已經修復此bug&#xff0c;不過ubuntu安裝包一直沒更新&#xff0c;那我們…