tf_image.py 文件源码

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

项目:DAVIS-2016-Chanllege-Solution 作者: tangyuhao 项目源码 文件源码
def _assert(cond, ex_type, msg):
    """A polymorphic assert, works with tensors and boolean expressions.
    If `cond` is not a tensor, behave like an ordinary assert statement, except
    that a empty list is returned. If `cond` is a tensor, return a list
    containing a single TensorFlow assert op.
    Args:
      cond: Something evaluates to a boolean value. May be a tensor.
      ex_type: The exception class to use.
      msg: The error message.
    Returns:
      A list, containing at most one assert op.
    """
    if _is_tensor(cond):
        return [control_flow_ops.Assert(cond, [msg])]
    else:
        if not cond:
            raise ex_type(msg)
        else:
            return []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号