예제 #1
0
def test_jaccard_index():
    """
    Testing jaccard index function with computed
    tensor.
    """
    array_eye = np.identity((3))
    tensor_eye = np.zeros((3, 3, 3, 3))
    tensor_eye[:, :, 0:3, 0:3] = array_eye

    tensor_pred = np.zeros((3, 3, 3, 3))
    tensor_pred[:, 0:2, :, :] = array_eye
    num = np.array([6, 6, 6])
    denom = np.array([9, 9, 9]) + np.array([6, 6, 6]) - num

    get = num / denom
    expect = label.jaccard_index(tensor_eye, tensor_pred)
    assert assertTensorsEqual(get, expect)
예제 #2
0
def test_jaccard_index():
    """
    Testing jaccard index function with computed
    tensor.
    """
    array_eye = np.identity(3, dtype=np.float32)
    tensor_eye = np.zeros((3, 3, 3, 3), dtype=np.float32)
    tensor_eye[:, :, 0:3, 0:3] = array_eye
    tensor_eye = tf.convert_to_tensor(tensor_eye, dtype=tf.float32)

    tensor_pred = np.zeros((3, 3, 3, 3), dtype=np.float32)
    tensor_pred[:, 0:2, :, :] = array_eye
    tensor_pred = tf.convert_to_tensor(tensor_pred, dtype=tf.float32)

    num = np.array([6, 6, 6])
    denom = np.array([9, 9, 9]) + np.array([6, 6, 6]) - num

    get = num / denom
    expect = label.jaccard_index(tensor_eye, tensor_pred)
    assert is_equal_tf(get, expect)