0% found this document useful (0 votes)
7 views1 page

TP2 - (AAr)

The document outlines exercises for implementing functions related to machine learning models, including a function for computing the dot product of two vectors and the logistic regression model. It also covers linear regression, specifically how to compute the loss function, and tasks related to visualizing Boolean functions and creating classifiers for AND, OR, and XOR operations. Additionally, it discusses the use of a Multi Layer Perceptron (MLP) for the XOR operator with different activation functions.

Uploaded by

marwa BEN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

TP2 - (AAr)

The document outlines exercises for implementing functions related to machine learning models, including a function for computing the dot product of two vectors and the logistic regression model. It also covers linear regression, specifically how to compute the loss function, and tasks related to visualizing Boolean functions and creating classifiers for AND, OR, and XOR operations. Additionally, it discusses the use of a Multi Layer Perceptron (MLP) for the XOR operator with different activation functions.

Uploaded by

marwa BEN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Module Aar

M1_ IA

Exercise 1 :

a. Given two vectors x and y of the same size, write a function that compute the sum of
x[i]*y[i] for all indices i.

b. Implement the logistic model which is used in Machine Learning to perform binary
classification. Mathematically, it is defined as

Note that x and w vectors don't have the same length. So, get around this by using one of
following tricks:
- Insert 1 at the beginning of x , and multiply it with w .
- Slice w by removing its first element w[0] , multiply the remaining elements
w[1], ..., w[Q] with x , and then add w[0] to the result.

Exercise 2 :
Linear regression is a machine learning technique that aims at predicting a continuous output
by using a parametric linear model :

w is a parameter vector to be learned from a set of input-output pairs {(xn ,yn)}. Mathematically,
the learning is equivalent to minimize the following loss function to evaluate the performance
of the model :

Implement the function that computes the loss given three inputs : the matrix X storing all the
inputs, the parameter vector w, the vector y with all the outputs.

Exercise 3 :

a. Schematize in a 2D plane, the 4 points for each Boolean function (AND, OR, XOR).
b. For each 2D plane, separate the 4 points by a single line.
c. Define a classifier without any hidden layer and a linear activation for each of the operators
AND, OR and XOR.
Check the results predicted by the classifier if they are correct.
d. In the case of the XOR operator, define a classifier based on a Multi Layer Percetron (MLP).
For its training use the following two cases: (a) linear activation. (b) Functions of non-linear
activations.

You might also like