# Petike and the Parametric Palette

*English translation by SOTA – AI Community of the Hungarian original. Licensed CC BY-NC-SA 4.0, like the original. Organisers who would like this translation removed can email sota.ai.community@gmail.com.*

**Magyar MI Diákolimpia** (Hungarian AI Olympiad)\
**Petike and the Parametric Palette** (Petike és a Paraméteres Paletta)\
Task description\
24 May 2025

## 1. Petike and the Parametric Palette

Petike is in the youngest group at nursery school. His favourite pastime is drawing. He has recently got to know the basic shapes **(the circle, the square and the triangle)**, and he is very enthusiastic whenever he can make drawings from them. The nursery school, however, has crayons in only a few colours, so until now Petike has used only **red, blue and green**. He gives every finished drawing to the nursery teacher, who helps him draw more and more beautifully.

The nursery teacher, however, behaves peculiarly: she never says a word, yet she always knows exactly how well a drawing turned out, and Petike can sense this too. In reality the nursery teacher is none other than a cost function, who, after every drawing, silently but firmly lets Petike know how well he did. This is how Petike learnt to draw shapes during training.

By now, however, **the training period has ended**. Petike no longer learns from new examples – he knows only what he learnt from his earlier drawings. But it is still possible to communicate with him, just not in the way one would with an ordinary nursery-school child.

Petike cannot be instructed directly, and he does not learn from new examples either. There is only one way for us to understand each other: **through his latent space**. If we give him a point there, Petike turns it into a drawing in his own style.

Fortunately, we have a few tools at hand:

- **Petike's decoder**: from this we know what he will draw on the basis of a given latent point;
- **Petike's encoder**: with this we can map existing drawings into the latent space – so, for example, if we show him an example (e.g. a red square), we can find out where Petike "imagines" it in the latent space;
- **Petike's external classifiers**: besides drawing what he imagines in the latent space, Petike can also point out what he wanted to draw.

**Your task**: explain to Petike, through the latent space, that he should draw:

- 5 different orange triangles
- 5 different magenta circles
- 5 different pictures in which the colour blue appears

## 2. Scoring

1. Implementing the helper functions – **[25 points]**
2. 5 different magenta circles – **[25 points]**
3. 5 different orange triangles – **[25 points]**
4. 5 different pictures in which the colour blue appears – **[25 points]**

**Maximum score:** 100 points

## 3. Technical information

To solve the task, the attached Notebook file and the pretrained weight file [`petike.pth`](https://drive.google.com/drive/folders/1aZ15bY6-I6T1JjtqKfr10zsNleh7iQ9X) are sufficient. The list of required libraries and the steps needed to run the notebook are described in detail at the beginning of the notebook.

After solving the task, regardless of whether you worked in Google Colab or locally, you must upload the `.ipynb` file to the CMS system for the corresponding task. No other file needs to be uploaded.

## 4. Useful resources

- 🔗 [What is a variational autoencoder?](https://www.ibm.com/think/topics/variational-autoencoder)
- 🔗 [PyTorch](https://docs.pytorch.org/docs/stable/index.html)
- 🔗 [Pillow](https://pillow.readthedocs.io/en/stable/)
- 🔗 [numpy](https://numpy.org/doc/stable/)
- 🔗 [matplotlib](https://matplotlib.org/stable/users/index.html)
