MCPcopy Create free account
hub / github.com/apache/singa / bernoulli

Method bernoulli

python/singa/tensor.py:496–511  ·  view source on GitHub ↗

Sample 0/1 for each element according to the given probability. Args: p (float): with probability p, each element is sample to 1. inplace: inplace flag Returns: this tensor

(self, p, inplace=True)

Source from the content-addressed store, hash-verified

494 return self.clone()
495
496 def bernoulli(self, p, inplace=True):
497 '''Sample 0/1 for each element according to the given probability.
498
499 Args:
500 p (float): with probability p, each element is sample to 1.
501 inplace: inplace flag
502
503 Returns:
504 this tensor
505 '''
506 if not inplace:
507 # return new tensor
508 raise NotImplementedError
509
510 singa.Bernoulli(float(p), self.data)
511 return self
512
513 def gaussian(self, mean, std, inplace=True):
514 '''Generate a value for each element following a Gaussian distribution.

Callers 1

Calls

no outgoing calls

Tested by 1