-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjectives.py
More file actions
21 lines (15 loc) · 820 Bytes
/
objectives.py
File metadata and controls
21 lines (15 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import numpy as np
import math
class Objectives:
def objective(self, Lw, U, lamda, K, beta):
return self.negloglikelihood(Lw, lamda, K) + self.prior(beta, Lw, lamda, U)
def negloglikelihood(self, Lw, lamda, K):
return np.sum(-np.log(lamda)) + np.trace(K @ Lw)
def prior(self, beta, Lw, lamda, U):
return 0.5 * beta * np.linalg.norm(Lw - U @ np.diag(lamda) @ U.T)**2
def bipartite_nll(self, Lw, K, J):
return np.sum(-np.log(np.linalg.eigvals(Lw + J)) + np.diag(K @ Lw))
def bipartite_prior(self, nu, Aw, psi, V):
return 0.5 * nu * np.linalg.norm(Aw - V @ np.diag(psi) @ V.T) ** 2
def bipartite_obj(self, Aw, Lw, V, psi, K, J, nu):
return self.bipartite_nll(Lw = Lw, K = K, J = J) + self.bipartite_prior(nu = nu, Aw = Aw, psi = psi, V = V)