This is Faster R-CNN implement in tensorflow.
The proposal_layer is implement by python    
i am curious about if gradient can pass by tf.py_func
the weights and biases are keep changing
so I think the gradient deliver back successful
Then I do a small test
import tensorflow as tf
import numpy as np
def addone(x):
    # print type(x)
    return x + 1
def pyfunc_test():
    # create data
    x_data = tf.placeholder(dtype=tf.float32, shape=[None])
    y_data = tf.placeholder(dtype=tf.float32, shape=[None])
    w = tf.Variable(tf.constant([0.5]))
    b = tf.Variable(tf.zeros([1]))
    y1 = tf.mul(w, x_data, name='y1')
    y2 = tf.py_func(addone, [y1], tf.float32)
    y = tf.add(y2, b)
    loss = tf.reduce_mean(tf.square(y - y_data))
    optimizer = tf.train.GradientDescentOptimizer(0.5)
    train = optimizer.minimize(loss)
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        for step in xrange(201):
            ran = np.random.rand(115).astype(np.float32)
            ans = ran * 1.5 + 3
            dic = {x_data: ran, y_data: ans}
            tt, yy, yy1= sess.run([train, y1, y2], feed_dict=dic)
            if step % 20 == 0:
                print 'step {}'.format(step)
                print '{}, {}'.format(w.eval(), b.eval())
        test = sess.run(y, feed_dict={x_data:[1]})
        print 'test = {}'.format(test)
if __name__ == '__main__':
    pyfunc_test()
Variable b keep changing, but w keep the value after initialize and never change    
sess.run(tf.gradients(loss, b), feed_dict=dic) get value
sess.run(tf.gradients(loss, w), feed_dict=dic) get {TypeError}Fetch argument None has invalid type <type 'NoneType'>
I know some questions suggest use tf.RegisterGradient and gradient_override_map
but I can't find these in the faster rcnn repo(link on top of post)
am I do something wrong or missing something so that w is freeze