extract_patches_2d max_patches param behaviours
#9,390 opened on 2017年7月17日
説明
Hi, initially this started as SO question. However, now I really think is might be considered as an issue.
I'm using sklearn version 0.18.2
In particular, I'm using this function for extracting image regions: http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.image.extract_patches_2d.html
This function has one funny argument, namely max_patches which says how many patches function should extract from the image.
According to the source code, lines 228-238, if the number of requested samples is higher than the number of patches available in the image, an exception is raised: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/image.py
In my image set I have images of different sizes: from really tiny images to full HD ones. And now this is a problem as when I try to request, say, 1e6 patches, it throws an error on small images.
The workaround, I found is as follows. Is it alright is just paste link with my SO answer here? https://stackoverflow.com/questions/45146347/extract-patches-2d-max-patches-param-behaviours/
If no, I can correct it. Long, story short to get what I want I had to use a private module function, namely _compute_n_patches
Should this be considered as an issue? When you request the amount of patches that is greater than available, you would expect to get this amount of patches at maximum. If this amount of patches is unavailable, why throw an exception?
What am I missing?
Thanks