use burn::{
Tensor,
prelude::Bool,
tensor::Distribution,
};
pub fn fuzz_state<const R: usize>(
state: Tensor<R, Bool>,
density: f64,
) -> Tensor<R, Bool> {
if density == 0.0 {
return state;
}
let noise = Tensor::<R>::random(
state.shape(),
Distribution::Bernoulli(density),
&state.device(),
)
.bool();
state.bool_xor(noise)
}
pub fn fuzz_state_2d(
state: Tensor<2, Bool>,
density: f64,
) -> Tensor<2, Bool> {
fuzz_state(state, density)
}
pub fn fuzz_state_3d(
state: Tensor<3, Bool>,
density: f64,
) -> Tensor<3, Bool> {
fuzz_state(state, density)
}