View source on GitHub |
Gaussian noise generator with counter as pseudo state.
Inherits From: ValueGenerator
tf_privacy.tree_aggregation.GaussianNoiseGenerator(
noise_std: float,
specs: Collection[tf.TensorSpec],
seed: Optional[int] = None
)
Produces i.i.d. spherical Gaussian noise at each step shaped according to a
nested structure of tf.TensorSpec
s.
Args | |
---|---|
noise_std
|
The standard deviation of the noise. |
specs
|
A nested structure of tf.TensorSpec s specifying the shape of the
noise to generate.
|
seed
|
An optional integer seed. If None, generator is seeded from the clock. |
Methods
initialize
initialize()
Makes an initial state for the GaussianNoiseGenerator.
Returns | |
---|---|
A named tuple of (seeds, stddev). |
make_state
make_state(
seeds: tf.Tensor, stddev: tf.Tensor
)
Returns a new named tuple of (seeds, stddev).
next
next(
state
)
Gets next value and advances the GaussianNoiseGenerator.
Args | |
---|---|
state
|
The current state (seed, noise_std). |
Returns | |
---|---|
A tuple of (sample, new_state) where sample is a new sample and new_state is the advanced state (seed+1, noise_std). |