题解|softmax激活函数实现

softmax激活函数实现

https://www.nowcoder.com/practice/438e5a90131b42a9b2caa0484cf6cf0b?tpId=377&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj

softmax激活函数实现(Softmax Activation Function Implementation)是神经网络中的最常见的激活函数之一。 softmax函数其公式为

标准代码如下

def softmax(scores: list[float]) -> list[float]:
    exp_scores = [math.exp(score) for score in scores]
    sum_exp_scores = sum(exp_scores)
    probabilities = [round(score / sum_exp_scores, 4) for score in exp_scores]
    return probabilities
全部评论

相关推荐

每晚夜里独自颤抖:把华北改为华南再试一试,应该就没啥问题了。改完可能都不用投,别人主动联系了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务