Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gmm and Update gaussian #89

Merged
merged 1 commit into from Sep 22, 2022
Merged

Add gmm and Update gaussian #89

merged 1 commit into from Sep 22, 2022

Conversation

sbsekiguchi
Copy link
Contributor

Added gmm and gaussian of the numpy models.
In addition, updated the gaussian distribution's API.

The API change is like following:

Previous :

batch_size = 10
output_dim = 10
input_shape = (batch_size, output_dim)
mean = np.zeros(shape=input_shape)
sigma = np.ones(shape=input_shape) * 5.
ln_var = np.log(sigma) * 2.
distribution = D.Gaussian(mean, ln_var)
# return nn.Variable
assert isinstance(distribution.sample(), nn.Variable)

Updated:

batch_size = 10
output_dim = 10
input_shape = (batch_size, output_dim)
mean = np.zeros(shape=input_shape)
sigma = np.ones(shape=input_shape) * 5.
ln_var = np.log(sigma) * 2.
# You have to pass the nn.Variable if you want to get nn.Variable as all class method's return.
distribution = D.Gaussian(nn.Variable.from_numpy_array(mean), nn.Variable.from_numpy_array(ln_var))
assert isinstance(distribution.sample(), nn.Variable)

# If you pass np.ndarray, then all class methods return np.ndarray
# Currently, only support without batch shape (i.e. mean.shape = (dims,), ln_var.shape = (dims, dims)).
distribution = D.Gaussian(mean[0], np.diag(ln_var[0]))  # without batch
assert isinstance(distribution.sample(), np.ndarray)

@sbsekiguchi sbsekiguchi changed the title Add gmm and gaussian Add gmm and Update gaussian Sep 22, 2022
@sbsekiguchi sbsekiguchi self-assigned this Sep 22, 2022
@ishihara-y ishihara-y merged commit 4ac5f37 into master Sep 22, 2022
@ishihara-y ishihara-y deleted the feature/20220822-add-gmm branch September 22, 2022 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants