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