首页 > 技术文章 > tensorflow Relu激活函数

lovephysics 2017-07-21 18:49 原文

1、Relu激活函数

Relu激活函数(The Rectified Linear Unit)表达式为:f(x)=max(0,x)

2、tensorflow实现

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tensorflow as tf

input_data = tf.constant( [[0, 10, -10],[-1,2,-3]] , dtype = tf.float32 )
output = tf.nn.relu(input_data)
sess=tf.Session()

print(sess.run(output))

输出为:

[[ 0. 10. 0.]
[ 0. 2. 0.]]

 

推荐阅读