当前位置:网站首页>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)
边栏推荐
- Activity and fragment lifecycle
- Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
- Definition and properties of summation symbols
- (二)进制
- (2) Base
- CorelDRAW Graphics Suite 2022新版功能详情介绍
- JGG专刊征稿:时空组学
- 软件测试周刊(第78期):你对未来越有信心,你对现在越有耐心。
- 按键切换:按F1-F12都需要按Fn
- 有赞CTO崔玉松:有赞Jarvis核心目标是使产品变得更加聪明和可靠
猜你喜欢

FL Studio 20无限试用版水果编曲下载

反正切熵(Arctangent entropy):2022.7月最新SCI论文

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

基于I2C协议的驱动开发

redis那些事儿

How to clean up v$rman_ backup_ job_ Details view reports error ora-02030

Solve undefined reference to`__ aeabi_ Uidivmod 'and undefined reference to`__ aeabi_ Uidiv 'error

数据库增量备份 - DB INCR DB FULL

My understanding of testing (summarized by senior testers)

Incremental database backup - DB incr DB full
随机推荐
How to become a senior digital IC Design Engineer (1-4) Verilog coding syntax: expression
如何清理v$rman_backup_job_details视图 报错ORA-02030
Kotlin's use of the no Arg compiler plug-in in gradle
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
Encapsulate a koa distributed locking middleware to solve the problem of idempotent or repeated requests
FL Studio 20无限试用版水果编曲下载
Internet socket (non) blocking write/read n bytes
Inexplicable problems in the nesting of constraintlayout and relativelayout
帝国cms 无缩略图 灵动标签(e:loop)判断有无标题图片(titlepic)的两种写法
Struct function & function pointer
[VTK] vtkWindowedSincPolyDataFilter 源码注释解读
Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
使用onvif协议操作设备
面试题总结(2) IO模型,集合,NIO 原理,缓存穿透,击穿雪崩
浅析-JMM内存模型
软件测试周刊(第78期):你对未来越有信心,你对现在越有耐心。
MATLAB提取不规则txt文件中的数值数据(简单且实用)
今晚要修稿子準備發佈。但是,仍卡在這裡,也許你需要的是一個段子。
线性表的双链表
redis那些事儿