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