File size: 2,305 Bytes
c165272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Install Environment (Conda) and Run Scripts

This guide sets up a Conda environment and runs both scripts:

- `assignment_image/code/c1.py` (train + save checkpoint)
- `assignment_image/code/c1_test.py` (evaluate + error analysis)

First need to enter this folder:

```bash
cd assignment_llm_1/assignment_image
```


## 1) Create and activate Conda environment

```bash
conda create -n transformer_hw python=3.10 -y
conda activate transformer_hw
python -m pip install --upgrade pip
```

## 2) Install dependencies

If there is a `requirements.txt` file in this folder, run:

```bash
pip install -r requirements.txt
```


## 3) Run training script (`c1.py`)

Move to the code directory and run:

```bash
python code/c1.py
```

Expected outputs include:

- `saved_model/vit_cifar10_best.pt`
- `saved_model/vit_cifar10_last.pt`

## 4) Run evaluation script (`c1_test.py`)

After training completes:

```bash
python code/c1_test.py \
  --checkpoint-path ./saved_model/vit_cifar10_best.pt \
  --results-dir ./results
```

This baseline evaluation run saves:

- `results/baseline_analysis.txt`
- `results/misclassified_examples_test.png`

## 5) Run optional pre-trained ViT comparison

To run transfer learning and compare baseline vs pre-trained ViT:

```bash
python code/c1_test.py \
  --checkpoint-path ./saved_model/vit_cifar10_best.pt \
  --results-dir ./results \
  --run-pretrained-experiment
```

Additional files saved in this mode:

- `results/pretrained_vit_analysis.txt`
- `results/misclassified_examples_pretrained_vit.png`
- `results/comparison_report.txt`

## 6) Where data and outputs are saved

- **Dataset download/cache**: `./data`  
  (both `c1.py` and `c1_test.py` load CIFAR-10 from this folder by default)
- **Model checkpoints from training**: `./saved_model`
- **Evaluation artifacts/reports**: `./results` (or the path passed with `--results-dir`)
- **Default checkpoint used by evaluation**: `./saved_model/vit_cifar10_best.pt`

### Quick path summary

- Training command: `python code/c1.py`
- Baseline evaluation: `python code/c1_test.py --checkpoint-path ./saved_model/vit_cifar10_best.pt --results-dir ./results`
- Baseline + transfer comparison: `python code/c1_test.py --checkpoint-path ./saved_model/vit_cifar10_best.pt --results-dir ./results --run-pretrained-experiment`