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)
| 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. |
no outgoing calls