Description
Exercise 1
1. Write the factorization of the joint distribution 𝑃(𝐴, 𝐵, 𝐶, 𝐷, 𝐸, 𝐹) corresponding to the Bayesian network:
2. Indicate whether the following statements on conditional indepence are True or False and motivate your answer.
a. A B
b. A F
c. A C | {B,E}
d. F D | B
e. B D | C
⊥⊥
⊥⊥
⊥⊥
⊥⊥
⊥⊥
Exercise 2
Topic models are statistical models that learn the distribution of the abstract topics occurring in a collection of documents. In this
context, documents are collections of topics and topics are collections of words.
We consider a dictionary of words, an ordered collection of documents and an ordered collection of possible topics
appearing in each document. We build our model using the indexes representing each quantity in its collection (e.g. is the -th word
in the dictionary). For simplicity, we assume that all documents contain the same number of words. Each document can contain
multiple topics; specifically, we associate a topic to each word appearing in the document.
We make the following assumptions:
is the total number of documents
is the total number of topics
is the number of words per document
For the -th word and the -th document, we sample a topic from a Categorical distribution on
The distribution of topics in the -th document is a Dirichlet distribution with concentration parameters (the length of is )
The -th word in the -th document, namely , is sampled from a Categorical distribution on
The distribution of words per topic is a Dirichlet distribution with concentration parameters (the length of is )
1. Write the generative process of the following graphical model. Be aware of plate notation!
𝑁 𝐷 𝑇
𝑖 𝑖
𝐷
𝑇
𝑊 < 𝑁
𝑗 𝑖 𝑡𝑖,𝑗 𝜃𝑖
𝜃𝑖 𝑖 𝛼 𝛼 𝑇
𝑗 𝑖 𝑤𝑖,𝑗 𝜑𝑡𝑖,𝑗
𝜑𝑘 𝑘 𝛽 𝛽 𝑁
2. Set , , , and use pyro to implement this graphical model as a function of the
hyperparameters model(alpha, beta) , that outputs theta, phi, t, w .
3. Evaluate your function on the hyperparameters
alpha = torch.tensor([0.5, 0.3, 0.1, 0.4, 0.2])
beta = dist.Gamma(1./T, 1.).sample((W,))
and print the shape of the output tensors theta, phi, t, w .