rfho/utils.py
def hvp(loss, w, v, name='hessian_vector_product'):
    """
    Convenience function for hessian vector product.

    :param name:
    :param loss:
    :param w:
    :param v:
    :return:
    """
    # some parameter checking
    if not isinstance(w, list) and not isinstance(v, list):  # single inputs
        if len(v.get_shape().as_list()) == 2 and len(w.get_shape().as_list()) == 1:
            return tf.stack([
                hvp(loss, w, v[:, k]) for k in range(v.get_shape().as_list()[1])
            ], axis=1)
        return wsr(tf.identity(_hvp(loss, [w], [v]), name=name)[0])
    return wsr(tf.identity(_hvp(loss, w, v), name=name))

    Convenience function for hessian vector product.

    :param name:
    :param loss:
    :param w:
    :param v:
    :return:
    
Convenience function for hessian vector product.
Convenience function for hessian vector product .
def hvp(loss, w, v, name='hessian_vector_product'):
    if not isinstance(w, list) and not isinstance(v, list):  
        if len(v.get_shape().as_list()) == 2 and len(w.get_shape().as_list()) == 1:
            return tf.stack([
                hvp(loss, w, v[:, k]) for k in range(v.get_shape().as_list()[1])
            ], axis=1)
        return wsr(tf.identity(_hvp(loss, [w], [v]), name=name)[0])
    return wsr(tf.identity(_hvp(loss, w, v), name=name))
def hvp ( loss , w , v , name = 'hessian_vector_product' ) : if not isinstance ( w , list ) and not isinstance ( v , list ) : if len ( v . get_shape ( ) . as_list ( ) ) == 2 and len ( w . get_shape ( ) . as_list ( ) ) == 1 : return tf . stack ( [ hvp ( loss , w , v [ : , k ] ) for k in range ( v . get_shape ( ) . as_list ( ) [ 1 ] ) ] , axis = 1 ) return wsr ( tf . identity ( _hvp ( loss , [ w ] , [ v ] ) , name = name ) [ 0 ] ) return wsr ( tf . identity ( _hvp ( loss , w , v ) , name = name ) )
Convenience function for hessian vector product.
Convenience function for hessian vector product .
"""
    Convenience function for hessian vector product.

    :param name:
    :param loss:
    :param w:
    :param v:
    :return:
    """ # some parameter checking # single inputs
None
loss
None
w
None
v
None
name
None