It would be nice to see your train_generator code for clarity, but it does not seem to be a torch DataLoader. In this case, you should probably convert your arrays to tensors manually. There are several ways to do so:
torch.from_numpy(numpy_array)- for numpy arrays;torch.as_tensor(list)- for common lists and tuples;torch.tensor(array)should also work but the above ways will avoid copying the data when possible.
'numpy.ndarray' object has no attribute 'numpy'.
Python - AttributeError: 'numpy.ndarray' object has no attribute 'to' - Stack Overflow
python - Unable to Create Polynomial Features for regression using numpy.plyfit -- AttributeError: 'numpy.ndarray' object has no attribute 'to_numpy' - Stack Overflow
AttributeError: 'numpy.ndarray' object has no attribute 'cpu'
Videos
if you need to flatten you can directly use flatten() on numpy.ndarray object
X = X.flatten()
Link to doc: https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flatten.html
DO NOT VOTE UP RESPONSE MAIN WORK DONE BY @wayne above:
Did you run print(type(X)) on X prior to that line that gave an error? Given you got an error of AttributeError: 'numpy.ndarray' object has no attribute 'to_numpy', X appears to already be numpy object. Also, I don't think the to_numpy comes from numpy. Pandas has one. Polars has one. This drops us in the end of the problem and so we cannot provide much help without more code upstream.
solution
reload data set.
df = pd.read_csv(file_name, header=0)
[str(i) for i in ([["CPU_frequency"]])]
code above resolves.
Hi,
I'm trying to create a numpy v-stack and creating 3 np.array's for it, by filling them with a loop:
I get the error: 'AttributeError: 'numpy.ndarray' object has no attribute 'np' . I think I'm using the wrong notation to append to the empty arrays:
neighbor_id = [id_ for id_ in range(1, n_obs) if id_ != user_id]
neighbor_id_arr = np.array(neighbor_id)
similarity = np.array([])
num_interactions = np.array([])
# get similarity and num_interactions
for id_ in neighbor_id:
similarity.np.append(np.dot(user_item.loc[user_id],user_item.loc[id_])) #The issue is here, I think
num_interactions.np.append(user_interactions.loc[id_])
c = numpy.vstack((neighbor_id_arr, similarity,num_interactions))
Thanks!
James
https://imgur.com/gallery/yAdAjdx
Hello,
Linked is the screenshot of the two error messages I keep recieving as well as the code leading up to it. I'm trying to run an uplift on a classification tree. Any help is appreciated, I am still fairly new to python. Thank you!!