def forward(self): if self.alpha.ndim == 1: return Tensor(np.random.dirichlet(self.alpha.value), function=self) else: raise NotImplementedError
def forward(self, x): self.x = x if isinstance(self.x, Constant): return Constant(x.value) return Tensor(x.value, function=self)
def forward(self): self.output = np.random.gamma(self.shape.value, 1 / self.rate.value) if isinstance(self.shape, Constant) and isinstance( self.rate, Constant): return Constant(self.output) return Tensor(self.output, function=self)
def forward(self): self.eps = np.random.normal(size=self.mu.shape) output = self.mu.value + self.std.value * self.eps if isinstance(self.mu, Constant) and isinstance(self.var, Constant): return Constant(output) return Tensor(output, self)