regularization.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:QuantizedRNN 作者: ottj 项目源码 文件源码
def dual_copy_rounding(W,integer_bits=0,fractional_bits=1):
    """
    Rounding as described in as in "Robustness of spiking Deep Belief Networks to noise and reduced bit precision
    of neuro-inspired hardware platforms"
    by Stromatidis et al. See http://dx.doi.org/10.3389/fnins.2015.00222
    :param W: Weights
    :param integer_bits: number of bits to represent the integer part
    :param fractional_bits: number of bits to represent the fractional part
    :return:quantized weights
    """
    #print "Dual copy rounding!"
    power = T.cast(2.**fractional_bits, theano.config.floatX) # float !
    max_val = T.cast((2.**(fractional_bits+integer_bits))-1, theano.config.floatX)
    value = W*power
    value = GradPreserveRoundTensor(value) # rounding
    value = T.clip(value, -max_val, max_val) # saturation arithmetic
    Wb = value/power
    return Wb
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号