激活函数(relu,prelu,elu,+BN)对比on cifar10

Lrelu实现:
def lrelu(x, leak=0.2, name="lrelu"):
return tf.maximum(x, leak * x) Prelu实现:
def parametric_relu(_x):
alphas = tf.get_variable('alpha', _x.get_shape()[-1],
initializer=tf.constant_initializer(0.25),
dtype = tf.float32
)
pos = tf.nn.relu(_x)
neg = alphas * (_x - abs(_x)) * 0.5
print(alphas)
return pos + neg BN实现:
def batch_norm(x, n_out,scope='bn'):
"""
Batch normalization on convolutional maps.
Args:
x: Tensor, 4D BHWD input maps
n_out: integer, depth of input maps
phase_train: boolean tf.Variable, true indicates training phase
scope: string, variable scope Return:
normed: batch-normalized maps
"""
with tf.variable_scope(scope):
beta = tf.Variable(tf.constant(0.0, shape=[n_out]),
name='beta', trainable=True)
gamma = tf.Variable(tf.constant(1.0, shape=[n_out]),
name='gamma', trainable=True)
tf.add_to_collection('biases', beta)
tf.add_to_collection('weights', gamma) batch_mean, batch_var = tf.nn.moments(x, [0,1,2], name='moments')
ema = tf.train.ExponentialMovingAverage(decay=0.99) def mean_var_with_update():
ema_apply_op = ema.apply([batch_mean, batch_var])
with tf.control_dependencies([ema_apply_op]):
return tf.identity(batch_mean), tf.identity(batch_var)
#mean, var = control_flow_ops.cond(phase_train,
# mean, var = control_flow_ops.cond(phase_train,
# mean_var_with_update,
# lambda: (ema.average(batch_mean), ema.average(batch_var)))
mean, var = mean_var_with_update()
normed = tf.nn.batch_normalization(x, mean, var,
beta, gamma, 1e-3)
return normed




解压:tar -zxvf xxx.tar.gz
cifar-100-python/
cifar-100-python/file.txt~
cifar-100-python/train
cifar-100-python/test
cifar-100-python/meta
def unpickle(file):
import cPickle
fo = open(file, ‘rb’)
dict = cPickle.load(fo)
fo.close()
return dict
label_bytes =2 # 2 for CIFAR-100
#取第二个标签100维
result.label = tf.cast(
tf.strided_slice(record_bytes, [1], [label_bytes]), tf.int32)
https://towardsdatascience.com/activation-functions-neural-networks-1cbd9f8d91d6
激活函数(relu,prelu,elu,+BN)对比on cifar10的更多相关文章
- 激活函数ReLU、Leaky ReLU、PReLU和RReLU
“激活函数”能分成两类——“饱和激活函数”和“非饱和激活函数”. sigmoid和tanh是“饱和激活函数”,而ReLU及其变体则是“非饱和激活函数”.使用“非饱和激活函数”的优势在于两点: 1 ...
- [转]激活函数ReLU、Leaky ReLU、PReLU和RReLU
“激活函数”能分成两类——“饱和激活函数”和“非饱和激活函数”. sigmoid和tanh是“饱和激活函数”,而ReLU及其变体则是“非饱和激活函数”.使用“非饱和激活函数”的优势在于两点: 1 ...
- 激活函数(ReLU, Swish, Maxout)
神经网络中使用激活函数来加入非线性因素,提高模型的表达能力. ReLU(Rectified Linear Unit,修正线性单元) 形式如下: \[ \begin{equation} f(x)= \b ...
- 【机器学习】激活函数(ReLU, Swish, Maxout)
https://blog.csdn.net/ChenVast/article/details/81382939 神经网络中使用激活函数来加入非线性因素,提高模型的表达能力. ReLU(Rectifie ...
- ReLU 和sigmoid 函数对比
详细对比请查看:http://www.zhihu.com/question/29021768/answer/43517930 . 激活函数的作用: 是为了增加神经网络模型的非线性.否则你想想,没有激活 ...
- ReLU 和sigmoid 函数对比以及droupout
参考知乎的讨论:https://www.zhihu.com/question/29021768 1.计算简单,反向传播时涉及除法,sigmod求导要比Relu复杂: 2.对于深层网络,sigmod反向 ...
- caffe Python API 之激活函数ReLU
import sys import os sys.path.append("/projects/caffe-ssd/python") import caffe net = caff ...
- Difference between ReLU、LReLU、PReLU、CReLU、ELU、SELU
激活函数 ReLU.LReLU.PReLU.CReLU.ELU.SELU 的定义和区别 ReLU tensorflow中:tf.nn.relu(features, name=None) LReLU ...
- 神经网络中的激活函数具体是什么?为什么ReLu要好过于tanh和sigmoid function?(转)
为什么引入激活函数? 如果不用激励函数(其实相当于激励函数是f(x) = x),在这种情况下你每一层输出都是上层输入的线性函数,很容易验证,无论你神经网络有多少层,输出都是输入的线性组合,与没有隐藏层 ...
随机推荐
- Markdown 常用操作
1->水平线 注意,使用时发现,水平线的语句上一行必须为空行,不然水平线不生效 *** 或者 --- ------->效果: 2->标题 # 大 ## 大 ### 大 #### 大 ...
- liunx相关指令
修改网卡命名规范 a 如何进入到救援模式 修改网卡 1.修改配置文件名称 /etc/sysconfig/network-scripts/ 名称为:ifcfg-xxx 2.修改配置文件内的 dev ...
- Spring Security构建Rest服务-0701-个性化用户认证流程
上一篇说了用户认证的基本流程,但是上一篇当访问一个受保护的服务后,如果未认证会调到默认的登录页面,这样是不行的,而且认证成功后,就直接访问了那个服务,如果想要做认证成功后做一些操作,还需要自定义. 个 ...
- jdbc调试sql语句方法
在main命令行输入三个参数到oracle 的 dept2表(自己建的 和dept一样(deptno,dname,loc)),插入到数据库中去.通过本例子,学习在java里调试sql的方法. 写完sq ...
- Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but CLSID_VirtualBox w/ IUnknown works.
我是 win7 64位 解决办法: 1, win+r 快捷键打开 “运行”,输入regedit 打开注册表 2,找到 HKEY_CLASSES_ROOT\CLSID\{00020420-0000-00 ...
- Flow类
JLS参考:https://docs.oracle.com/javase/specs/jls/se7/html/jls-16.html This pass implements dataflow an ...
- Web自动化 - 选择操作元素 1
文章转自 白月黑羽教Python 所有的 UI (用户界面)操作 的自动化,都需要选择界面元素. 选择界面元素就是:先让程序能找到你要操作的界面元素. 先找到元素,才能操作元素. 选择元素的方法 程序 ...
- ls命令显示的total你知道代表着什么吗?
今天我无意间在用ls命令的时候发现显示的内容里的total,这个total代表着什么,引起了我的疑惑. 接下来开始解开它的神秘面纱. total后面的数字是指当前目录下所有文件所占用的空间总和,它是怎 ...
- Linux-(touch,cat,nl,more|less,head|tail)
touch命令 1.命令格式: touch [选项]... 文件... 2.命令参数: -a 或--time=atime或--time=access或--time=use 只更改存取时间. -c ...
- jquery.dataTables动态列--转
转自 https://www.cnblogs.com/lyeo/p/4765514.html jquery.dataTables 版本1.10.7 直接上代码: 0.table <table ...