Skip to content

Commit 1cc18a6

Browse files
committed
final commit
1 parent 9668781 commit 1cc18a6

File tree

4 files changed

+61
-138
lines changed

4 files changed

+61
-138
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# transferlearning_shufflenet
1+
# Transfer Learning on ShuffleNetv2
2+
3+
- A few CNN comparisions using Tensorflow on the CIFAR-10 dataset. Show progessive improvement with use of maxpool & dropout.
4+
[CNN comparisions](./main.ipynb)
5+
6+
- Transferlearning on the ShuffleNetv2 model in Pytorch.
7+
[Transferlearning on ShuffleNet](./shuffle.ipynb)

main.ipynb

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# CNNs on CIFAR-10\n",
8+
"\n",
9+
"Comparing different CNNs performance on the CIFAR-10 Dataset\n",
10+
"- Just CNNs\n",
11+
"- Include MaxPool\n",
12+
"- Include Dropout"
13+
]
14+
},
315
{
416
"cell_type": "code",
517
"execution_count": 2,

shuffle.ipynb

+42-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Tranfer Learning over Shufflnetv2\n",
8+
"\n",
9+
"Fine Tuning a Shufflenet model (pre-trained over Imagenet) on the CIFAR-10 Dataset."
10+
]
11+
},
312
{
413
"cell_type": "code",
514
"execution_count": 2,
@@ -18,6 +27,13 @@
1827
"from torchsummary import summary\n"
1928
]
2029
},
30+
{
31+
"cell_type": "markdown",
32+
"metadata": {},
33+
"source": [
34+
"#### Training, Valiation Loop"
35+
]
36+
},
2137
{
2238
"cell_type": "code",
2339
"execution_count": 13,
@@ -47,7 +63,7 @@
4763
" outputs = model(inputs) # prediction\n",
4864
" _loss = loss(outputs, labels) # loss\n",
4965
" _, pred = torch.max(outputs, 1)\n",
50-
" \n",
66+
"\n",
5167
" # backpropr\n",
5268
" _loss.backward()\n",
5369
" optim.step()\n",
@@ -83,11 +99,11 @@
8399
" print(f'Epoch #{epoch+1}, '\n",
84100
" f'Validation Loss: {valid_loss/len(testload.dataset):.2f}, '\n",
85101
" f'Validation Acc: {valid_acc.double()/len(testload.dataset):.2f}')\n",
86-
" \n",
102+
"\n",
87103
" # Save losses for plotting\n",
88104
" train_losses.append(running_loss/len(trainload.dataset))\n",
89105
" valid_losses.append(valid_loss/len(testload.dataset))\n",
90-
" \n",
106+
"\n",
91107
" print(f'Training time: {start_time - time()}')\n",
92108
" print('Savin model')\n",
93109
" torch.save(model.state_dict(), 'my_shufflenet.pt')\n",
@@ -314,6 +330,15 @@
314330
"device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')"
315331
]
316332
},
333+
{
334+
"cell_type": "markdown",
335+
"metadata": {},
336+
"source": [
337+
"#### Freeze network params\n",
338+
"- Freeze all params in the network\n",
339+
"- Replace the final classification layer with a new one to train."
340+
]
341+
},
317342
{
318343
"cell_type": "code",
319344
"execution_count": 10,
@@ -330,6 +355,13 @@
330355
"model = model.to(device)"
331356
]
332357
},
358+
{
359+
"cell_type": "markdown",
360+
"metadata": {},
361+
"source": [
362+
"#### Default transformations"
363+
]
364+
},
333365
{
334366
"cell_type": "code",
335367
"execution_count": 11,
@@ -357,6 +389,13 @@
357389
"])"
358390
]
359391
},
392+
{
393+
"cell_type": "markdown",
394+
"metadata": {},
395+
"source": [
396+
"#### Dataloaders"
397+
]
398+
},
360399
{
361400
"cell_type": "code",
362401
"execution_count": 12,

shuffle.py

-134
This file was deleted.

0 commit comments

Comments
 (0)