dcslin commented on a change in pull request #570: Tensor naming convention review URL: https://github.com/apache/singa/pull/570#discussion_r365662139 ########## File path: python/singa/tensor.py ########## @@ -352,74 +356,86 @@ def deepcopy(self): ''' return self.clone() - def bernoulli(self, p): + def bernoulli(self, p, inplace=True): '''Sample 0/1 for each element according to the given probability. Args: p (float): with probability p, each element is sample to 1. ''' + if not inplace: + # return new tensor + raise NotImplementedError + singa.Bernoulli(float(p), self.data) - def gaussian(self, mean, std): + def gaussian(self, mean, std, inplace=True): '''Generate a value for each element following a Gaussian distribution. Args: mean (float): mean of the distribution std (float): standard variance of the distribution ''' + if not inplace: + # return new tensor + raise NotImplementedError + singa.Gaussian(float(mean), float(std), self.data) - def uniform(self, low, high): + def uniform(self, low, high, inplace=True): '''Generate a value for each element following a uniform distribution. Args: low (float): the lower bound high (float): the hight bound ''' + if not inplace: + # return new tensor + raise NotImplementedError + singa.Uniform(float(low), float(high), self.data) def add_column(self, v): Review comment: reference https://github.com/apache/singa/pull/570/commits/203fcb91cd590d3436ce31a68844d8f47817be9c ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services