吴裕雄 python深度学习与实践(4)

import numpy,math

def softmax(inMatrix):
m,n = numpy.shape(inMatrix)
outMatrix = numpy.mat(numpy.zeros((m,n)))
soft_sum = 0
for idx in range(0,n):
outMatrix[0,idx] = math.exp(inMatrix[0,idx])
soft_sum += outMatrix[0,idx]
for idx in range(0,n):
outMatrix[0,idx] = outMatrix[0,idx] / soft_sum
return outMatrix aa = numpy.matrix([1,2,3,4,5,4,3,9,8])
outMatrix = softmax(aa)
print(outMatrix)

吴裕雄 python深度学习与实践(4)

上一篇:20155313 实验二《Java面向对象程序设计》实验报告


下一篇:python pyqt绘制直方图