0% found this document useful (0 votes)
22 views67 pages

CSC 245/445 Fall 2025 Programming Guide

This programming tutorial for CSC 245/445 covers essential topics such as computation resources, Python setup, and PyTorch for building deep neural networks. It includes instructions for accessing CSUG machines, setting up accounts, and configuring the class environment. The tutorial also provides guidance on using Python libraries like NumPy and OpenCV, as well as detailed steps for working with PyTorch, including tensors and model training.

Uploaded by

minulo
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)
22 views67 pages

CSC 245/445 Fall 2025 Programming Guide

This programming tutorial for CSC 245/445 covers essential topics such as computation resources, Python setup, and PyTorch for building deep neural networks. It includes instructions for accessing CSUG machines, setting up accounts, and configuring the class environment. The tutorial also provides guidance on using Python libraries like NumPy and OpenCV, as well as detailed steps for working with PyTorch, including tensors and model training.

Uploaded by

minulo
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

Programming Tutorial

CSC 245/445 Fall 2025

Andy Liu, Mingqian Feng


n Computation Resources
¨ CSUG Machine
¨ Account
¨ Class Environment
¨ Setup your VSCode
n Python
¨ Setup
¨ Language Basics
¨ Numpy and OpenCV
n PyTorch
¨ Tensors
¨ Build Model
¨ Training

2
Computation resources

3
1.1 CSUG Machine
• If you do not already have a CS instructional account, visit [Link]

4
1.2 Account

(base) pinxinliu@dhcp-10-5-173-208 ~ % ssh pliu23@[Link]


Last login: Tue Dec 26 05:42:55 2023 from [Link]
[pliu23@cycle1 ~]$

(project1) [pliu23@cycle1 ~]$ ssh pliu23@[Link]


[pliu23@gpu-node01 ~]$

You need to do a jump to access the gpu resources

SSH + your NetID + @ + cycle1 or cycle2 or cycle 3 or cycle4 +


.[Link]

SSH + your NetID + [Link] (node02, node03, node04)


5
1.3 Class Environment

source /u/cs298/anaconda3/bin/activate /u/cs298/anaconda3/envs/project1/

6
1.4 (Optional) Setup your Visual Studio Code

7
1.4 (Optional) Setup your Visual Studio Code

8
Python

9
2.1 Setup

10
11
12
13
14
Language Basics

15
16
17
18
19
20
21
22
23
24
25
26
NumPy and OpenCV

27
28
29
30
31
32
33
34
35
OpenCV

36
37
Image data structure

38
Get the bounding box

39
40
Image translation

41
Image rotation

42
3. Pytorch

Wanna build deep neural networks just like playing Lego?

PyTorch is all you need!

(1) Pythonic

(2) Dynamic Graphs

(3) Ecosystems
Source: CS231N by Fei-Fei Li & Andrej Karpathy & Justin Johnson
43
3.1 Tensors

Source: Microsoft Learn

44
3.2 Initializing a Tensor

45
3.3 Initializing a Tensor

46
3.4 Operation on Tensors

47
3.4 Operation on Tensors

48
3.4 Operation on Tensors

49
3.4 Operation on Tensors

50
3.4 Operation on Tensors

51
3.4 Operation on Tensors

52
3.4 Operation on Tensors

53
3.4 Autograd

54
3.5 Tensors, Functions and Computational graph

55
3.6 Computing Gradients

56
3.6Disabling Gradient Tracking

57
3.6 Disabling Gradient Tracking

58
Build Models

59
4.1 [Link]
(The base class for all neural network modules)

60
4.2 Get Device for Training

61
4.3 Define the Class

62
4.3 Define the Class

63
4.3 Define the Class

64
Training

65
5.1 Loss Function

66
5.2 Optimizer

67

You might also like