0
我想用tf.nn.top k
更換argsort
(numpy
)
但它似乎tf.nn.top_k
不接受None
尺寸
這裏是我的代碼如何使用tf.nn.top_k與尺寸無
cond1 = tf.greater_equal(ws, min_size) # assume shape is (100,)
cond2 = tf.greater_equal(hs, min_size) # assume shape is (100,)
cond = cond1 & cond2 # shape is (100)
# cause I don't give x and y, so tf.where return index of True element
# but number of True is unknow now
keep = tf.where(cond) # so shape is (?,1)
keep = tf.reshape(keep, [-1]) # shape is (?,)
val = tf.gather(val, keep) # shpae is (?,)
argsort = tf.nn.top_k(val, val.get_shape()[0])
# ValueError: Cannot convert an unknown Dimension to a Tensor: ?