- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 python 代码作为我不想触摸的黑匣子。该代码在 Ubuntu 12.04 下使用 Python 运行良好,但在将系统升级到 Ubuntu 16 后,我收到以下警告,该警告会中断代码运行。知道如何在不更改代码的情况下解决此问题吗?非常感谢。
File "/home/hammouc/.local/lib/python2.7/site-packages/scipy/sparse/base.py", line 849, in todense return np.asmatrix(self.toarray(order=order, out=out))
File "/home/hammouc/.local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py", line 71, in asmatrix return matrix(data, dtype=dtype, copy=False)
File "/home/hammouc/.local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py", line 123, in new PendingDeprecationWarning, stacklevel=2)
PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
最佳答案
与 import warnings
模块,可以控制警告的显示。
与 M
作为稀疏矩阵:
In [26]: warnings.filterwarnings('ignore', category=PendingDeprecationWarning)
In [27]: M.todense()
Out[27]:
matrix([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
In [28]: warnings.filterwarnings('default', category=PendingDeprecationWarning)
In [29]: M.todense()
/usr/local/lib/python3.6/dist-packages/numpy/matrixlib/defmatrix.py:71: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
return matrix(data, dtype=dtype, copy=False)
Out[29]:
matrix([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
ndarray
而不是
np.matrix
:
In [30]: M.toarray()
Out[30]:
array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
In [31]: M.A
Out[31]:
array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
ipython
setup 会忽略这些警告,所以我以前没见过。我得看看配置文件。
关于python-2.7 - 如何解决 PendingDeprecationWarning : the matrix subclass is not the recommended way to represent matrices 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56146811/
我有以下代码: dotp = np.dot(X[i], w) mult = -Y[i] * dotp lhs = Y[i] * X[i] rhs = logistic(mult) s += lhs *
下面是 MATLAB 的示例代码及其使用 Numpy 包的 eqv Python 代码。 MATLAB 代码运行良好,但 Python 代码出现问题: MATLAB/ Octave N=1200 YD
我应该编写一个执行以下操作的 for 循环:使用对应于最大n个奇异值的奇异向量(Ur等的列和VrT等的行)创建与原始图像(500 x 375)相同大小的新R,G和B矩阵 这是我目前的情况 from P
a = numpy.zeros((17770,5)) b = numpy.zeros((5,20000)) ma = numpy.matrix(a) mb = numpy.matrix(b) 即ma.
我正在尝试在树莓派 2 上使用 ROS 来运行 Matrice 100 的示例应用程序。我通过 USB-TTL 电缆将 Pi 连接到无人机上的 UART 端口。我将笔记本电脑连接到运行 DJI Ass
当我阅读 Knuth 的算法 X 以解决精确覆盖问题时,我想到了一个边缘情况,我想对其进行一些说明。 这是我的假设: 给定矩阵 A,算法 X 的“目标是选择行的子集,以便数字 1 在每一列中出现恰好一
对于我当前的 C++ 项目,我需要一个 2D vector ,其中包含 opencv:Mat 矩阵作为元素。我找到了一个类似的例子,它创建了一个双端队列的二维 vector ,效果非常好: vecto
我正在尝试实现Hartley&Zisserman的“多 View 几何”(第12.2节)中的(相对简单的)线性齐次(DLT)3D三角剖分方法,目的是将来实现其完整的“最佳算法”。现在,基于this q
我正在尝试提高我的一些代码的性能,它首先根据两个索引构造一个 4x4 矩阵,对该矩阵进行对角化,然后将每个矩阵的每个对角化的特征向量存储在 4 维数组中。目前,我只是依次遍历所有索引,然后将特征向量存
下午好。我想实现骨骼动画。我在 Blender 中创建了一个简单的示例并通过 collada 将其导出。 anim will be 因为这对我来说是全新的,所以我使用了 collada 1.4.1指定
我正在尝试为 Matrix 程序重载“+”运算符。这是我的代码,我觉得没问题。但是当我在我的主函数中添加两个矩阵时,什么也没有发生。有人可以帮忙吗?谢谢:) 顺便说一句: -程序编译并运行得很好,直到
我正在尝试编写一个高效的代码来执行循环移位,在我的数据处理过程中,我需要在大矩阵上多次实现它。 在我的第一次试验中,编译器抛出一些异常,似乎我可能正在尝试访问超出其大小的矩阵元素,但我不知道发生了什么
我想将提取的字符位图(.bmp 文件)输入某种可以用 C++ 处理的矩阵,然后输入人工神经网络,例如该网络将采用 72 个输入 - 每个输入都是 6 x 12 尺寸的二值化图片的一个像素。 例如:我有
在 n 层神经网络中计算梯度的最佳实现是什么? 权重层: 第一层权重: (n_inputs+1, n_units_layer)-matrix 隐藏层权重:(n_units_layer+1, n_uni
假设我在两张图片之间有很好的对应关系,并尝试恢复它们之间的相机运动。我可以为此使用 OpenCV 3 的新工具,如下所示: Mat E = findEssentialMat(imgpts1, img
我查看了 Matrix包和他们的 slides 。我试图理解dgCMatrix中的论点背后的直觉和含义是什么。类(class)。我明白了 @i给出矩阵中非零条目的从零开始的行索引。 @j给出矩阵中非零
我正在使用 Java + Jblas(首次使用)并尝试将两个矩阵相乘。一个是 163x4,另一个是 4x1 矩阵。我希望这种乘法的结果是一个 163x1 矩阵。但是使用: FloatMatrix a
以下问题: template void foo ( ){ Eigen::Matrix bar; if ( nDim == 3 ){ bar = generate_a_s
Python SymPy 矩阵 API 有一个 method来确定特征值。我想用 SymPy MutableDenseMatrix 做类似的事情。不幸的是,API不允许我这样做。 有什么办法吗? 最佳
我正在尝试解决多元回归问题。这是回归的附加代码。模型构建得很好,但是当我尝试检索摘要时,它给出以下错误 ValueError:矩阵未对齐 这是回溯: Traceback (most recent ca
我是一名优秀的程序员,十分优秀!