#[non_exhaustive]pub struct SmoothGradConfig {
pub noisy_sample_count: i32,
pub gradient_noise_sigma: Option<GradientNoiseSigma>,
/* private fields */
}dataset-service or deployment-resource-pool-service or endpoint-service or job-service or model-service or pipeline-service or prediction-service only.Expand description
Config for SmoothGrad approximation of gradients.
When enabled, the gradients are approximated by averaging the gradients from noisy samples in the vicinity of the inputs. Adding noise can help improve the computed gradients. Refer to this paper for more details: https://arxiv.org/pdf/1706.03825.pdf
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.noisy_sample_count: i32The number of gradient samples to use for approximation. The higher this number, the more accurate the gradient is, but the runtime complexity increases by this factor as well. Valid range of its value is [1, 50]. Defaults to 3.
gradient_noise_sigma: Option<GradientNoiseSigma>Represents the standard deviation of the gaussian kernel that will be used to add noise to the interpolated inputs prior to computing gradients.
Implementations§
Source§impl SmoothGradConfig
impl SmoothGradConfig
pub fn new() -> Self
Sourcepub fn set_noisy_sample_count<T: Into<i32>>(self, v: T) -> Self
pub fn set_noisy_sample_count<T: Into<i32>>(self, v: T) -> Self
Sets the value of noisy_sample_count.
§Example
let x = SmoothGradConfig::new().set_noisy_sample_count(42);Sourcepub fn set_gradient_noise_sigma<T: Into<Option<GradientNoiseSigma>>>(
self,
v: T,
) -> Self
pub fn set_gradient_noise_sigma<T: Into<Option<GradientNoiseSigma>>>( self, v: T, ) -> Self
Sets the value of gradient_noise_sigma.
Note that all the setters affecting gradient_noise_sigma are mutually
exclusive.
§Example
use google_cloud_aiplatform_v1::model::smooth_grad_config::GradientNoiseSigma;
let x = SmoothGradConfig::new().set_gradient_noise_sigma(Some(GradientNoiseSigma::NoiseSigma(42.0)));Sourcepub fn noise_sigma(&self) -> Option<&f32>
pub fn noise_sigma(&self) -> Option<&f32>
The value of gradient_noise_sigma
if it holds a NoiseSigma, None if the field is not set or
holds a different branch.
Sourcepub fn set_noise_sigma<T: Into<f32>>(self, v: T) -> Self
pub fn set_noise_sigma<T: Into<f32>>(self, v: T) -> Self
Sets the value of gradient_noise_sigma
to hold a NoiseSigma.
Note that all the setters affecting gradient_noise_sigma are
mutually exclusive.
§Example
let x = SmoothGradConfig::new().set_noise_sigma(42.0);
assert!(x.noise_sigma().is_some());
assert!(x.feature_noise_sigma().is_none());Sourcepub fn feature_noise_sigma(&self) -> Option<&Box<FeatureNoiseSigma>>
pub fn feature_noise_sigma(&self) -> Option<&Box<FeatureNoiseSigma>>
The value of gradient_noise_sigma
if it holds a FeatureNoiseSigma, None if the field is not set or
holds a different branch.
Sourcepub fn set_feature_noise_sigma<T: Into<Box<FeatureNoiseSigma>>>(
self,
v: T,
) -> Self
pub fn set_feature_noise_sigma<T: Into<Box<FeatureNoiseSigma>>>( self, v: T, ) -> Self
Sets the value of gradient_noise_sigma
to hold a FeatureNoiseSigma.
Note that all the setters affecting gradient_noise_sigma are
mutually exclusive.
§Example
use google_cloud_aiplatform_v1::model::FeatureNoiseSigma;
let x = SmoothGradConfig::new().set_feature_noise_sigma(FeatureNoiseSigma::default()/* use setters */);
assert!(x.feature_noise_sigma().is_some());
assert!(x.noise_sigma().is_none());Trait Implementations§
Source§impl Clone for SmoothGradConfig
impl Clone for SmoothGradConfig
Source§fn clone(&self) -> SmoothGradConfig
fn clone(&self) -> SmoothGradConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more