Python中sigmoid函数导数的正确计算方法

The right way to calculate the derivative of sigmoid function in Python

我正走过 this article。在代码中,作者提到以下函数求导数:

# convert output of sigmoid function to its derivative
def sigmoid_output_to_derivative(output):
    return output*(1-output)

我真的不明白导数是怎么在这里找到的。使用 SymPy 求导数会更好吗?文章中的例子怎么实现,特别是output会是一个类似于下面的列表:

[[ 0.44856632  0.51939863  0.45968497  0.59156505]
 [ 0.28639589  0.32350963  0.31236398  0.51538526]
 [ 0.40795614  0.62674606  0.23841622  0.49377636]
 [ 0.25371248  0.42628115  0.14321233  0.41732254]]

所以,底线是:

谢谢。

sigmoid 函数之所以有用,主要是因为它的导数在输出方面很容易计算;导数是 f(x)*(1-f(x))

因此,没有必要使用基于 sigmoid 函数的库求导数,因为数学导数(上述)是已知的。推导见this.