util.py 文件源码

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

项目:fold 作者: tensorflow 项目源码 文件源码
def __array__(self, dtype=None):
    """NumPy array protocol; returns iterator values as an ndarray."""
    if self._value is None:
      # Call fromiter if we can; it is faster and avoids the extra
      # copy, but doesn't support object types and requires a dtype.
      if dtype is None or dtype.hasobject:
        self._value = np.array(list(self._iterator), dtype)
      else:
        self._value = np.fromiter(self._iterator, dtype)
    return self._value
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号