Skip to content

Commit

Permalink
Merge pull request #1267 from ArmDeveloperEcosystem/main
Browse files Browse the repository at this point in the history
Production update
  • Loading branch information
jasonrandrews authored Sep 20, 2024
2 parents 1a48d3c + 5a9f552 commit 5ea4d87
Show file tree
Hide file tree
Showing 41 changed files with 1,426 additions and 140 deletions.
75 changes: 74 additions & 1 deletion .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3114,4 +3114,77 @@ ifunc
ifuncs
lm
memcpy
multiversioning
multiversioning
AwsServerlessDynamoDbLambdaS
BLASes
BVH
Bindless
Calvo
Chowdary
CloudFormation
GDC
GLSL
Helpbox
Lista
LttE
Malhotra
Mandepudi
Nikhil
OPLTK
Rasterization
Ravi
Refractions
Rohr
RunsOn
SSR
Streamlit
TLASes
TorchAO
Torchchat
Vulkan's
Vulkanised
WebsiteBucket
aaaa
barycentric
bindless
bonza
calvo
chatbot's
createResponse
denoising
getAverageTemperatureButton
getAverageTemperatureUrl
jJyHzkWXEfY
lista
param
prismjs
quicktool
rasterization
rasterized
refractions
renderer
skybox
specular
ssr
streamlit
stylesheet
torchchat
tps
uQ
vulkan
vulkanised
writeTemperaturesUrl
IPython
NeuralNetwork
Sigmoid
Softmax
Tanh
backpropagation
diskio
feedforward
logits
prem
softmax
subclassing
tanh
torchsummary
2 changes: 1 addition & 1 deletion content/install-guides/acfl.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You are now ready to install ACfL [manually](#manual) or with [Spack](#spack).
Use an Arm recommended script to select, download, and install your preferred `ACfL` package.

```console
bash <(curl -L https://developer.arm.com/-/media/Files/downloads/hpc/arm-compiler-for-linux/install.sh)
bash <(curl -L https://developer.arm.com/-/cdn-downloads/permalink/Arm-Compiler-for-Linux/Package/install.sh)
```

## Download and install manually {#manual}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ further_reading:
title: Eigen official Tutorial on Matrix class
link: https://libeigen.gitlab.io/docs/group__TutorialMatrixClass.html
type: documentation
- resource:
title: CS Tutorial on Eigen
link: https://cs2240.graphics/assignments/eigen_tutorial.pdf
type: documentation
- resource:
title: Eigen Webinar from Linaro
link: https://static.linaro.org/connect/webinars/presentations/Eigen_Webinar_3.pdf
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Create a PyTorch model for digit classification
draft: true
cascade:
draft: true

minutes_to_complete: 40

who_is_this_for: This is an introductory topic for software developers interested in learning how to use PyTorch to create a feedforward neural network for digit classification.

learning_objectives:
- Prepare a PyTorch development environment.
- Understand the MNIST digit dataset.
- Create a neural network architecture using PyTorch.

prerequisites:
- Any computer which can run Python3 and Visual Studio Code, this can be Windows, Linux, or macOS.

author_primary: Dawid Borycki

### Tags
skilllevels: Introductory
subjects: ML
armips:
- Cortex-A
- Cortex-X
- Neoverse
operatingsystems:
- Windows
- Linux
- macOS
tools_software_languages:
- Android Studio
- Coding
shared_path: true
shared_between:
- servers-and-cloud-computing
- laptops-and-desktops
- smartphones-and-mobile

### FIXED, DO NOT MODIFY
# ================================================================================
weight: 1 # _index.md always has weight of 1 to order correctly
layout: "learningpathall" # All files under learning paths have this same wrapper
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# ================================================================================
# Edit
# ================================================================================

next_step_guidance: >
Proceed to Get Started with Arm Performance Studio for mobile to continue learning about Android performance analysis.
# 1-3 sentence recommendation outlining how the reader can generally keep learning about these topics, and a specific explanation of why the next step is being recommended.

recommended_path: "/learning-paths/smartphones-and-mobile/ams/"

# Link to the next learning path being recommended(For example this could be /learning-paths/servers-and-cloud-computing/mongodb).


# further_reading links to references related to this path. Can be:
# Manuals for a tool / software mentioned (type: documentation)
# Blog about related topics (type: blog)
# General online references (type: website)

further_reading:
- resource:
title: PyTorch
link: https://pytorch.org
type: documentation
- resource:
title: MNIST
link: https://en.wikipedia.org/wiki/MNIST_database
type: website
- resource:
title: Visual Studio Code
link: https://code.visualstudio.com
type: website



# ================================================================================
# FIXED, DO NOT MODIFY
# ================================================================================
weight: 21 # set to always be larger than the content in this path, and one more than 'review'
title: "Next Steps" # Always the same
layout: "learningpathall" # All files under learning paths have this same wrapper
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# ================================================================================
# Edit
# ================================================================================

# Always 3 questions. Should try to test the reader's knowledge, and reinforce the key points you want them to remember.
# question: A one sentence question
# answers: The correct answers (from 2-4 answer options only). Should be surrounded by quotes.
# correct_answer: An integer indicating what answer is correct (index starts from 0)
# explanation: A short (1-3 sentence) explanation of why the correct answer is correct. Can add additional context if desired


review:
- questions:
question: >
Does the input layer of the model flatten the 28x28 pixel image into a 1D array of 784 elements?
answers:
- "Yes"
- "No"
correct_answer: 1
explanation: >
Yes, the model uses nn.Flatten() to reshape the 28x28 pixel image into a 1D array of 784 elements for processing by the fully connected layers.
- questions:
question: >
Does the model use dropout layers with a 20% dropout rate after each hidden layer?
answers:
- "Yes"
- "No"
correct_answer: 1
explanation: >
Yes, the model applies dropout layers after each hidden layer, randomly setting 20% of the neurons to 0 during training to prevent overfitting.
- questions:
question: >
Will the model make random predictions if it’s run before training?
answers:
- "Yes"
- "No"
correct_answer: 1
explanation: >
Yes, however in such the case the model will produce random outputs, as the network has not been trained to recognize any patterns from the data.
# ================================================================================
# FIXED, DO NOT MODIFY
# ================================================================================
title: "Review" # Always the same title
weight: 20 # Set to always be larger than the content in this path
layout: "learningpathall" # All files under learning paths have this same wrapper
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
# User change
title: "Prepare a PyTorch development environment"

weight: 2

layout: "learningpathall"
---

## Background

PyTorch is an open-source deep learning framework developed by Meta AI and now part of the Linux Foundation.

It is designed to provide a flexible and efficient platform for building and training neural networks. It is widely used due to its dynamic computational graph, which allows users to modify the architecture during runtime, making debugging and experimentation easier.

The major motivation for introducing PyTorch was to provide a more flexible, user-friendly deep learning framework that addressed the limitations of static computational graphs found in earlier tools like TensorFlow.

Prior to PyTorch, many frameworks used static computation graphs that required the entire model structure to be defined before training, making experimentation and debugging more cumbersome. PyTorch introduced dynamic computational graphs (also known as “define-by-run”), which allow the graph to be constructed on the fly as operations are executed. This flexibility significantly improved ease of use for researchers and developers, enabling faster prototyping, easier debugging, and more intuitive code.


Additionally, PyTorch was designed to have seamless integration with Python, encouraging a more native coding experience. Its deep integration with GPU acceleration also made it a powerful tool for both research and production environments. This combination of flexibility, usability, and performance contributed to PyTorch’s rapid adoption, especially in academic research, where experimentation and iteration are crucial.

A typical process for creating a feedforward neural network in PyTorch involves defining a sequential stack of fully connected layers (also known as linear layers). Each layer transforms the input by applying a set of weights and biases, followed by an activation function like ReLU. PyTorch supports this process using the torch.nn module, where layers are easily defined and composed.

To create a model, users subclass the torch.nn.Module class, defining the network architecture in the __init__ method, and implement the forward pass in the forward method. PyTorch’s intuitive API and strong support for GPU acceleration make it ideal for building efficient feedforward networks, particularly in tasks like image classification and digit recognition.

In this Learning Path, you will explore how to use PyTorch for creating a model for digit recognition.

## Before you begin

Before you begin make sure Python3 is installed on your system. You can check by running:

```console
python3 --version
```

The expected output is the Python version, for example:

```output
Python 3.11.2
```

If Python3 is not installed, download and install it from [python.org](https://www.python.org/downloads/).

Alternatively, you can also install Python3 using package managers such as Brew or APT.

If you are using Windows on Arm you can refer to the [Python install guide](https://learn.arm.com/install-guides/py-woa/).

Next, download and install [Visual Studio Code](https://code.visualstudio.com/download).

## Install PyTorch and additional Python packages

To prepare a virtual Python environment, install PyTorch, and the additional tools you will need for this Learning Path:

1. Open a terminal or command prompt and navigate to your project directory.

2. Create a virtual environment by running:

```console
python -m venv pytorch-env
```

This will create a virtual environment named pytorch-env.

3. Activate the virtual environment:

* On Windows:
```console
pytorch-env\Scripts\activate
```

* On macOS or Linux:
```console
source pytorch-env/bin/activate
```

Once activated, you should see the virtual environment name in your terminal prompt.

3. Install PyTorch using `pip`:

```console
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
```

4. Install torchsummary, Jupyter and IPython Kernel:

```console
pip install torchsummary
pip install jupyter
pip install ipykernel
```

5. Register your virtual environment as a new kernel:

```console
python3 -m ipykernel install --user --name=pytorch-env
```

6. Install the Jupyter Extension in VS Code:

* Open VS Code and go to the Extensions view (click on the Extensions icon or press Ctrl+Shift+X).

* Search for “Jupyter” and install the official Jupyter extension.

* Optionally, also install the Python extension if you haven’t already, as it improves Python language support in VS Code.

To ensure everything is set up correctly:

1. Open Visual Studio Code.
2. Click New file, and select `Jupyter Notebook .ipynb Support`.
3. Save the file as `pytorch-digits.ipynb`.
4. Select the Python kernel you created earlier (pytorch-env). To do so, click Kernels in the top right corner. Then, click Jupyter Kernel..., and you will see the Python kernel as shown below:

![img1](Figures/01.png)

5. In your Jupyter notebook, run the following code to verify PyTorch is working correctly:

```console
import torch
print(torch.__version__)
```

It will look as follows:
![img2](Figures/02.png)

With your development environment created you can proceed to creating a PyTorch model.
Loading

0 comments on commit 5ea4d87

Please sign in to comment.