Beispiel #1
0
def fully_connect_bn(pre_layer,
                     output_dim,
                     act,
                     use_bias,
                     training,
                     epsilon=1e-4,
                     alpha=.1,
                     binary=True,
                     stochastic=False,
                     H=1.,
                     W_LR_scale="Glorot"):
    pre_act = binary_layer.dense_binary(
        pre_layer,
        output_dim,
        use_bias=use_bias,
        kernel_constraint=lambda w: tf.clip_by_value(w, -1.0, 1.0))
    bn = binary_layer.batch_normalization(pre_act,
                                          momentum=1 - alpha,
                                          epsilon=epsilon,
                                          training=training)
    if act == None:
        output = bn
    else:
        output = act(bn)
    return output
Beispiel #2
0
def fully_connect_bn(pre_layer, output_dim, act, use_bias, training):
    pre_act = binary_layer.dense_binary(
        pre_layer,
        output_dim,
        use_bias=use_bias,
        activation=None,
        kernel_constraint=lambda w: tf.clip_by_value(w, -1.0, 1.0))
    bn = binary_layer.batch_normalization(pre_act,
                                          momentum=0.9,
                                          epsilon=1e-4,
                                          training=training)
    if act == None:
        output = bn
    else:
        output = act(bn)
    return output