bernoulli

tch_bernoulli(x, p = NULL)

Arguments

x

tensor object

p

probability (if null uses tensor values)

Examples

x <- tensor(runif(10)) tch_bernoulli(x)
#> tensor #> 0 #> 0 #> 1 #> 0 #> 1 #> 0 #> 1 #> 1 #> 1 #> 1 #> [ Variable[CPUFloatType]{10} ]
x <- tensor(rep(0, 10)) tch_bernoulli(x)
#> tensor #> 0 #> 0 #> 0 #> 0 #> 0 #> 0 #> 0 #> 0 #> 0 #> 0 #> [ Variable[CPUFloatType]{10} ]