Skip to content

Commit

Permalink
fix: tied was ignored when saving to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardz1 committed Jul 16, 2024
1 parent 3822db6 commit 4f2e1d0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions project/classifiers/gaussian_mixture_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ def from_json(data: dict) -> "SingleGMM":
(
np.array(d["w"]),
vcol(np.array(d["mu"])),
np.array(d["C"]) if gmm._type == "full" else np.diag(np.array(d["C"])),
(
np.diag(np.array(d["C"]))
if gmm._type == "diagonal"
else np.array(d["C"])
),
)
for d in data["params"]
]
Expand Down Expand Up @@ -250,7 +254,9 @@ def to_json(self) -> dict:
"w": w.tolist(),
# Save as row to make the representation more compact
"mu": vrow(mu).tolist(),
"C": C.tolist() if self._type == "full" else np.diag(C).tolist(),
"C": (
np.diag(C).tolist() if self._type == "diagonal" else C.tolist()
),
}
for w, mu, C in self.params
],
Expand Down

0 comments on commit 4f2e1d0

Please sign in to comment.