Category "numpy"

Eigenvectors in Julia vs Numpy

I'm currently working to diagonalize a 5000x5000 Hermitian matrix, and I find that when I use Julia's eigen function in the LinearAlgebra module, which produces

Ranking (not sorting) rows of 2D matrix lexicographically with numpy

I want to rank the rows of a 2D matrix lexicographically (in descending order) such that they are ranked: first by the left-most column, then second left-most c

Python: appending numpy.array to list python overwrites the previous elements

I'm trying to plot a stellar orbit in a given potential. First, I initialize the position and velocity, and derive the acceleration from the position according

How to guess the numerical Solution for Mathieu's Equation

am trying to predict the exact solution for the mathieu's equation y"+(lambda - 2qcos(2x))y = 0. I have been able to get five eigenvalues for the equation using

Movie Recommendation: Generate similar movies for all movies

I'm using scikit-learn TfldfVectorizer to produce the TF-IDF matrix #Import TfIdfVectorizer from scikit-learn from sklearn.feature_extraction.text import TfidfV

SymmetricalLogLocator not working with Contourf in Matplotlib

I have data in which values are ranging from small negative values to positive 1000. Since the minimum and maximum differ by large scales, I first set locator a

Finite difference method for 3D diffusion/heat equation

I'm trying to use finite differences to solve the diffusion equation in 3D. I think I'm having problems with the main loop. In particular the discrete equation

Install numpy for blender

I'm having a hard time exporting my blender model to glTF 2.0 format (for godot): (I still can export it to default .dae format) So, I tried installing numpy f

Efficiently get first N numbers that satisfy a condition in each row in a pytorch/numpy tensor

Given a tensor b, and I would like to extract N elements in each row that satisfy a specific condition. For example, suppose a is a matrix that indicates whethe

Transform array of arrays to a single array

I would like to expand a list of arrays into a single array, so for example: a = [array([1,2,3]), array([4,5,6]), array([7,8,9,])] To become: a = [array([1,2,3

No strict inequalities in cvxpy problem but still get the error "Strict inequalities are not allowed"

I was using the CVXPY library in Python, trying to solve a particular optimization problem. import cvxpy as cp import numpy as np from scipy.stats import norm

Find Top-K Smallest Values So Far in Data Stream

Let's say that I have a data stream where single data point is retrieved at a time: import numpy as np def next_data_point(): """ Mock a data stream. Da

output multiples row to csv python

New to python, so if this impossible sorry for time wasting.. I would like to get the full data set that is printed in console into to the csv when written out.

How to extract tensors to numpy arrays or lists from a larger pytorch tensor

I have a list of pytorch tensors as shown below: data = [[tensor([0, 0, 0]), tensor([1, 2, 3])], [tensor([0, 0, 0]), tensor([4, 5, 6])]] Now this is ju

Using tf.data.Dataset as training input to Keras model NOT working

I have a simple code, which DOES work, for training a Keras model in Tensorflow using numpy arrays as features and labels. If I then wrap these numpy arrays usi

AttributeError: 'float' object has no attribute 'dtype'

When I try to use a custom activation function in keras (2.2.5), I create a new activation function gelu. add it in activations.py : from . import backend as K

ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1,

I've got this error: ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has s

add negative seconds using numpy date time

I'm trying to add an array of time offsets (in seconds, which can be both positive and negative) to a constant timestamp using numpy. numpy version is 1.19.1, p

NumPy Interpolate Between Two 2-D Arrays At Various Timesteps

I have a pair of two-dimensional arrays from a gridded dataset (in GeoTIFF format), both with the exact same resolution and number of rows/columns. Suppose Arra

get maximum of absolute along axis

I have a couple of ndarrays with same shape, and I would like to get one array (of same shape) with the maximum of the absolute values for each element. So I de