softmax代码实现
时间: 2023-08-27 20:05:05 浏览: 129
AmSoftmax pytorch实现代码
Sure, here's a basic implementation of softmax function in Python:
```
import numpy as np
def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum()
# example usage
x = np.array([1, 2, 3])
print(softmax(x))
```
Hope that helps!
阅读全文