在mask_rcnn常用的函数
1 Tensorflow中 tf.cast()的用法:
2 tf.gather 实例
3 tf.boolean_mask
1:
https://blog.csdn.net/dss875914213/article/details/86558407
tf.cast()
cast(
x,
dtype,
name=None
)12345
将x的数据格式转化成dtype数据类型.例如,原来x的数据格式是bool,
那么将其转化成float以后,就能够将其转化成0和1的序列。反之也可以
%%python2
import sys
import tensorflow as tf
print(sys.version)
a = tf.Variable([1.0,1.3,2.1,3.41,4.51])
b = tf.cast(a>3,dtype=tf.bool)
c = tf.cast(a>3,dtype=tf.int8)
e = tf.cast(a<2,dtype=tf.float32)
d = tf.cast(a,dtype=tf.int8)
sess = tf.Session()
sess.run(tf.initialize_all_variables())
print(sess.run(b))
print(sess.run(c))
print(sess.run(e))
print(sess.run(d))1234567891011121314151617
[False False False True True]
[0 0 0 1 1]
[1. 1. 0. 0. 0.]
[1 1 2 3 4]1234
https://blog.csdn.net/guotong1988/article/details/53172882
mport tensorflow as tf
temp = tf.range(0,10)*10 + tf.constant(1,shape=[10])
temp2 = tf.gather(temp,[1,5,9])
with tf.Session() as sess:
print sess.run(temp)
print sess.run(temp2)
输出
[ 1 11 21 31 41 51 61 71 81 91]
[11 51 91]
3:
https://blog.csdn.net/m0_37393514/article/details/81674489