NumPy Sigmoid 函数:实现与示例代码
在 NumPy 中,可以使用 exp 函数和 1 / (1 + exp(-x)) 来实现 sigmoid 函数。下面是一个示例代码:
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x))
x = np.array([1, 2, 3])
print(sigmoid(x)) # 输出 [0.73105858 0.88079708 0.95257413]
原文地址: https://www.cveoy.top/t/topic/m7ST 著作权归作者所有。请勿转载和采集!