Open
Description
Hi,
First of all, thank you so much for inferpy. Its an wonderful project. I am trying to implement Poisson Matrix factorization using this library. I first implemented the basic Matrix factorization using the example given in the older version of inferpy. The relevant part of the code is as follows :
`
# definition of a generic model
@inf.probmodel
def mf(M, K):
w_Item = inf.Normal(loc=tf.zeros([M, K]), scale=1, name="wItem")
with inf.datamodel():
w_User = inf.Normal(tf.ones(K), scale=1, name="wUser")
Rating = inf.Normal(tf.matmul(w_User, w_Item, transpose_b = True), 1, name="Rating")
#In variational inference - define Q-model
@inf.probmodel
def qmodel(M, K):
qw_Item_loc = inf.Parameter(tf.zeros([M, K]), name="qw_Item_loc")
qw_Item_scale = tf.math.softplus(inf.Parameter(tf.ones([M, K]), name="qw_Item_scale"))
qw_Item = inf.Normal(qw_Item_loc, qw_Item_scale, name="wItem")
with inf.datamodel():
qw_Userloc = inf.Parameter(np.ones(K), name="qw_Userloc")
qw_Userscale = tf.math.softplus(inf.Parameter(tf.ones(K), name="qw_Userscale"))
qw = inf.Normal(qw_Userloc, qw_Userscale, name="wUser")`
This code seems to work ... so I modified the code for Poisson factorization as follows:
`
# definition of a generic model
@inf.probmodel
def mf(M, K):
w_Item = inf.Normal(loc=tf.zeros([M, K]), scale=1, name="wItem") # shape = [M,K]
with inf.datamodel():
w_User = inf.Normal(tf.ones(K), scale=1, name="wUser") # shape = [N,K]
Rating = inf.Poisson(tf.math.exp(w_User) @ tf.transpose(tf.math.exp(w_Item)), name="Rating")
#In variational inference - define Q-model
@inf.probmodel
def qmodel(M, K):
qw_Item_loc = inf.Parameter(tf.zeros([M, K]), name="qw_Item_loc")
qw_Item_scale = tf.math.softplus(inf.Parameter(tf.ones([M, K]), name="qw_Item_scale"))
qw_Item = inf.Normal(qw_Item_loc, qw_Item_scale, name="wItem")
with inf.datamodel():
qw_Userloc = inf.Parameter(np.ones(K), name="qw_Userloc")
qw_Userscale = tf.math.softplus(inf.Parameter(tf.ones(K), name="qw_Userscale"))
qw = inf.Normal(qw_Userloc, qw_Userscale, name="wUser")`
Unfortunately it gives the following error ...
LookupError: No gradient defined for operation 'Rating_46/sample/random_poisson/RandomPoissonV2' (op type: RandomPoissonV2)
I tried to find some examples using Poisson distribution but could not find any ...where am I going wrong ? Kindly help ...
Metadata
Metadata
Assignees
Labels
No labels