tensorflow中的激活函数对应代码
时间: 2023-06-03 17:02:37 浏览: 110
激活函数_ancientzyb_神经网络激活函数代码_
5星 · 资源好评率100%
以下是常见的几种激活函数及其对应代码:
1. Sigmoid函数:
```
import tensorflow as tf
output = tf.nn.sigmoid(logits)
```
2. ReLU函数:
```
import tensorflow as tf
output = tf.nn.relu(logits)
```
3. Leaky ReLU函数:
```
import tensorflow as tf
output = tf.nn.leaky_relu(logits, alpha=0.2)
```
4. Tanh函数:
```
import tensorflow as tf
output = tf.nn.tanh(logits)
```
5. Softmax函数:
```
import tensorflow as tf
output = tf.nn.softmax(logits)
```
阅读全文