共计 4916 个字符,预计需要花费 13 分钟才能阅读完成。
ECS759P: ARTIFICIAL INTELLIGENCE
Coursework 2: Logic and reasoning, neural networks and classification
DUE DATE: PLEASE REFER TO THE EXACT DATE FROM QMPLUS
Instructions: The coursework is composed of two questions. The first is a writing exercise
about logic and reasoning. Only the second exercise (on classification) involves programming,
You are expected to submit one zip file ONLY through the QM+ submission link, containung:
- A single PDF file that must be at most 5 pages long. Any file submitted under the wrong
format (e.g. doc, docx, odt, etc.) or exceeding the length limit will be penalised. The
PDF can include scans of handwritten material as long as it is legible but a typewritten
version is encouraged (even better if you use LATEX). A single folder containing all your (well documented and sufficiently commented) codes.
The code should be written using Python. Your code should run (no bugs!). There must
be an easy to follow readme.txt file inside the folder.
It is allowed to use codes from online resources. However, this has to be clearly cited with
reference in your report. Collaboration is NOT permitted when attempting the answers. High
level discussion when not attempting the questions may be fine, but discouraged. A better
means is using our discussion forum on QM+. Please be aware that systems can be busy and
slow to respond shortly before deadlines. So you should aim to submit at least one hour before
the announced deadline.
Question Points Score
Crystal clear! (Logic problem) 50
Lost in the closet (Classification) 50
Total: 100
Question 1: Crystal clear! (Logic problem) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Although you are looking for it everywhere, you cannot find your true love. A bit desperate,
you decide to see Madame Irma the most famous (and serious) fortune teller of the
city. On the entrance you see a sign stating: Everything that I say must be proved to be
believed. More perplexed than ever, you still go inside. After glaring at you for some time,
she looks into her crystal ball, which has a strange glow, and says in a mysterious voice:
• You have a dog.
• The person you are looking for buys carrots by the bushel.
• Anyone who owns a rabbit hates anything that chases any rabbit.
• Every dog chases some rabbit.
• Anyone who buys carrots by the bushel owns either a rabbit or a grocery store.
• Someone who hates something owned by another person will not date that person.
The sentences you just heard reminds you of a person: Robin. But before you leave, she
challenges you with a conclusion:
• If the person you are looking for does not own a grocery, she will not date you.
Remembering the sentence at the entrance, you realise that what she has told you is true
only if you can prove her challenge conclusion. Since you don’t want any awkward situation,
you decide to provide a proof for her conclusion before going to see Robin.
(a) (10 points) Express Madame Irma’s six statements into First Order Logic (FOL).
Note: You are allowed to change the person you are looking for to Robin.
(b) (10 points) Translate the obtained expressions to Conjunctive Normal Forms (CNFs)
(c) (10 points) Transform Madame Irma’s conclusion into FOL, negate it and convert it
to a CNF.
(d) (20 points) Based on all the previously created CNF (you should have at least 7 depending
on how you split them), prove that Madame Irma is right and that you should
go to see Robin to declare to her your (logic) love.
Page 2
Question 2: Lost in the closet (Classification) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
You are an artist who secluded yourself for years to come up with the perfect design for
a new brand of clothes. However, your time off civilisation was not so beneficial since
you cannot distinguish a T-shirt from a dress or a sneaker from a sandal any more! In
order to redress (!) that issue, you choose to train a Convolutional Neural Network (using
PyTorch) that will help you identify each cloth to match the perfect design you created.
In order to train it, you decide to rely on the dataset fashion MNIST.
You can access the data using the following lines:
import torchvision
import torchvision . transforms as transforms
import torch
train_set = torchvision .datasets. FashionMNIST (root = “.”, train = True ,
download = True , transform = transforms .ToTensor ())
test_set = torchvision .datasets. FashionMNIST (root = “.”, train = False ,
download = True , transform = transforms .ToTensor ())
training_loader = torch.utils.data. DataLoader (train_set , batch_size = 32,
shuffle = False)
test_loader = torch.utils.data. DataLoader (test_set , batch_size = 32,
shuffle = False)
torch. manual_seed (0)If you are using CuDNN , otherwise you can just ignore
torch.backends.cudnn. deterministic = True
torch.backends.cudnn. benchmark = False
(a) (10 points) Given the problem, what is the most appropriate loss function to use?
(b) (15 points) Create and train a Convolutional Neural Network corresponding to the
following architecture:
For training, initialise your weights using the Xavier initialisation, use ReLU as the
activation function, a learning rate of 0.1 with the SGD optimiser. You will train your
neural network over 50 epochs. What is the final (train and test) accuracy obtained?
Provide a plot with the accuracy on the training and test set per each epoch. Looking
at the loss through the epochs, discuss what you observe.
(c) (10 points) Now, change the activation function to Tanh, Sigmoid and ELU. Provide
only the final classification accuracy. Keeping ReLU, use 5 different learning rates:
0.001, 0.1, 0.5, 1, 10. What do you observe? Explain.
(d) (15 points) Now, add a dropout of 0.3 rate on the second fully connected layer. What
is the impact of dropout on the performance? Provide the plot for training and test
after each epoch. What happens if you decrease or increase the dropout rate?