question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `RandomChoice` - randomly pick from list!

See original GitHub issue

Short Description

Let’s say in your training, you want to use all of the follows:

  • cutmix-mixup-fmix-mosaic
  • gaussian_blur-zoom_blur-motion_blur-median-blur
  • optical_distortion-elastic-transform-grid_distortion
  • equalization-clahe
  • grid_mask-cutput
  • etc.

then it’s required to randomly pick one among others (in general) in a single pass during training, for example: [cutmix-zoom_blur-optical_distortion-clahe-cutput]. So, it would be nice to have a functionality to feasibly do this task.

Papers Most of the top used libraries/frameworks offer similar strategies.

Existing Implementations

Other Information In the title, the name RandomChoice is picked for demonstration purposes. The thing is, we may need to introduce or modify any of the existing functionality if it’s reasonable to take.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LukeWoodcommented, May 11, 2022

I like the way Albumnations OneOf works; but I don’t like that they take a p parameter in their constructor for the augmentations themselves that behaves differently depending on context; very unintuitive.

We should strive to support custom probabilities, but not in that way.

1reaction
LukeWoodcommented, May 11, 2022

Awesome, thanks for the links @sebastian-sz and @chjort.

Here is my thought:

  • right now, we have RandomAugmentationPipeline, which couples two ideas: repeated augmentation, and Randomly selecting from a list
  • we can extract this functionality into two separate pieces: a RandomChoice(), and a for loop
  • after this, the functionality of RandomAugmentationPipeline will just be to wrap a RandomChoice() in a for loop + support a rate parameter.

So for a PR I’d like:

Feel free to send this PR @chjort

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python random choice() function to select a random item from ...
Use random.choice() function to randomly select an item from a list, String, Dictionary, and set. Pick a single random number from a range....
Read more >
How can I randomly select an item from a list? - Stack Overflow
In short, use random.sample method ... The sample method returns a new list containing elements from the population while leaving the original ...
Read more >
Python Random choice() Method - W3Schools
The choice() method returns a randomly selected element from the specified sequence. The sequence can be a string, a range, a list, a...
Read more >
Python | Select random value from a list - GeeksforGeeks
Using random.sample() to select random value from a list ... Python has a built-in function called random.sample(). The random module contains the ...
Read more >
How to Randomly Select Elements From a List in Python
Selecting a Random Element From Python List · Using random.randint() · Using random.randrange() · Using random.choice().
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found