02
04
37
02
请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

关于activation(bn)

activation(bn)
为什么可以直接可以这样用,activation这个函数是怎么来的,它不属于tf吗

正在回答 回答被采纳积分+3

插入代码

1回答

正十七 2020-03-05 22:05:49

可以看代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def conv_wrapper(inputs, 
                 name, 
                 is_training,
                 output_channel = 32,
                 kernel_size = (3,3),
                 activation = tf.nn.relu,
                 padding = 'same'):
    """wrapper of tf.layers.conv2d"""
    # without bn: conv -> activation
    # with batch normalization: conv -> bn -> activation
    with tf.name_scope(name):
        conv2d = tf.layers.conv2d(inputs,
                                  output_channel,
                                  kernel_size,
                                  padding = padding,
                                  activation = None,
                                  name = name + '/conv2d')
        bn = tf.layers.batch_normalization(conv2d,
                                           training = is_training)
        return activation(bn)

这里的activation是tensorflow里的激活函数啊,只不过它是从外面传进来的。默认是tf.nn.relu.

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号