当前位置:网站首页>Numpy np.max和np.maximum实现relu函数
Numpy np.max和np.maximum实现relu函数
2022-07-03 10:22:00 【郭庆汝】
Numpy np.max和np.maximum实现relu函数
1. np.max 计算一个数组中的最值
(1)基础用法
a = np.array([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
])
print(np.max(a))
print(np.max(a, axis=0))
print(np.max(a, axis=1))
[Out]:
9
[7 8 9]
[3 6 9]
(2)keepdims:维持形状
print(np.max(a, keepdims=True))
print(np.max(a, axis=0, keepdims=True))
print(np.max(a, axis=1, keepdims=True))
[Out]:
[[9]]
[[7 8 9]]
[[3]
[6]
[9]]
(3)initial:指定最小值
print(np.max(a, initial=8))
print(np.max(a, axis=0, initial=8))
print(np.max(a, axis=1, initial=8))
[Out]:
9
[8 8 9]
[8 8 9]
(4)where:指定参与比较的元素,不参与的置initial值
print(np.max(a, initial=8, where=[1, 1, 0]))
print(np.max(a, axis=0, initial=8, where=[True, True, False]))
print(np.max(a, axis=1, initial=8, where=[True, True, False]))
[Out]:
8
[8 8 8]
[8 8 8]
2. np.maximum 比较两个数组的最值
a = np.array([
[1, 2, 3],
[4, 5, 6]
])
b = np.array([
[7, 8, 9],
[0, 1, 2]
])
print(np.maximum(a, b))
print(np.maximum(a, 3.5))
[Out]:
[[7 8 9]
[4 5 6]]
[[3.5 3.5 3.5]
[4. 5. 6. ]]

def relu(inX):
return np.maximum(0,inX)
边栏推荐
- 图解网络:什么是虚拟路由器冗余协议 VRRP?
- Unique in the industry! Fada electronic contract is on the list of 36 krypton hard core technology enterprises
- Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure
- 2022-07-02: what is the output of the following go language code? A: Compilation error; B:Panic; C:NaN。 package main import “fmt“ func mai
- 活动预告 | 直播行业“内卷”,以产品力拉动新的数据增长点
- [OBS] encapsulate the basic process of OBS acquisition
- 浅析-JMM内存模型
- 数据库增量备份 - DB INCR DB FULL
- A simple method of adding dividing lines in recyclerview
- 历经一个月,终于拿到金蝶Offer!分享一下四面面经+复习资料
猜你喜欢
![[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder](/img/1f/729594930c7c97d3e731987f4c3645.png)
[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder

MATLAB extrait les données numériques d'un fichier txt irrégulier (simple et pratique)

Abandon the Internet after 00: don't want to enter a big factory after graduation, but go to the most fashionable Web3

I have been doing software testing for three years, and my salary is less than 20K. Today, I put forward my resignation

Processes and threads

多维度监控:智能监控的数据基础

Application of high-precision indoor positioning technology in safety management of smart factory

Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche

The testing department of the company came to the king of the Post-00 roll, and the veteran exclaimed that it was really dry, but

FL Studio 20无限试用版水果编曲下载
随机推荐
How did I grow up in the past eight years as a test engineer of meituan? I hope technicians can gain something after reading it
反正切熵(Arctangent entropy):2022.7月最新SCI论文
面試題總結(2) IO模型,集合,NIO 原理,緩存穿透,擊穿雪崩
ASP.NET-酒店管理系统
2022-07-02: what is the output of the following go language code? A: Compilation error; B:Panic; C:NaN。 package main import “fmt“ func mai
Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡
进程与线程
How to become a senior digital IC Design Engineer (1-3) Verilog coding syntax: Verilog behavior level, register transfer level, gate level (abstract level)
浅析-JMM内存模型
2. Hal hardware abstraction layer
AMS Series 1 - AMS startup process
Tencent micro app to get wechat user information
Multi dimensional monitoring: the data base of intelligent monitoring
Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
读书笔记:《心若菩提》 曹德旺
线性表顺序表综合应用题P18
触摸与屏幕自动旋转调试
如何成为一名高级数字 IC 设计工程师(1-4)Verilog 编码语法篇:表达式
Incremental database backup - DB incr DB full
行业唯一!法大大电子合同上榜36氪硬核科技企业