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

ValueError: Found array with 0 sample(s) (shape=(0, 3)) while a minimum of 1 is required by check_pairwise_arrays. #4

Closed
laomeng0703 opened this issue Sep 25, 2023 · 2 comments

Comments

@laomeng0703
Copy link

laomeng0703 commented Sep 25, 2023

感谢您的工作!
当我想训练train_SRGCAE_Local.py时,出现以下错误:

Traceback (most recent call last):
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/train_SRGCAE_Local.py", line 150, in <module>
    train_model(args)
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/train_SRGCAE_Local.py", line 51, in train_model
    am_set_t1 = construct_affinity_matrix(img_t1, objects, args.band_width_t1)
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/aux_func/graph_func.py", line 26, in construct_affinity_matrix
    adj_mat = gaussian_kernel_distance(sub_object, band_width=band_width)
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/aux_func/graph_func.py", line 6, in gaussian_kernel_distance
    euc_dis = pairwise_distances(vector)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 2195, in pairwise_distances
    return _parallel_pairwise(X, Y, func, n_jobs, **kwds)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 1765, in _parallel_pairwise
    return func(X, Y, **kwds)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 310, in euclidean_distances
    X, Y = check_pairwise_arrays(X, Y)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 156, in check_pairwise_arrays
    X = Y = check_array(
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/utils/validation.py", line 969, in check_array
    raise ValueError(
ValueError: Found array with 0 sample(s) (shape=(0, 3)) while a minimum of 1 is required by check_pairwise_arrays.

代码未做任何改动,使用的数据也是下载代码时附带的曙光数据集。请问为何会出现这个错误,该如何解决?谢谢。
我的环境:
python==3.8.13
pytorch==1.11.0
scikit-learn==1.3.0
imageio=2.31.1
numpy==1.23.1
gdal==3.6.2
opencv==4.8.0

@ChenHongruixuan
Copy link
Owner

Sorry for my late reply. And many thanks for your interest to our works!

The problem seems to be caused by the start value of the label of the object map. Maybe we are using a different version of the package. Starting from a certain version, the labels of the object map obtained with the slic algorithm will start from 1, not 0. Maybe you can target your code changes based on this.

Best regards,

@Broccoli77PP
Copy link

Sorry for my late reply. And many thanks for your interest to our works!

The problem seems to be caused by the start value of the label of the object map. Maybe we are using a different version of the package. Starting from a certain version, the labels of the object map obtained with the slic algorithm will start from 1, not 0. Maybe you can target your code changes based on this.

Best regards,

感谢您的工作! 当我想训练train_SRGCAE_Local.py时,出现以下错误:

Traceback (most recent call last):
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/train_SRGCAE_Local.py", line 150, in <module>
    train_model(args)
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/train_SRGCAE_Local.py", line 51, in train_model
    am_set_t1 = construct_affinity_matrix(img_t1, objects, args.band_width_t1)
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/aux_func/graph_func.py", line 26, in construct_affinity_matrix
    adj_mat = gaussian_kernel_distance(sub_object, band_width=band_width)
  File "/media/meng/57673667-4363-4453-89a5-a422016a5299/Meng_forked/code/change_detection/SRGCAE/aux_func/graph_func.py", line 6, in gaussian_kernel_distance
    euc_dis = pairwise_distances(vector)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 2195, in pairwise_distances
    return _parallel_pairwise(X, Y, func, n_jobs, **kwds)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 1765, in _parallel_pairwise
    return func(X, Y, **kwds)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 310, in euclidean_distances
    X, Y = check_pairwise_arrays(X, Y)
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 156, in check_pairwise_arrays
    X = Y = check_array(
  File "/home/meng/anaconda3/envs/torch1.11.0/lib/python3.8/site-packages/sklearn/utils/validation.py", line 969, in check_array
    raise ValueError(
ValueError: Found array with 0 sample(s) (shape=(0, 3)) while a minimum of 1 is required by check_pairwise_arrays.

代码未做任何改动,使用的数据也是下载代码时附带的曙光数据集。请问为何会出现这个错误,该如何解决?谢谢。 我的环境: python==3.8.13 pytorch==1.11.0 scikit-learn==1.3.0 imageio=2.31.1 numpy==1.23.1 gdal==3.6.2 opencv==4.8.0

May I ask, have you solved this problem

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

3 participants