解决 warning 显示 The linear_assignment function is deprecated in 0.21 and will be removed from 0.23. Us

Posted clemente

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决 warning 显示 The linear_assignment function is deprecated in 0.21 and will be removed from 0.23. Us相关的知识,希望对你有一定的参考价值。

 

用以下代码做实验

import time
import cv2 as cv
import glob
import argparse
import sys
import numpy as np
import os.path
from collections import deque
from sklearn.utils.linear_assignment_ import linear_assignment

.....
.....
for i in range(100):
    indices = linear_assignment(cost_matrix)

 

 

输出显示

DeprecationWarning: The linear_assignment function is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead.

 

经过查阅相关资料,代码部分替换为下面形式即可解决


不同之处在于返回格式: linear_assignment() 返回一个 numpy 数组和linear_sum_assignment() 返回 一个 numpy 数组的元组。通过转换 linear_sum_assignment()输出为array并转置它,可以获得相同的输出。

import time
import cv2 as cv
import glob
import argparse
import sys
import numpy as np
import os.path
from collections import deque
from scipy.optimize import linear_sum_assignment # 代替上面 linear_assignment

indices = linear_sum_assignment(cost_matrix)
indices = np.asarray(indices)
indices = np.transpose(indices)

 

 

参考资料


 

https://stackoverflow.com/questions/57369848/how-do-i-resolve-use-scipy-optimize-linear-sum-assignment-instead

以上是关于解决 warning 显示 The linear_assignment function is deprecated in 0.21 and will be removed from 0.23. Us的主要内容,如果未能解决你的问题,请参考以下文章

[Mathematics][Linear Algebra] The Rotation of the Base Vector in 3 dimensions

cuda环境下安装opencv出现nvcc warning : The 'compute_11'

WARNING: The TCP backlog setting of 511.解决

caffe编译nvcc warning:The 'compute_20', 'sm_20'

warning C4819 解决方案 warning C4819: The file contains a character that cannot be represented in the cu

vscode 提示Set the 'experimentalDecorators' option to remove this warning. [1219]