AttributeError:'RaggedTensor'对象没有属性'unsqueeze'

时间:2020-06-09 00:37:20

标签: tensorflow tensorflow2.0 tensor torch ragged

试图找到相交set_1和set_2,但不确定应使用哪种类型

def find_intersection(set_1, set_2):
    """
    Find the intersection of every box combination between two sets of boxes that are in boundary coordinates.

    :param set_1: set 1, a tensor of dimensions (n1, 4)
    :param set_2: set 2, a tensor of dimensions (n2, 4)
    :return: intersection of each of the boxes in set 1 with respect to each of the boxes in set 2, a tensor of dimensions (n1, n2)
    """

    print('set_1->',set_1)
    print('set_2->',set_2)
    #tensorflow auto-broadcasts singleton dimensions
    lower_bounds = tf.argmax(set_1[:, :2].unsqueeze(1), set_2[:, :2].unsqueeze(0))  # (n1, n2, 2)
    upper_bounds = tf.argmin(set_1[:, 2:].unsqueeze(1), set_2[:, 2:].unsqueeze(0))  # (n1, n2, 2)
    intersection_dims = tf.clamp(upper_bounds - lower_bounds, min=0)  # (n1, n2, 2)
    return intersection_dims[:, :, 0] * intersection_dims[:, :, 1]  # (n1, n2)

set_1 = tf.RaggedTensor [[52,86,470,419],[157,43,288,166]]

文件“ /home/jake/Gits/ssd_tensorflow/model.py”,第405行,正在调用 重叠= find_jaccard_overlap(boxes [i],self.prior_xy)文件“ /home/jake/Gits/ssd_tensorflow/ssd_utils.py”,第131行,在 find_jaccard_overlap 交集= find_intersection(set_1,set_2)#(n1,n2)文件“ /home/jake/Gits/ssd_tensorflow/ssd_utils.py”,第115行,在 find_intersection lower_bounds = tf.argmax(set_1 [:,:2] .unsqueeze(1),set_2 [:,:2] .unsqueeze(0))#(n1,n2,2)AttributeError:'RaggedTensor'对象 没有属性“取消压缩”

0 个答案:

没有答案