Question: Can you help me complete this project In this project you will train a Multilayer Perceptron on a small dataset in order to study the

Can you help me complete this project
In this project you will train a Multilayer Perceptron on a small dataset in order to study the effects of sample size and model complexity on variance and bias.
The MLP will be implemented using the PyTorch library.
The data set is a binary classification synthetic dataset generated using make_moons(n_samples=n_samples, noise=noise_level, random_state=42)
from the SciKit Learn. n_samples and noise are variables to be set.
Task one: Write the code to do the following:
1. Generates the dataset and split it into training and validation sets.
2. Designs an MLP with a single hidden layer and ReLU activation.
3. The number of hidden units is a variable.
4. Uses the cross entropy loss function.
5. Trains the model for 100 epochs and plot the training and validation losses on the same graph vs. the epoch number.
Results and Discussion:
1. Set the noise level to 1. Plot the loss for \( N=\) number of hidden units=8,\(32,128,512\) for each of the following cases: \(\mathrm{n}_{\text {_samples }}=300,3000,30000\).
2. Set the noise level to 4 and repeat.
3. Set the noise level to 8 and repeat.
Discussion: Compare and discuss the results in terms of overfitting as a function of
1. Number of samples
2. Noise level
3. Number of neurons in the hidden layer \( N \).
Task two: Add \(\ell_{2}\) regularization to your code. Plot the losses of training and validation sets for three choices of weight decay parameter, namely \(\lambda=\) weight_decay \(=1\mathrm{e}-4,1\mathrm{e}-3,1\mathrm{e}-2\) for the following cases:
1. n_samples \(=300\)
2. noise \(=1\)
3.\( N=\) number of hidden units \(=8,32,128,512\)
Discuss your results in terms of \( N \) and \(\lambda \).
Can you help me complete this project In this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!