Skip to content
fn

bernoulli_op

→TensorImplPtr
int bernoulli_op(const int & shape, double p, Dtype dt, Device device, Generator * gen)

Python wrappers

Public Python APIs implemented by this engine symbol.

Allocates a tensor of independent Bernoulli(p)(p) samples.

Each element is independently drawn as 1 with probability pp and 0 with probability 1−p1 - p.

Math

\Pr(x_i = 1) = p, \quad \Pr(x_i = 0) = 1 - p$$ **See Also** `lucid.distributions.Bernoulli` — higher-level distribution object built on top of this op.

Parameters

shapeconst Shape&
Shape of the output tensor.
pdouble
Success probability in [0,1][0, 1].
dtDtype
Output dtype. Both floating-point (F32/F64 storing 0.0/1.0) and integer (U8/I32 storing 0/1) are accepted.
deviceDevice
Memory domain.
genGenerator*= None
Bit-stream state.

Returns

TensorImplPtr

Newly allocated leaf tensor (requires_grad = false).