-
Notifications
You must be signed in to change notification settings - Fork 621
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
Add ShotNoise CPU and GPU operators #2861
Conversation
31a27bc
to
f610a3c
Compare
f610a3c
to
8c406a8
Compare
8c406a8
to
5173455
Compare
Signed-off-by: Joaquin Anton <janton@nvidia.com>
5173455
to
44e2651
Compare
|
||
output[i] = denormalize(poisson_dist(normalize(input[:]) * peak) / peak) | ||
|
||
where ``normalize`` and ``denormalize`` represent scaling to the range [-1, 1] and back to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poisson noise is unsigned - if so, then why do we have the [-1,1] range? Also - do we want to do something with negative values? (e.g. produce a noisy value from the absolute and copysign?).
DALI_HOST_DEV inline T operator()(T in_val, Generator& g) { | ||
float norm = ConvertNorm<float>(in_val); | ||
Dist dist(peak_ * norm); | ||
return ConvertSatNorm<T>(dist(g) / peak_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store the reciprocal and multiply here.
return ConvertSatNorm<T>(dist(g) / peak_); | |
return ConvertSatNorm<T>(dist(g) * ipeak_); |
std::poisson_distribution<uint32_t>>; | ||
|
||
DALI_HOST_DEV explicit shot_noise_impl(float peak = 12) | ||
: peak_{peak} {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: peak_{peak} {} | |
: peak_(peak), ipeak(1/peak) {} |
Nitpick: following my advisor's recommendation - I think that such simple initialization can be expressed more naturally by plain assignment.
Signed-off-by: Joaquin Anton <janton@nvidia.com>
The factor can be interpreted as the number of event registrations (modeled by the poisson distribution) | ||
are required to increase the output value by 1. For example, a factor of 0.1 means we need the | ||
10 events to increase the output by 1, while a factor of 10 means that a single event | ||
increases the output by 10. The higher the factor, the more noise will be applied to the data. | ||
A factor of 0 translates to an identity operation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description is inaccurate (it's for the 1/factor). Also, perhaps we should define what a shot noise is?
The factor can be interpreted as the number of event registrations (modeled by the poisson distribution) | |
are required to increase the output value by 1. For example, a factor of 0.1 means we need the | |
10 events to increase the output by 1, while a factor of 10 means that a single event | |
increases the output by 10. The higher the factor, the more noise will be applied to the data. | |
A factor of 0 translates to an identity operation. | |
Shot noise is a noise that's present in data generated by a Poisson process, like | |
registering photons by an image sensor. This operator simulates the data | |
acquisition process where each event increases the output value by | |
``factor`` and the input tensor contains the expected values of corresponding | |
output points. For example, a ``factor`` of 0.1 means that each 10 events are | |
needed to increase the output value by 1, while a factor of 10 means that | |
a single event increases the output by 10. The output values are quantized | |
to multiples of ``factor``. The larger the factor, the more noise is present in | |
the output. A factor of 0 makes this an identity operation. |
Optionally, we can add a line saying that
The values in the input must be of the same sign as the factor.
but I'm not sure if we really need to write that - an inquisitive reader should discover that on their own.
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [2299238]: BUILD STARTED |
CI MESSAGE: [2299238]: BUILD PASSED |
Signed-off-by: Joaquin Anton janton@nvidia.com
Why we need this PR?
Pick one, remove the rest
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
Implemented
noise.shot
based on the existing template for noise generators.New functionality
All
Tests added
Docstr
JIRA TASK: [DALI-1946] [DALI-1947]