提交 9664ce69 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

fix import issue

上级 3dcaac82
......@@ -1153,6 +1153,12 @@ def hex_digest(x):
Returns a short, mostly hexadecimal hash of a numpy ndarray
"""
global hashlib
if hashlib is None:
try:
import hashlib
except ImportError:
raise RuntimeError("Can't run hex_digest because hashlib is not available.")
assert isinstance(x, np.ndarray)
rval = hashlib.md5(x.tostring()).hexdigest()
# hex digest must be annotated with strides to avoid collisions
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论