当前位置:网站首页>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)
边栏推荐
- 历经一个月,终于拿到金蝶Offer!分享一下四面面经+复习资料
- Matlab extracts numerical data from irregular txt files (simple and practical)
- 动态规划(区间dp)
- EPS电动转向系统分析
- Commonly used discrete random distribution
- IIS修改配置信息后不生效
- 有赞CTO崔玉松:有赞Jarvis核心目标是使产品变得更加聪明和可靠
- php服务器 与redis交互大量CLOSE_WAIT分析
- 今晚要修稿子準備發佈。但是,仍卡在這裡,也許你需要的是一個段子。
- Résumé des questions d'entrevue (2) Modèle io, ensemble, principe NiO, pénétration du cache, avalanche de rupture
猜你喜欢
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
Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡
After using the thread pool for so long, do you really know how to reasonably configure the number of threads?
(二)进制
After a month, I finally got Kingdee offer! Share tetrahedral Sutra + review materials
Résumé des questions d'entrevue (2) Modèle io, ensemble, principe NiO, pénétration du cache, avalanche de rupture
Google Earth engine (GEE) - ghsl global population grid dataset 250 meter resolution
Activity and fragment lifecycle
(2) Base
FL Studio 20 unlimited trial fruit arranger Download
随机推荐
How can UI automated testing get out of trouble? How to embody the value?
ORACLE 11G 单机冷备数据库
How to clean up v$rman_ backup_ job_ Details view reports error ora-02030
ASP.NET-酒店管理系統
The manuscript will be revised for release tonight. But, still stuck here, maybe what you need is a paragraph.
Intel 13th generation core flagship exposure, single core 5.5ghz
【obs】obs的ini格式的ConfigFile
Oracle 11g single machine cold standby database
Matlab extracts numerical data from irregular txt files (simple and practical)
My understanding of testing (summarized by senior testers)
[VTK] vtkWindowedSincPolyDataFilter 源码注释解读
Execute kubectl on Tencent cloud container service node
How to: configure ClickOnce trust prompt behavior
Analysis of JMM memory model
2021 postgraduate entrance examination mathematics 2 linear algebra
.\vmware-vdiskmanager.exe -k “c:\\xxxxx.vmdk”
活动预告 | 直播行业“内卷”,以产品力拉动新的数据增长点
浅析-JMM内存模型
The five-year itch of software testing engineers tells the experience of breaking through bottlenecks for two years
00后抛弃互联网: 毕业不想进大厂,要去搞最潮Web3