Пример #1
0
def softmax2D(M, t = 1.0):
    E = F.map(M, lambda row: [math.exp(x/t) for x in row])
    total = F.sum(F.map(E, lambda row: F.sum(row)))
    return F.map(E, lambda row: [x/total for x in row])
Пример #2
0
def softmax(M, t = 1.0):
    E = [math.exp(x/t) for x in M]
    total = F.sum(E)
    return [x/total for x in E]