在theano的对角线上创建具有特征值的方阵 [英] Creating square matrix with eigenvalues on the diagonal in theano
本文介绍了在theano的对角线上创建具有特征值的方阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用对角线上的特征值创建一个方阵:
I would like to create a square matrix with the eigenvalues on the diagonal:
eigen_values, eigen_vectors = theano.tensor.nlinalg.eig(covariance_matrix)
D = T.nlinalg.AllocDiag(eigen_values)
然而,theano 显然没有将我创建的 D 矩阵视为标准矩阵,因此我无法在后续计算中使用它.
However apparently theano does not treat the D matrix I created as a standard matrix, thus I cannot use it in the succeding computations.
theano.tensor.var.AsTensorError: ('Cannot convert <theano.tensor.nlinalg.AllocDiag object at 0x7face5708450> to TensorType', <class 'theano.tensor.nlinalg.AllocDiag'>)
推荐答案
您正在使用操作类,就好像它是一个操作函数一样.
You're using an operation class as if it were an operation function.
代替
D = T.nlinalg.AllocDiag(eigen_values)
试试
D = T.nlinalg.AllocDiag()(eigen_values)
或
D = T.nlinalg.alloc_diag(eigen_values)
这篇关于在theano的对角线上创建具有特征值的方阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文