eigenvalue

tensorflow.linalg.eig throwing error UnboundLocalError: local variable 'out_dtype' referenced before assignment

tensorflow.linalg.eig throwing error UnboundLocalError: local variable 'out_dtype' referenced before assignment Question: I have below code import tensorflow as tf X_tf = tf.Variable([[25, 2, 9], [5, 26, -5], [3, 7, -1]]) lambdas_X_tf, V_X_tf = tf.linalg.eig(X_tf) when I execute it I get below error File "C:Usersu1.condaenvspy39libsite-packagestensorflowpythonutiltraceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "C:Usersu1.condaenvspy39libsite-packagestensorflowpythonopslinalg_ops.py", line …

Total answers: 1

numpy computed eigenvalues incorrect?

numpy computed eigenvalues incorrect? Question: I am trying to get the eigenvalues of a positive semi-definite matrix in Python using numpy. All eigenvalues should be non-negative and real. The minimum eigenvalue should be zero. Sometimes, numpy.eig returns complex values as eigenvalues even when they’re supposed to be real (although the complex numbers have 0j in …

Total answers: 1

Python Numpy TypeError: ufunc 'isfinite' not supported for the input types

Python Numpy TypeError: ufunc 'isfinite' not supported for the input types Question: Here’s my code: def topK(dataMat,sensitivity): meanVals = np.mean(dataMat, axis=0) meanRemoved = dataMat – meanVals covMat = np.cov(meanRemoved, rowvar=0) eigVals,eigVects = np.linalg.eig(np.mat(covMat)) I get the error in the title on the last line above. I suspect it has something to do with the datatype, …

Total answers: 2

Python numpy compute first eigenvalue and eigenvector

Python numpy compute first eigenvalue and eigenvector Question: I was wondering if there is a Python package, numpy or otherwise, that has a function that computes the first eigenvalue and eigenvector of a small matrix, say 2×2. I could use the linalg package in numpy as follows. import numpy as np def whatever(): A = …

Total answers: 3

whats the fastest way to find eigenvalues/vectors in python?

whats the fastest way to find eigenvalues/vectors in python? Question: Currently im using numpy which does the job. But, as i’m dealing with matrices with several thousands of rows/columns and later this figure will go up to tens of thousands, i was wondering if there was a package in existence that can perform this kind …

Total answers: 2

Numpy transpose multiplication problem

Numpy transpose multiplication problem Question: I tried to find the eigenvalues of a matrix multiplied by its transpose but I couldn’t do it using numpy. testmatrix = numpy.array([[1,2],[3,4],[5,6],[7,8]]) prod = testmatrix * testmatrix.T print eig(prod) I expected to get the following result for the product: 5 11 17 23 11 25 39 53 17 39 …

Total answers: 3