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])
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]