deepy/trainers/util.py
def multiple_l2_norm(tensors):
    """
    Get the L2 norm of multiple tensors.
    This function is taken from blocks.
    """
    # Another way for doing this, I don't know which one is fast
    # return T.sqrt(sum(T.sum(t ** 2) for t in tensors))
    flattened = [T.as_tensor_variable(t).flatten() for t in tensors]
    flattened = [(t if t.ndim > 0 else t.dimshuffle('x'))
                 for t in flattened]
    joined = T.join(0, *flattened)
    return T.sqrt(T.sqr(joined).sum())
def multiple_l2_norm(tensors):
    """
    Get the L2 norm of multiple tensors.
    This function is taken from blocks.
    """
    # Another way for doing this, I don't know which one is fast
    # return T.sqrt(sum(T.sum(t ** 2) for t in tensors))
    flattened = [T.as_tensor_variable(t).flatten() for t in tensors]
    flattened = [(t if t.ndim > 0 else t.dimshuffle('x'))
                 for t in flattened]
    joined = T.join(0, *flattened)
    return T.sqrt(T.sqr(joined).sum())
def multiple_l2_norm ( tensors ) : # Another way for doing this, I don't know which one is fast # return T.sqrt(sum(T.sum(t ** 2) for t in tensors)) flattened = [ T . as_tensor_variable ( t ) . flatten ( ) for t in tensors ] flattened = [ ( t if t . ndim > 0 else t . dimshuffle ( 'x' ) ) for t in flattened ] joined = T . join ( 0 , * flattened ) return T . sqrt ( T . sqr ( joined ) . sum ( ) )
Get the L2 norm of multiple tensors.
    This function is taken from blocks.
Get the L2 norm of multiple tensors . This function is taken from blocks .