使用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.mzph.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;那我们…