【发布时间】:2017-08-09 21:47:35
【问题描述】:
在矩阵上调用 numpy sum 函数时,Python 会引发错误。
probs = exp_scores / np.sum(exp_scores, axis=1, keepdims=True)
错误
probs = exp_scores / np.sum(exp_scores, axis=1, keepdims=True)
TypeError: sum() got an unexpected keyword argument 'keepdims'
上下文:计算 softmax 分类器的损失函数。分子是正确类别的得分函数的指数,分母是所有可能类别的所有指数的总和。
【问题讨论】:
-
你的 NumPy 版本是多少?听起来很老。