• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tensorflow.load_op_library函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tensorflow.load_op_library函数的典型用法代码示例。如果您正苦于以下问题:Python load_op_library函数的具体用法?Python load_op_library怎么用?Python load_op_library使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load_op_library函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: load_custom_op

  def load_custom_op(self, custom_op_paths):

    custom_op_path_list = custom_op_paths.split(",")

    for custom_op_path in custom_op_path_list:
      if os.path.isdir(custom_op_path):
        for filename in os.listdir(custom_op_path):
          if filename.endswith(".so"):

            op_filepath = os.path.join(custom_op_path, filename)
            logger.info("Load the so file from: {}".format(op_filepath))
            tf.load_op_library(op_filepath)

      else:
        logger.error("The path does not exist: {}".format(custom_op_path))
开发者ID:tobegit3hub,项目名称:simple_tensorflow_serving,代码行数:15,代码来源:tensorflow_inference_service.py


示例2: build_plasma_tensorflow_op

def build_plasma_tensorflow_op():
    global tf_plasma_op
    try:
        import tensorflow as tf
        print("TensorFlow version: " + tf.__version__)
    except ImportError:
        pass
    else:
        print("Compiling Plasma TensorFlow Op...")
        dir_path = os.path.dirname(os.path.realpath(__file__))
        cc_path = os.path.join(dir_path, "tensorflow", "plasma_op.cc")
        so_path = os.path.join(dir_path, "tensorflow", "plasma_op.so")
        tf_cflags = tf.sysconfig.get_compile_flags()
        if sys.platform == 'darwin':
            tf_cflags = ["-undefined", "dynamic_lookup"] + tf_cflags
        cmd = ["g++", "-std=c++11", "-g", "-shared", cc_path,
               "-o", so_path, "-DNDEBUG", "-I" + pa.get_include()]
        cmd += ["-L" + dir for dir in pa.get_library_dirs()]
        cmd += ["-lplasma", "-larrow_python", "-larrow", "-fPIC"]
        cmd += tf_cflags
        cmd += tf.sysconfig.get_link_flags()
        cmd += ["-O2"]
        if tf.test.is_built_with_cuda():
            cmd += ["-DGOOGLE_CUDA"]
        print("Running command " + str(cmd))
        subprocess.check_call(cmd)
        tf_plasma_op = tf.load_op_library(TF_PLASMA_OP_PATH)
开发者ID:dremio,项目名称:arrow,代码行数:27,代码来源:plasma.py


示例3: __init__

    def __init__(self, run_dir):

        r = 10.
        game_params = {
            'r': r,
            'dt': 1./9,
            'host_speed': 10/3.6,
            'target_speed': 5.,
            'num_of_targets': 5,
        }

        self._connect(game_params)

        self._train_params()

        self.fig = plt.figure()
        self.ax = plt.subplot2grid((2, 2), (0, 0), colspan=2, rowspan=2)

        self.run_dir = run_dir

        subprocess.Popen(self.run_dir + "./simulator")

        self.pipe_module = tf.load_op_library(self.run_dir + 'pipe.so')

        plt.ion()
        plt.show()
开发者ID:bentzinir,项目名称:Buffe,代码行数:26,代码来源:environment.py


示例4: do_test

 def do_test(self):
   test = []
   test = self.d.gpu_test
   assemble_module = tf.load_op_library('./../assemble_boxes_gpu.so')
   with tf.Session():
     with tf.device("/gpu:0"):
         if len(test) == 0:
             test = [1,1,3,3,1,15]
             test.extend([4,1,3,3,2,15])
             test.extend([7,1,3,3,3,15])
             test.extend([1,4,3,3,4,15])
             test.extend([4,4,3,3,5,15])
             test.extend([7,4,3,3,6,15])
             test.extend([1,7,3,3,7,15])
             test.extend([4,7,3,3,8,15])
             test.extend([7,7,3,3,9,15])
             test.extend([6,9, 16])
         test = tf.constant(test, dtype=tf.uint16)
         #test = tf.cast(test, dtype=tf.int32)
     print test
     #result = assemble_module.assemble_boxes_op(test)
     result = assemble_module.assemble_boxes_cpu(test)
     self.r = result.eval()
     s = []
     for i in range(len(self.r) // 6):
         print(self.r[ i * 6: i * 6 + 6])
         g = self.r[i * 6 + 4]
         if not g in s:
             s.append(g)
     print "simple list:" , s
开发者ID:radiodee1,项目名称:awesome-tag,代码行数:30,代码来源:atag_boxes_gpu_test.py


示例5: _load_dynamiclib_module

    def _load_dynamiclib_module():
        if Operator._dynamiclibop_module is None:
            libname = 'dynamiclibop.so.' + version
            dynamiclibop_path = os.path.join(cache_directory, libname)
            if not os.path.exists(dynamiclibop_path):
                # build the library if it does not exist already
                tf_include = tf.sysconfig.get_include()
                # resolve the directory of this file
                this_file_path = os.path.abspath(__file__)
                this_directory = os.path.split(this_file_path)[0]
                try:
                    if cuda_enabled:
                        tf.logging.log(tf.logging.INFO, '*** building dynamiclibop for GPU')
                        subprocess.check_output(['g++', '-fPIC', '-Wall', '-shared',
                                         '-std=c++11', '-O2', '-Wextra', '-DGOOGLE_CUDA=1',
                                         '-o', dynamiclibop_path,
                                         this_directory + '/dynamiclibop.cc',
                                         '-isystem', cuda_directory + '/include',
                                         '-isystem', tf_include],
                                          stderr=subprocess.STDOUT,
                                          universal_newlines=True)
                    else:
                        tf.logging.log(tf.logging.INFO, '*** building dynamiclibop for CPU')
                        subprocess.check_output(['g++', '-fPIC', '-Wall', '-shared',
                                         '-std=c++11', '-O2', '-Wextra',
                                         '-o', dynamiclibop_path,
                                         this_directory + '/dynamiclibop.cc',
                                         '-isystem', tf_include],
                                          stderr=subprocess.STDOUT,
                                          universal_newlines=True)
                except subprocess.CalledProcessError as exception:
                    tf.logging.log(tf.logging.ERROR, 'g++ error: ' + exception.output)
                    raise

            Operator._dynamiclibop_module = tf.load_op_library(dynamiclibop_path)
开发者ID:kbrems,项目名称:opveclib,代码行数:35,代码来源:operator.py


示例6: f_segm_match

def f_segm_match(iou, s_gt):
    """Matching between segmentation output and groundtruth.

    Args:
        y_out: [B, T, H, W], output segmentations
        y_gt: [B, T, H, W], groundtruth segmentations
        s_gt: [B, T], groudtruth score sequence
    """
    global hungarian_module
    if hungarian_module is None:
        hungarian_module = tf.load_op_library('hungarian.so')
        log.info('Loaded library "hungarian.so"')
        pass
        
    # Mask X, [B, M] => [B, 1, M]
    mask_x = tf.expand_dims(s_gt, dim=1)
    # Mask Y, [B, M] => [B, N, 1]
    mask_y = tf.expand_dims(s_gt, dim=2)
    iou_mask = iou * mask_x * mask_y

    # Keep certain precision so that we can get optimal matching within
    # reasonable time.
    eps = 1e-5
    precision = 1e6
    iou_mask = tf.round(iou_mask * precision) / precision
    match_eps = hungarian_module.hungarian(iou_mask + eps)[0]

    # [1, N, 1, 1]
    s_gt_shape = tf.shape(s_gt)
    num_segm_out = s_gt_shape[1]
    num_segm_out_mul = tf.pack([1, num_segm_out, 1])
    # Mask the graph algorithm output.
    match = match_eps * mask_x * mask_y

    return match
开发者ID:ziyu-zhang,项目名称:ins-seg-public,代码行数:35,代码来源:ris_model_base.py


示例7: testBasic

  def testBasic(self):
    library_filename = os.path.join(tf.resource_loader.get_data_files_path(),
                                    'duplicate_op.so')
    duplicate = tf.load_op_library(library_filename)

    self.assertEqual(len(duplicate.OP_LIST.op), 0)

    with self.test_session():
      self.assertEqual(tf.add(1, 41).eval(), 42)
开发者ID:1000sprites,项目名称:tensorflow,代码行数:9,代码来源:duplicate_op_test.py


示例8: testBasic

    def testBasic(self):
        library_filename = os.path.join(tf.resource_loader.get_data_files_path(), "ackermann_op.so")
        ackermann = tf.load_op_library(library_filename)

        self.assertEqual(len(ackermann.OP_LIST.op), 1)
        self.assertEqual(ackermann.OP_LIST.op[0].name, "Ackermann")

        with self.test_session():
            self.assertEqual(ackermann.ackermann().eval(), "A(m, 0) == A(m-1, 1)")
开发者ID:bgyss,项目名称:tensorflow,代码行数:9,代码来源:ackermann_test.py


示例9: Load

def Load():
  """Load the TopN ops library and return the loaded module."""
  with _ops_lock:
    global _topn_ops
    if not _topn_ops:
      ops_path = tf.resource_loader.get_path_to_datafile(TOPN_OPS_FILE)
      tf.logging.info('data path: %s', ops_path)
      _topn_ops = tf.load_op_library(ops_path)

      assert _topn_ops, 'Could not load topn_ops.so'
  return _topn_ops
开发者ID:821760408-sp,项目名称:tensorflow,代码行数:11,代码来源:topn_ops.py


示例10: Load

def Load(library_base_dir=""):
    """Load the quantized ops library and return the loaded module."""
    with _ops_lock:
        global _quantized_ops
        if not _quantized_ops:
            data_files_path = os.path.join(library_base_dir, tf.resource_loader.get_data_files_path())
            tf.logging.info("q:data path: %s", data_files_path)
            _quantized_ops = tf.load_op_library(os.path.join(data_files_path, QUANTIZED_OPS_FILE))

            assert _quantized_ops, "Could not load quantized_ops.so"
    return _quantized_ops
开发者ID:RuhiSharma,项目名称:tensorflow,代码行数:11,代码来源:load_quantized_ops_so.py


示例11: Load

def Load():
  """Load training ops library and return the loaded module."""
  with _ops_lock:
    global _training_ops
    if not _training_ops:
      data_files_path = tf.resource_loader.get_data_files_path()
      tf.logging.info('data path: %s', data_files_path)
      _training_ops = tf.load_op_library(os.path.join(
          data_files_path, TRAINING_OPS_FILE))

      assert _training_ops, 'Could not load _training_ops.so'
  return _training_ops
开发者ID:6779660,项目名称:tensorflow,代码行数:12,代码来源:training_ops.py


示例12: Load

def Load():
  """Load the inference ops library and return the loaded module."""
  with _ops_lock:
    global _inference_ops
    if not _inference_ops:
      data_files_path = tf.resource_loader.get_data_files_path()
      tf.logging.info('data path: %s', data_files_path)
      _inference_ops = tf.load_op_library(os.path.join(
          data_files_path, INFERENCE_OPS_FILE))

      assert _inference_ops, 'Could not load inference_ops.so'
  return _inference_ops
开发者ID:6779660,项目名称:tensorflow,代码行数:12,代码来源:inference_ops.py


示例13: Load

def Load(library_base_dir=''):
  """Load the quantized ops library and return the loaded module."""
  with _kernels_lock:
    global _quantized_kernels
    if not _quantized_kernels:
      data_files_path = os.path.join(library_base_dir,
                                     tf.resource_loader.get_data_files_path())
      tf.logging.info('data path: %s', data_files_path)
      _quantized_kernels = tf.load_op_library(os.path.join(
          data_files_path, QUANTIZED_KERNELS_FILE))

      assert _quantized_kernels, 'Could not load _quantized_kernels.so'
  return _quantized_kernels
开发者ID:0ruben,项目名称:tensorflow,代码行数:13,代码来源:load_quantized_kernels_so.py


示例14: load

def load(library_path):
    fuzzy_module = tf.load_op_library(library_path)

    @ops.RegisterGradient("FuzzyCTCLoss")
    def _FuzzyCTCLossGrad(op, grad_loss, _):
        grad_without_gradient = array_ops.prevent_gradient(
            op.outputs[1], message="Currently there is no way to take the second "
                                   " derivative of ctc_loss due to the fused implementation's interaction "
                                   " with tf.gradients()")
        return [_BroadcastMul(tf.expand_dims(grad_loss, -1), grad_without_gradient), None, None, None]

    def fuzzy_ctc_greedy_decoder(inputs, sequence_length):
        outputs = fuzzy_module.fuzzy_ctc_greedy_decoder(inputs, sequence_length)
        (decoded_ix, decoded_val, decoded_shape, log_probabilities) = outputs
        return ([sparse_tensor.SparseTensor(decoded_ix, decoded_val, decoded_shape)],
                log_probabilities)

    return {"module": fuzzy_module, "decoder_op": fuzzy_ctc_greedy_decoder}
开发者ID:AIRob,项目名称:calamari,代码行数:18,代码来源:tensorflow_fuzzy_ctc_loader.py


示例15: roi_pooling

import tensorflow as tf
from tensorflow.python.framework import ops
import os

module_path = os.path.realpath(__file__)
module_dir = os.path.dirname(module_path)
lib_path = os.path.join(module_dir, 'roi_pooling.so')
roi_pooling_module = tf.load_op_library(lib_path)

def roi_pooling(input, rois, pool_height, pool_width):
    """
      returns a tensorflow operation for computing the Region of Interest Pooling
    
      @arg input: feature maps on which to perform the pooling operation
      @arg rois: list of regions of interest in the format (feature map index, upper left, bottom right)
      @arg pool_width: size of the pooling sections
    """
    # TODO(maciek): ops scope
    out = roi_pooling_module.roi_pooling(input, rois, pool_height=pool_height, pool_width=pool_width)
    output, argmax_output = out[0], out[1]
    return output


@ops.RegisterGradient("RoiPooling")
def _RoiPoolingGrad(op, *grads):
    orig_inputs = op.inputs[0]
    orig_rois = op.inputs[1]
    orig_output = op.outputs[0]
    orig_argmax_output = op.outputs[1]

    orig_output_grad = grads[0]
开发者ID:DKfromsd,项目名称:seq2seq-chatbot,代码行数:31,代码来源:roi_pooling_ops.py


示例16: print

import tensorflow as tf
import numpy as np
import scipy.io

test_mat = {}
test_matrix = np.random.rand(2, 3, 4)
test_mat['test'] = test_matrix
scipy.io.savemat('test.mat', test_mat)
print('Generated matrix:')
print(test_matrix)

parse_mat_module = tf.load_op_library('parse_mat.so')
test_parse_tensor = parse_mat_module.parse_mat('test.mat', 'test', dtype=tf.float64)
sess = tf.InteractiveSession()
test_parse = sess.run(test_parse_tensor)
print('Parsed matrix:')
print(test_parse)
开发者ID:kwanz,项目名称:tf-mat-parser,代码行数:17,代码来源:test.py


示例17: query_ball_point

import tensorflow as tf
from tensorflow.python.framework import ops
import sys
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
grouping_module=tf.load_op_library(os.path.join(BASE_DIR, 'tf_grouping_so.so'))
def query_ball_point(radius, nsample, xyz1, xyz2):
    '''
    Input:
        radius: float32, ball search radius
        nsample: int32, number of points selected in each ball region
        xyz1: (batch_size, ndataset, 3) float32 array, input points
        xyz2: (batch_size, npoint, 3) float32 array, query points
    Output:
        idx: (batch_size, npoint, nsample) int32 array, indices to input points
        pts_cnt: (batch_size, npoint) int32 array, number of unique points in each local region
    '''
    #return grouping_module.query_ball_point(radius, nsample, xyz1, xyz2)
    return grouping_module.query_ball_point(xyz1, xyz2, radius, nsample)
ops.NoGradient('QueryBallPoint')
def select_top_k(k, dist):
    '''
    Input:
        k: int32, number of k SMALLEST elements selected
        dist: (b,m,n) float32 array, distance matrix, m query points, n dataset points
    Output:
        idx: (b,m,n) int32 array, first k in n are indices to the top k
        dist_out: (b,m,n) float32 array, first k in n are the top k
    '''
    return grouping_module.selection_sort(dist, k)
开发者ID:joosm,项目名称:pointnet2,代码行数:31,代码来源:tf_grouping.py


示例18: _zero_out_grad

import tensorflow as tf
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import sparse_ops

zero_out_module = tf.load_op_library('./zero_out.so')
zero_out = zero_out_module.zero_out
zero_out_float = zero_out_module.zero_out_float

@ops.RegisterGradient("ZeroOut")
def _zero_out_grad(op, grad):
    """The gradients for `zero_out`.

  Args:
    op: The `zero_out` `Operation` that we are differentiating, which we can use
      to find the inputs and outputs of the original op.
    grad: Gradient with respect to the output of the `zero_out` op.

  Returns:
    Gradients with respect to the input of `zero_out`.
  """
    to_zero = op.inputs[0]
    shape = array_ops.shape(to_zero)
    index = array_ops.zeros_like(shape)
    first_grad = array_ops.reshape(grad, [-1])[0]
    to_zero_grad = sparse_ops.sparse_to_dense([index], shape, first_grad, 0)
    return [to_zero_grad]  # List of one Tensor, since we have one input

@ops.RegisterGradient("ZeroOutFloat")
def _zero_out_float_grad(op, grad):
    """The gradients for `zero_out_float`.
开发者ID:niurouli,项目名称:SWEM,代码行数:31,代码来源:py_zero_out.py


示例19:

import tensorflow as tf
import os.path as osp

filename = osp.join(osp.dirname(__file__), 'psalign_pooling.so')
_psalign_pooling_module = tf.load_op_library(filename)
psalign_pool = _psalign_pooling_module.ps_align_pool
psalign_pool_grad = _psalign_pooling_module.ps_align_pool_grad
开发者ID:Zumbalamambo,项目名称:light_head_rcnn,代码行数:7,代码来源:psalign_pooling_op.py


示例20:

import tensorflow as tf
import os.path as osp

filename = osp.join(osp.dirname(__file__), 'psroi_pooling.so')
_psroi_pooling_module = tf.load_op_library(filename)
psroi_pool = _psroi_pooling_module.psroi_pool
psroi_pool_grad = _psroi_pooling_module.psroi_pool_grad
开发者ID:Bruslan,项目名称:MV3D-1,代码行数:7,代码来源:psroi_pooling_op.py



注:本文中的tensorflow.load_op_library函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tensorflow.local_variables函数代码示例发布时间:2022-05-27
下一篇:
Python tensorflow.linspace函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap