当前位置:网站首页>Numpy np. Max and np Maximum implements the relu function
Numpy np. Max and np Maximum implements the relu function
2022-07-03 11:27:00 【Guoqingru】
Numpy np.max and np.maximum Realization relu function
1. np.max Calculate the maximum value in an array
(1) Basic usage
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: Maintain shape
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: Specify the minimum
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: Specify the elements that participate in the comparison , Non participating settings initial value
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 Compare the maximum values of two arrays
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)
边栏推荐
猜你喜欢
Application of high-precision indoor positioning technology in safety management of smart factory
Redis things
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
Cadence background color setting
Cuiyusong, CTO of youzan: the core goal of Jarvis is to make products smarter and more reliable
PHP server interacts with redis with a large number of close_ Wait analysis
Driver development based on I2C protocol
多维度监控:智能监控的数据基础
ASP.NET-酒店管理系统
软件测试周刊(第78期):你对未来越有信心,你对现在越有耐心。
随机推荐
Numpy np.max和np.maximum实现relu函数
Encapsulation attempt of network request framework of retro + kotlin + MVVM
Unique in the industry! Fada electronic contract is on the list of 36 krypton hard core technology enterprises
Ext file system mechanism principle
2022 东北四省赛 VP记录/补题
one hot 独热码
软考中级软件设计师该怎么备考
How to clean up v$rman_ backup_ job_ Details view reports error ora-02030
Technical experts from large factories: how can engineers improve their communication skills?
ORACLE 11G 单机冷备数据库
00后抛弃互联网: 毕业不想进大厂,要去搞最潮Web3
多维度监控:智能监控的数据基础
Double linked list of linear list
DS90UB949
CSRF
repo ~ 常用命令
一些常用术语
动态规划(区间dp)
Using onvif protocol to operate the device
asyncio 警告 DeprecationWarning: There is no current event loop