zhusuan/distributions/utils.py
def assert_rank_at_least_one(tensor, name):
    """
    Whether the rank of `tensor` is at least one.

    :param tensor: A tensor to be checked.
    :param name: The name of `tensor` for error message.
    :return: (checked tensor, the last dimension of `tensor`).
    """
    static_shape = tensor.get_shape()
    shape_err_msg = name + " should have rank >= 1."
    if static_shape and (static_shape.ndims < 1):
        raise ValueError(shape_err_msg)
    elif static_shape and (static_shape[-1].value is not None):
        return tensor, static_shape[-1].value
    else:
        _assert_shape_op = tf.assert_rank_at_least(
            tensor, 1, message=shape_err_msg)
        with tf.control_dependencies([_assert_shape_op]):
            tensor = tf.identity(tensor)
        return tensor, tf.shape(tensor)[-1]

    Whether the rank of `tensor` is at least one.

    :param tensor: A tensor to be checked.
    :param name: The name of `tensor` for error message.
    :return: (checked tensor, the last dimension of `tensor`).
    
Whether the rank of `tensor` is at least one.
Whether the rank of ` tensor ` is at least one .
def assert_rank_at_least_one(tensor, name):
    static_shape = tensor.get_shape()
    shape_err_msg = name + " should have rank >= 1."
    if static_shape and (static_shape.ndims < 1):
        raise ValueError(shape_err_msg)
    elif static_shape and (static_shape[-1].value is not None):
        return tensor, static_shape[-1].value
    else:
        _assert_shape_op = tf.assert_rank_at_least(
            tensor, 1, message=shape_err_msg)
        with tf.control_dependencies([_assert_shape_op]):
            tensor = tf.identity(tensor)
        return tensor, tf.shape(tensor)[-1]
def assert_rank_at_least_one ( tensor , name ) : static_shape = tensor . get_shape ( ) shape_err_msg = name + " should have rank >= 1." if static_shape and ( static_shape . ndims < 1 ) : raise ValueError ( shape_err_msg ) elif static_shape and ( static_shape [ - 1 ] . value is not None ) : return tensor , static_shape [ - 1 ] . value else : _assert_shape_op = tf . assert_rank_at_least ( tensor , 1 , message = shape_err_msg ) with tf . control_dependencies ( [ _assert_shape_op ] ) : tensor = tf . identity ( tensor ) return tensor , tf . shape ( tensor ) [ - 1 ]
Whether the rank of `tensor` is at least one.
Whether the rank of ` tensor ` is at least one .
"""
    Whether the rank of `tensor` is at least one.

    :param tensor: A tensor to be checked.
    :param name: The name of `tensor` for error message.
    :return: (checked tensor, the last dimension of `tensor`).
    """
(checked tensor, the last dimension of `tensor`).
( checked tensor the last dimension of ` tensor ` ) .
tensor
A tensor to be checked.
A tensor to be checked .
name
The name of `tensor` for error message.
The name of ` tensor ` for error message .