码迷,mamicode.com
首页 > 其他好文 > 详细

解决 warning 显示 The linear_assignment function is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead

时间:2020-02-17 16:14:35      阅读:407      评论:0      收藏:0      [点我收藏+]

标签:content   sklearn   time   参考   val   scipy   代码   输出   stack   

 

用以下代码做实验

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. Use scipy.optimize.linear_sum_assignment instead

标签:content   sklearn   time   参考   val   scipy   代码   输出   stack   

原文地址:https://www.cnblogs.com/clemente/p/12321745.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!