PGDIP Assignment 2: Create a Simple AI Model for Linear
Regression Using Rust Burn Library VERSION 0.16
Assignment 2
February 15, 2025
1 Objective
The goal of this assignment is to create a simple AI model for linear regression using the Rust programming
language and the burn library. The model should predict the output of the function y = 2x + 1 using
synthetic data for training. You will use the burn library version 0.16.0 and other dependencies as specified
in the provided [Link] file. You are free to use AI, documentation, and other resources to complete
the task. Once completed, submit the link to your GitHub repository on Blackboard LMS and provide a
detailed writeup in Markdown.
2 Requirements
2.1 Setup Rust and Rust Rover IDE
1. Install Rust:
• Download and install Rust from [Link]
• Verify the installation by running rustc –version in your terminal.
2. Install Rust Rover IDE:
• Download Rust Rover from [Link]
• Follow the installation instructions for your operating system.
3. Create a New Rust Project:
• Open Rust Rover and create a new project using the cargo new or you can do this on command
line and then open project in Rust Rover. For console creattion do command:
cargo new l i n e a r _ r e g r e s s i o n _ m o d e l
cd l i n e a r _ r e g r e s s i o n _ m o d e l
• Replace the contents of the [Link] file with the provided TOML configuration:
[ dependencies ]
burn = { v e r s i o n = ” 0 . 1 6 . 0 ” , f e a t u r e s = [ ” wgpu ” , ” t r a i n ” ] }
burn - ndarray = ” 0 . 1 6 . 0 ”
rand = ” 0 . 9 . 0 ”
rgb = ” 0 . 8 . 5 0 ”
textplots = ”0.8.6”
• Do not use any other content under [dependencies] in the [Link] file other than what is
above. Any changes that DON NOT match what is above under [dependencies] will result in a
score of zero marks.
4. Connect Rust Rover to GitHub:
1
• Install Git from [Link]
• In Rust Rover, go to VCS > Enable Version Control Integration and select Git.
• Create a new repository on GitHub and link it to your project. You can use command line:
git init
git remote add o r i g i n <your - github - repo - u r l >
git add .
git commit -m ” I n i t i a l commit”
git push -u o r i g i n main
2.2 Create the Linear Regression Model
1. Generate Synthetic Data:
• Create a dataset of (x, y) pairs where y = 2x + 1. Add some noise to the data to simulate
real-world conditions.
2. Define the Model:
• Use the burn library to define a simple linear regression model.
• Implement the forward pass and loss function (e.g., Mean Squared Error).
3. Train the Model:
• Use the synthetic data to train the model.
• Monitor the training process and ensure the model converges.
4. Evaluate the Model:
• Test the model on unseen data and evaluate its performance.
• Plot the results using the textplots crate.
2.3 Documentation
1. Write a Detailed README:
• Include steps to set up the project and run the code.
• Explain how you approached the problem, including any challenges you faced.
• Document the resources you used (e.g., AI tools, library documentation, tutorials).
2. Reflect on Your Learning:
• Describe how much help you received from AI, documentation, or other sources.
• If you failed to solve the problem, explain why and what you learned from the experience.
3 Submission Guidelines
1. Push your code to the GitHub repository you created.
2. Ensure the [Link] file is unchanged from what is in this document.
3. Include a detailed [Link] file in your repository where you will do your writeup.
4. Submit the link to your GitHub repository on Blackboard LMS.
5. Provide a detailed writeup in Markdown format in your [Link] file. The writeup should
include:
2
• An introduction to the problem.
• A description of your approach.
• Results and evaluation of the model.
• Reflection on your learning process.
4 Resources
• Rust Documentation: [Link]
• Burn Library Documentation: [Link]
• GitHub Guide: [Link]
• Rust Rover Documentation: [Link]
• LaTeX Documentation: [Link]
5 Evaluation Criteria
• Correct Implementation: The model should correctly predict y = 2x + 1.
• Code Quality: The code should be clean, well-structured, and documented.
• README File: The README should be detailed and reflective.
• LaTeX Writeup: The writeup should be clear, concise, and well-formatted.
• Adherence to Requirements: The [Link] file must remain unchanged as is in this document.