Midterm 2 (2021)
Assignment Rules and Execution
The second midterm covers the generative models introduced up to Lecture 11. To pass the midterm you should
- perform one (only one) of the assignments described in the following;
- prepare the short presentation describing your results and upload it here by the (strict) deadline;
- give your short presentation in front of the class on the midterm date (May the 03rd, 2021, h. 13.30).
You can use library functions to perform the analysis (e.g. implementations of HMMs, LDA, etc., as well as helper functions, e.g. to extract visual patches, etc.) unless explicitly indicated (e.g. Assignment 3 and 4). You can use whatever programming language you like, but I strongly suggest to use either Python or Matlab for which you have coding examples.
The midterm presentation MUST take a maximum of 3 minutes and should include a maximum of 5 slides, whose content should cover:
- A title slide with the assignment number and your name
- (only needed for assignement 3 and 4) A slide with code snippets
highlighting the key aspects of your code
- Slides showing the results of the analysis
- A final slide with your personal considerations (fun things, weak aspects, possible ways to enhance the analysis, etc.).
Don’t waste slides and time to describe the dataset or the assignment you are solving as we will all be already informed on it.
Assignments are based on the following two datasets already used in Midterm 1: refer to Midterm 1 page for details on the content.
DSET1 (Signal processing): https://archive.ics.uci.edu/ml/datasets/Appliances+energy+prediction#
DSET2 (Image processing): http://download.microsoft.com/download/A/1/1/A116CD80-5B79-407E-B5CE-3D5C6ED8B0D5/msrc_objcategimagedatabase_v1.zip
In addition to these datasets from Midterm 1, Assignment 3 is based on the well-known MNIST dataset:
DSET3 (Image processing): http://yann.lecun.com/exdb/mnist/
List of Midterm Assignments
Assignment 1
Fit an
Hidden Markov Model with Gaussian emissions to the data in DSET1: it is
sufficient to focus on the “Appliances” and “Lights” columns of the
dataset
which measure the energy consumption of appliances and lights,
respectively,
across a period of 4.5 months. Consider the two columnsin isolation,
i.e.
train two separate HMM, one for appliances and one for light.
Experiment with HMMs with a varying number of
hidden states (e.g. at least 2, 3 and 4). Once trained the HMMs, perform
Viterbi on a reasonably sized subsequence (e.g. 1 month of data) and
plot the timeseries
data highlighting (e.g. with different colours) the hidden state
assigned to
each timepoint by the Viterbi algorithm. Then, try sampling a sequence
of at least 100 points from the trained HMMs and show it on a plot
discussing similarities and differences w.r.t. the ground truth data.
Assignment 2
Implement a simple image understanding application for DSET2 using the LDA model and the bag of visual terms approach described in Lecture 9. For details on how to implement the approach see the BOW demo and paper [10] referenced on the Moodle site. Keep one picture for each image subset (identified by the initial digit in the filename) out of training for testing. In short:
1. For each image (train and test) extract the SIFT descriptors for the interest points identified by the SIFT detector (you are free to use a different detector if you wish; even grid sampling).
2. Learn a 500-dimensional codebook (i.e. run k-means with k=500 clusters) from the SIFT descriptors of the training images (you can choose a subsample of them if k-means takes too long).
3. Generate the bag of visual terms for each image (train and test): use the bag of terms for the training images to train an LDA model (use one of the available implementations). Choose the number of topics as you wish (but reasonably).
4. Test the trained LDA model on test images: plot (a selection of) them with overlaid visual patches coloured with different colours depending on the most likely topic predicted by LDA.
Assignment 3
Implement from scratch an RBM and apply it to DSET3. The RBM should be implemented fully by you (both CD-1 training and inference steps) but you are free to use library functions for the rest (e.g. image loading and management, etc.).
1. Train an RBM with 100 hidden neurons (single layer) on the MNIST data (use the training set split provided by the website).
2. Use the trained RBM to encode all the images using the corresponding activation of the hidden neurons.
3. Train a simple classifier (e.g. any simple classifier in scikit) to recognize the MNIST digits using as inputs their encoding obtained at step 2. Use the standard training/test split. Show the resulting confusion matrices (training and test) in your presentation.
(Alternative to step 3, optional) Step 3 can as well be realized by placing a softmax layer after the RBM: if you are up for it, feel free to solve the assignment this way.
Assignment 4
Disclaimer: this assignment is
only for those strongly motivated to play with Bayesian Network and sampling
Once you have modelled the BN, also plug in the necessary local conditional probability tables. You can set the values of the probabilities following your own intuition on the problem (ie no need to learn them from data). Then run some episoded of Ancestral Sampling on the BN and discuss the results.
The assignment needs to be fully implemented by you, without using BN libraries.