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

RNGBase to be used as base for noise augmentations + Add GaussianNoise operator (as an example) #2846

Merged
merged 4 commits into from
Apr 15, 2021

Conversation

jantonguirao
Copy link
Contributor

@jantonguirao jantonguirao commented Apr 7, 2021

Signed-off-by: Joaquin Anton janton@nvidia.com

Why we need this PR?

  • It reworks RNGBase class so that it can be used as a template for noise augmentations (applying random noise to an input) as well as the existing random generators (produces a random output, no input).

What happened in this PR?

Fill relevant points, put NA otherwise. Replace anything inside []

  • What solution was applied:
    Introduced a NeedsInput template argument to RNGBase to support a family of noise augmentation operators.
    *Created a fn.noise.gaussian as an example. The output of noise.gaussian(input, ...) is tested by comparing to input + random.normal(...) *.
  • Affected modules and functionalities:
    random. operators*
  • Key points relevant for the review:
    Design of RNGBase
  • Validation and testing:
    Python tests
  • Documentation (including examples):
    NA

JIRA TASK: [DALI-1949] [DALI-1950]

Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2260255]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2260255]: BUILD FAILED

@jantonguirao
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2260507]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2260507]: BUILD PASSED

Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao jantonguirao changed the title [WIP] RNGBase with data input RNGBase to be used as base for noise augmentations + GaussianNoise operator (as an example) Apr 13, 2021
@jantonguirao jantonguirao marked this pull request as ready for review April 13, 2021 07:28
Signed-off-by: Joaquin Anton <janton@nvidia.com>
template <typename T>
bool SetupDists(typename Dist<T>::type* dists_data, int nsamples) {
if (!mean_.IsDefined() && !stddev_.IsDefined()) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default constructed Dist is used. This mechanism is mainly used for cases where we don't need to create a per sample instance and we are fine with the default constructed.

Copy link
Contributor

@JanuszL JanuszL Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the user know that not providing mean and stdev would make DALI to follow such code path?
Asking mostly from the user point of view.

struct BlockDesc;

template <>
struct BlockDesc<false> {
int sample_idx;
void* start;
Copy link
Contributor

@JanuszL JanuszL Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not output to be consistent with BlockDesc<true>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that.

@jantonguirao jantonguirao changed the title RNGBase to be used as base for noise augmentations + GaussianNoise operator (as an example) RNGBase to be used as base for noise augmentations + Add GaussianNoise operator (as an example) Apr 14, 2021
Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2266847]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2266847]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2266847]: BUILD PASSED

@jantonguirao jantonguirao merged commit 70ed742 into NVIDIA:master Apr 15, 2021
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

Successfully merging this pull request may close these issues.

4 participants