本文整理汇总了Python中tensorflow.python.framework.ops.py方法的典型用法代码示例。如果您正苦于以下问题:Python ops.py方法的具体用法?Python ops.py怎么用?Python ops.py使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.framework.ops
的用法示例。
在下文中一共展示了ops.py方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: identity
# 需要导入模块: from tensorflow.python.framework import ops [as 别名]
# 或者: from tensorflow.python.framework.ops import py [as 别名]
def identity(labeled_tensor, name=None):
"""The identity op.
See tf.identity.
Args:
labeled_tensor: The input tensor.
name: Optional op name.
Returns:
The tensor.
"""
with ops.name_scope(name, 'lt_identity', [labeled_tensor]) as scope:
labeled_tensor = convert_to_labeled_tensor(labeled_tensor)
return LabeledTensor(
array_ops.identity(
labeled_tensor.tensor, name=scope),
labeled_tensor.axes)
# We don't call this slice because that shadows a built-in. Instead, we alias
# this to lt.slice in __init__.py.
示例2: identity
# 需要导入模块: from tensorflow.python.framework import ops [as 别名]
# 或者: from tensorflow.python.framework.ops import py [as 别名]
def identity(labeled_tensor, name=None):
"""The identity op.
See tf.identity.
Args:
labeled_tensor: The input tensor.
name: Optional op name.
Returns:
The tensor.
"""
with ops.name_scope(name, 'lt_identity', [labeled_tensor]) as scope:
labeled_tensor = convert_to_labeled_tensor(labeled_tensor)
return LabeledTensor(
array_ops.identity(labeled_tensor.tensor, name=scope),
labeled_tensor.axes)
# We don't call this slice because that shadows a built-in. Instead, we alias
# this to lt.slice in __init__.py.
示例3: _replace_grad
# 需要导入模块: from tensorflow.python.framework import ops [as 别名]
# 或者: from tensorflow.python.framework.ops import py [as 别名]
def _replace_grad(g, op):
# ref: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/framework/ops.py
# tf.Graph._gradient_override_map
try:
op_def = op._op_def
node_def = op._node_def
if op_def is not None:
mapped_op_type = g._gradient_override_map[op_def.name]
node_def.attr["_gradient_op_type"].CopyFrom(
attr_value_pb2.AttrValue(s=compat.as_bytes(mapped_op_type)))
except KeyError:
pass
示例4: load_op_module
# 需要导入模块: from tensorflow.python.framework import ops [as 别名]
# 或者: from tensorflow.python.framework.ops import py [as 别名]
def load_op_module(lib_name):
"""
Load TensorFlow operator library.
"""
# use absolute path so that ops.py can be called from other directory
lib_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'build/lib{0}.so'.format(lib_name))
# duplicate library with a random new name so that
# a running program will not be interrupted when the original library is updated
lib_copy_path = '/tmp/lib{0}_{1}.so'.format(str(uuid.uuid4())[:8], LIB_NAME)
shutil.copyfile(lib_path, lib_copy_path)
oplib = tf.load_op_library(lib_copy_path)
#print(_)
return oplib
示例5: load_op_module
# 需要导入模块: from tensorflow.python.framework import ops [as 别名]
# 或者: from tensorflow.python.framework.ops import py [as 别名]
def load_op_module(lib_name):
"""
Load TensorFlow operator library.
"""
# use absolute path so that ops.py can be called from other directory
if FLAGS.run_on_cloud:
lib_path = os.path.join(FLAGS.data_dir, 'lib{0}.so'.format(lib_name))
tf.gfile.Copy(lib_path, './' + 'lib{0}.so'.format(lib_name), overwrite=True)
return tf.load_op_library('./' + 'lib{0}.so'.format(lib_name))