I sorted a numpy array that I imported from another python file using the following commands:
import numpy as np
from test import c_A
cA=c_A.reshape(10000,1)
c=np.sort(cA,axis=0)[::-1]
I then get the following error:
ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array with array.copy().)
So, I copied the array, and adjusted my code accordingly:
cA=c_A.reshape(10000,1)
cA2 = torch.from_numpy(cA.copy())
c=np.sort(cA2,axis=0)[::-1]
The same error remains, and it says "torch" is not defined. I am using Nvidia Modulus, a DL framework that uses PyTorch.
The copied array method that I have been seeing online, which did not work. How to I go about this? The array should also remain as a dictionary of numpy array of szie [N,1]
Sorry, new to StackOverflow and don't know how to print out the question properly
source https://stackoverflow.com/questions/76385047/value-error-at-least-one-stride-in-the-given-numpy-array-is-negative-remains-a
Comments
Post a Comment