Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classification using error #47

Open
doheon114 opened this issue Oct 10, 2024 · 1 comment
Open

Classification using error #47

doheon114 opened this issue Oct 10, 2024 · 1 comment

Comments

@doheon114
Copy link

Thanks for good service. I found some error trying using this code.

Traceback (most recent call last):
File "/home/work/.LVEF/ecg-lvef-prediction/NeurIPS2023-One-Fits-All/Classification/src/main.py", line 309, in
main(config)
File "/home/work/.LVEF/ecg-lvef-prediction/NeurIPS2023-One-Fits-All/Classification/src/main.py", line 237, in main
aggr_metrics_val, best_metrics, best_value = validate(val_evaluator, tensorboard_writer, config, best_metrics,
File "/home/work/.LVEF/ecg-lvef-prediction/NeurIPS2023-One-Fits-All/Classification/src/running.py", line 222, in validate
np.savez(pred_filepath, **per_batch)
File "<array_function internals>", line 200, in savez
File "/home/work/.local/lib/python3.10/site-packages/numpy/lib/npyio.py", line 615, in savez
_savez(file, args, kwds, False)
File "/home/work/.local/lib/python3.10/site-packages/numpy/lib/npyio.py", line 716, in _savez
val = np.asanyarray(val)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (4,) + inhomogeneous part.

It's the result of run 'bash .scripts/Heartbeat.sh'
As the error code states, I cannot proceed to the next step after epoch 0, because I have error on validation after training epoch 0. Could anyone help us?

@soheilkooklan
Copy link

Hi there!

It looks like the error you're encountering happens when trying to save arrays using np.savez during validation. Specifically, the issue is caused by trying to save a variety with inconsistent dimensions (an inhomogeneous shape).

The detected shape (4,) + inhomogeneous part suggests that one or more elements of the array are sequences (e.g., lists or arrays) that don't have the same length or shape, making it difficult for NumPy to handle them as a single array.

To fix this, you might want to ensure that the data you're passing into np.savez has a consistent shape. You can either:

1- Check the data passed in per_batch and ensure each item has the exact dimensions.
2- If the data is inherently different in shape (e.g., a list of varying-length arrays), you could either pad or truncate the arrays to match dimensions or save each element separately rather than combining them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants