def _get_sample(self, number_samples, resample=False, observed=False, input_values={}, differentiable=True): if self in input_values: value = input_values[self] else: value = self.value if not is_discrete(value): return {self: tile_parameter(value, number_samples=number_samples)} else: return {self: value}
def _get_sample(self, number_samples, resample=False, observed=False, input_values={}): if self in input_values: value = input_values[self] else: value = self.value if not is_discrete(value): return {self: tile_parameter(value, number_samples=number_samples)} else: return { self: value } #TODO: This is for allowing discrete data, temporary? (for Julia)
def _get_sample(self, number_samples, resample=False, observed=False, input_values={}): if self in input_values: value = input_values[self] else: value = self.value if isinstance(value, chainer.Variable): return {self: tile_parameter(value, number_samples=number_samples)} #value_shape = value.shape #reps = tuple([number_samples] + [1]*len(value_shape[1:])) #return {self: F.tile(value, reps=reps)} #TODO: Work in progress else: return { self: value } #TODO: This is for allowing discrete data, temporary?
xc = F.expand_dims(x, axis=dim) equal_tensor_variable(xt, xc) ## tensor_tuple = (torch.randn(10, 5), torch.randn(40, 5)) outt = utilities.uniform_shapes(tensor_tuple[0], tensor_tuple[1]) outc = utilities.uniform_shapes_chainer( chainer.Variable(tensor_tuple[0].numpy()), chainer.Variable(tensor_tuple[1].numpy())) all([equal_tensor_variable(xt, xc) for xt, xc in zip(outt, outc)]) ## torch.repeat for tiling ns = 20 x = np.random.normal(size=(1, 20)) xt = utilities.tile_parameter(torch.tensor(x), number_samples=ns) xc = utilities.tile_parameter_chainer(chainer.Variable(x), number_samples=ns) equal_tensor_variable(xt, xc) ## get_diagonal: torch reshape x = np.random.normal(size=(1, 20, 10, 20)) xt = utilities.get_diagonal(torch.tensor(x)) xc = utilities.get_diagonal_chainer(chainer.Variable(x)) equal_tensor_variable(xt, xc) ## sum_from_dim: torch sum x = np.random.normal(size=(20, 5, 4, 2)) dim_index = 1 xt = utilities.sum_from_dim(torch.tensor(x), dim_index)