tf.py_func


在 faster  rcnn的tensorflow 实现中看到这个函数

rois,rpn_scores=tf.py_func(proposal_layer,[rpn_cls_prob,rpn_bbox_pred,self._im_info,self.mode,self._feat_stride,self._anchors,self._num_anchors],[tf.float32,tf.float32],name="proposal")

  tensorflow 官网上的解释

py_func(
    func,
    inp,
    Tout,
    stateful=True,
    name=None
)

将python 函数包装为一个tensorflow操作符
python 函数proposal_layer 以numpy 矩阵作为输入输出,使函数变为tensorflow图中的操作符
定义一个简单的sinh函数在tensorflow图中:
def my_func(x):
  # x will be a numpy array with the contents of the placeholder below
  return np.sinh(x)
inp = tf.placeholder(tf.float32)
y = tf.py_func(my_func, [inp], tf.float32)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM