gpt4 book ai didi

numpy - numpy中的Theano开关

转载 作者:行者123 更新时间:2023-12-04 14:43:14 25 4
gpt4 key购买 nike

在 theano 中,我有一个值大约为 0 的向量,并使用 switch 将每个小于 0 的值设置为 0:

T.switch(x < 0, 0, x)

我如何使用 numpy 做同样的事情?

最佳答案

回答numpy的问题开关模拟

numpy.where(x < 0, 0, x)

但特别是对于这个任务,我更喜欢使用为此目的创建的函数
x.clip(0)

关于numpy - numpy中的Theano开关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30582917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com