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

Handle data with 1-d features #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Virusdoll
Copy link

This allows the GMM model to handle data with 1-dimensional features.

Specifically, the shape of mat_b with 1-dimensional features is (1,k,1,1), and mat_b[0, i, :, :].squeeze() returns a numeric value instead of a matrix, which raises the following error:

Traceback (most recent call last):
  File "/media/Store4/yxc/workspace/gmm-torch/test.py", line 22, in testPredictClasses
    model.fit(x)
  File "/media/Store4/yxc/workspace/gmm-torch/gmm.py", line 149, in fit
    self.__em(x)
  File "/media/Store4/yxc/workspace/gmm-torch/gmm.py", line 365, in __em
    _, log_resp = self._e_step(x)
  File "/media/Store4/yxc/workspace/gmm-torch/gmm.py", line 317, in _e_step
    weighted_log_prob = self._estimate_log_prob(x) + torch.log(self.pi)
  File "/media/Store4/yxc/workspace/gmm-torch/gmm.py", line 275, in _estimate_log_prob
    x_mu_T_precision = calculate_matmul_n_times(self.n_components, x_mu_T, precision)
  File "/media/Store4/yxc/workspace/gmm-torch/utils.py", line 16, in calculate_matmul_n_times
    res[:, i, :, :] = mat_a_i.mm(mat_b_i).unsqueeze(1)
RuntimeError: mat2 must be a matrix

This can be solved by removing the squeeze() function.

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.

1 participant