本文整理汇总了Python中tensorflow.python.platform.resource_loader.get_path_to_datafile方法的典型用法代码示例。如果您正苦于以下问题:Python resource_loader.get_path_to_datafile方法的具体用法?Python resource_loader.get_path_to_datafile怎么用?Python resource_loader.get_path_to_datafile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.platform.resource_loader
的用法示例。
在下文中一共展示了resource_loader.get_path_to_datafile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_op_library
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def load_op_library(path):
"""Loads a contrib op library from the given path.
NOTE(mrry): On Windows, we currently assume that contrib op
libraries are statically linked into the main TensorFlow Python
extension DLL.
Args:
path: An absolute path to a shared object file.
Returns:
A Python module containing the Python wrappers for Ops defined in the
plugin.
"""
if os.name != 'nt':
path = resource_loader.get_path_to_datafile(path)
ret = load_library.load_op_library(path)
assert ret, 'Could not load %s' % path
return ret
else:
# NOTE(mrry):
return None
示例2: _load_library
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def _load_library(name, op_list=None):
"""Loads a .so file containing the specified operators.
Args:
name: The name of the .so file to load.
op_list: A list of names of operators that the library should have. If None
then the .so file's contents will not be verified.
Raises:
NameError if one of the required ops is missing.
"""
try:
filename = resource_loader.get_path_to_datafile(name)
library = load_library.load_op_library(filename)
for expected_op in (op_list or []):
for lib_op in library.OP_LIST.op:
if lib_op.name == expected_op:
break
else:
raise NameError('Could not find operator %s in dynamic library %s' %
(expected_op, name))
except errors.NotFoundError:
logging.warning('%s file could not be loaded.', name)
示例3: _load_library
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def _load_library(name, op_list=None):
"""Loads a .so file containing the specified operators.
Args:
name: The name of the .so file to load.
op_list: A list of names of operators that the library should have. If None
then the .so file's contents will not be verified.
Raises:
NameError if one of the required ops is missing.
NotFoundError if were not able to load .so file.
"""
filename = resource_loader.get_path_to_datafile(name)
library = load_library.load_op_library(filename)
for expected_op in (op_list or []):
for lib_op in library.OP_LIST.op:
if lib_op.name == expected_op:
break
else:
raise NameError(
'Could not find operator %s in dynamic library %s' %
(expected_op, name))
return library
示例4: Load
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def Load():
"""Load training ops library and return the loaded module."""
with _ops_lock:
global _training_ops
if not _training_ops:
ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE)
logging.info('data path: %s', ops_path)
_training_ops = loader.load_op_library(ops_path)
assert _training_ops, 'Could not load _training_ops.so'
return _training_ops
示例5: load_op_library
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def load_op_library(path):
"""Loads a contrib op library from the given path.
NOTE(mrry): On Windows, we currently assume that some contrib op
libraries are statically linked into the main TensorFlow Python
extension DLL - use dynamically linked ops if the .so is present.
Args:
path: An absolute path to a shared object file.
Returns:
A Python module containing the Python wrappers for Ops defined in the
plugin.
"""
if os.name == 'nt':
# To avoid makeing every user_ops aware of windows, re-write
# the file extension from .so to .dll.
path = re.sub(r'\.so$', '.dll', path)
# Currently we have only some user_ops as dlls on windows - don't try
# to load them if the dll is not found.
# TODO(mrry): Once we have all of them this check should be removed.
if not os.path.exists(path):
return None
path = resource_loader.get_path_to_datafile(path)
ret = load_library.load_op_library(path)
assert ret, 'Could not load %s' % path
return ret
示例6: zero_initializer
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def zero_initializer(ref, use_locking=True, name="zero_initializer"):
"""Initialize 'ref' with all zeros, ref tensor should be uninitialized.
If already initialized, you will get ValueError. This op is intended to
save memory during initialization.
Args:
ref: ref of the tensor need to be zero initialized.
name: optional name for this operation.
Returns:
ref that initialized.
Raises:
ValueError: If ref tensor is initialized.
"""
loader.load_op_library(
resource_loader.get_path_to_datafile("_variable_ops.so"))
return gen_variable_ops.zero_initializer(ref, name=name)
示例7: Load
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def Load():
"""Load training ops library and return the loaded module."""
with _ops_lock:
global _training_ops
if not _training_ops:
ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE)
logging.info('data path: %s', ops_path)
_training_ops = load_library.load_op_library(ops_path)
assert _training_ops, 'Could not load _training_ops.so'
return _training_ops
示例8: Load
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def Load():
"""Load the data ops library and return the loaded module."""
with _ops_lock:
global _data_ops
if not _data_ops:
ops_path = resource_loader.get_path_to_datafile(DATA_OPS_FILE)
logging.info('data path: %s', ops_path)
_data_ops = load_library.load_op_library(ops_path)
assert _data_ops, 'Could not load _data_ops.so'
return _data_ops
示例9: Load
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def Load():
"""Load the inference ops library and return the loaded module."""
with _ops_lock:
global _inference_ops
if not _inference_ops:
ops_path = resource_loader.get_path_to_datafile(INFERENCE_OPS_FILE)
logging.info('data path: %s', ops_path)
_inference_ops = load_library.load_op_library(ops_path)
assert _inference_ops, 'Could not load inference_ops.so'
return _inference_ops
示例10: load_library
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def load_library(name):
"""Loads a .so file containing the specified operators.
Args:
name: The name of the .so file to load.
Raises:
NotFoundError if were not able to load .so file.
"""
filename = resource_loader.get_path_to_datafile(name)
library = _load_library.load_op_library(filename)
return library
示例11: testCreatePage
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def testCreatePage(self):
num_clusters = 10
clusters = np.random.random((num_clusters, 12, 14))
template_src = resource_loader.get_path_to_datafile(
'kmeans_labeler_template.html')
template = mako_template.Template(open(template_src).read())
html = kmeans_labeler_request_handler.create_page(clusters, template)
self.assertEqual(len(re.findall('<img', html)), num_clusters)
self.assertEqual(len(re.findall('<select', html)), num_clusters)
示例12: do_GET
# 需要导入模块: from tensorflow.python.platform import resource_loader [as 别名]
# 或者: from tensorflow.python.platform.resource_loader import get_path_to_datafile [as 别名]
def do_GET(self):
template_path = resource_loader.get_path_to_datafile(
'kmeans_labeler_template.html')
template = mako_template.Template(open(template_path).read())
page = create_page(self.clusters, template)
self.send_response(http_client.OK)
self.send_header('Content-Type', 'text/html; charset=utf-8')
self.end_headers()
self.wfile.write(page)