Skip to content
Advertisement

Tag: numpy

A copy of image array not working in python

So I am working on Image Encryption and using a chaotic map for diffusion. So I have been trying to rearrange pixels of an image and made a rearranging code. It works fine for normal arrays but when I use it on image, without any rearranging, just a simple copy, the new array doesn’t make any image, in fact np.array_equal

Save a list of dictionaries with numpy arrays

I have a dataset composed as: Each element of the list is a dictionary containing a key “sample” and its value is a numpy array that has shape (2048,3) and the category is the class of that sample. The dataset len is 8000. I tried to save in JSON but it said it can’t serialize numpy arrays. What’s the best

Lambda function apply on dataframe DOES not contain str

I’m trying to add a condition .apply with a lambda function that pickups up a keyword but ignores values if they contain a specific word “total.” My dataframe: Here’s my code: current col output: Desired col output: Question What am I doing wrong? I have tried the ~ to make it a NOT but it’s still picking up rows and

Convert 16 bit hex value to FP16 in Python?

I’m trying to write a basic FP16 based calculator in python to help me debug some hardware. Can’t seem to find how to convert 16b hex values unto floating point values I can use in my code to do the math. I see lots of online references to numpy but I think the float16 constructor expects a string like float16(“1.2345”).

Advertisement