激活函数

tf.nn.relu ( features, name = None )
解释:这个函数的作用是计算激活函数 relu,即 max ( features, 0 )
输入参数:features: 一个Tensor。数据类型必须是:float32,float64,int3, int64,uint8,int16,int8,name: (可选)为这个操作取一个名字
输出参数:一个Tensor,数据类型和features相同

import tensorflow as tf


a = tf.constant([-2.0, -1.0, 2.0, 3.0])
with tf.Session() as sess:
       b = tf.nn.relu(a)
       print(sess.run(b))

-----

[0. 0. 2. 3.]

tf.nn.relu6(features, name = None)
解释:这个函数的作用是计算激活函数relu6,即min(max(features, 0), 6)
输入参数:features: 一个Tensor。数据类型必须是:float,double,int32, int64,uint8,int16或者int8, name: (可选)为这个操作取一个名字
输出参数:一个Tensor,数据类型和features相同

import tensorflow as tf
a = tf.constant([-2.0, -1.0, 1.0, 5.0, 10.0])
with tf.Session() as sess:
       b = tf.nn.relu6(a)
       print(sess.run(b))
----

[0. 0. 1. 5. 6.]

tf.nn.softplus(features, name = None)
解释:这个函数的作用是计算激活函数softplus,即log( exp( features ) + 1)
输入参数:features: 一个Tensor。数据类型必须是:float32,float64,int32,int64,uint8,int16或者int8, name: (可选)为这个操作取一个名字。
输出参数:一个Tensor,数据类型和features相同

-----

[0.6931472 1.3132616]


posted on 2019-05-07 11:13  happygril3  阅读(127)  评论(0编辑  收藏  举报

导航