Create an array of categorical variable and get the logp

Hi. I want to create two categorical variables.
Each categorical variables can have three possible values.

I tried the following:

import numpy as np
import pymc3 as pm
import theano.tensor as tt
import matplotlib.pyplot as plt

p = np.random.uniform(0, 1, size=(2, 3))

basic_model = pm.Model()

x = np.array(
    [[0, 1, 2],
    [2, 1, 0]]
with basic_model:
    cat = pm.Categorical('categ', p=p, shape=(2,))

But it gives the following error when I try to get the log probability that an observation sequence appears, given the model:

  "can't turn {} and {} into a dict. {}".format(args, kwargs, e))
TypeError: can't turn [array([[0, 1, 2],
       [2, 1, 0]])] and {} into a dict. dictionary update sequence element #0 has length 3; 2 is required


Couple of things here:

  1. RV.logp accept a dictionary as input, the dictionary should have the same structure as model.test_point (key and usually shape)
  2. The vector p is not normalized - it should be constrained to sum to 1
  3. The output of the categorical should be 1 dimension less than the parameter p, not sure if it is intensional that x has the same shape as p here but you should be careful about that.

Replace last line with: cat.distribution.logp(x).eval()