implemented wandb to classifier

This commit is contained in:
Clemens Dautermann 2020-01-26 15:42:01 +01:00
parent 8aec5e4d07
commit 1fe643d464
11 changed files with 630 additions and 7 deletions

View file

@ -0,0 +1,9 @@
wandb_version: 1
_wandb:
desc: null
value:
cli_version: 0.8.22
framework: torch
is_jupyter_run: false
python_version: 3.7.5

View file

@ -0,0 +1,64 @@
diff --git a/mnist_classifier.py b/mnist_classifier.py
index 8eac991..4578ce3 100644
--- a/mnist_classifier.py
+++ b/mnist_classifier.py
@@ -3,7 +3,10 @@ import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torchvision import transforms, datasets
+from tqdm import tqdm
+import wandb
+wandb.init(project='pytorch_ai')
train = datasets.MNIST('./datasets', train=True, download=True,
transform=transforms.Compose([
transforms.ToTensor()
@@ -37,31 +40,32 @@ class Net(nn.Module):
net = Net()
+wandb.watch(net)
loss_function = nn.CrossEntropyLoss()
optimizer = optim.Adam(net.parameters(), lr=0.001)
-for epoch in range(10): # 3 full passes over the data
- for data in trainset: # `data` is a batch of data
+for epoch in range(10): # 10 full passes over the data
+ for data in tqdm(trainset): # `data` is a batch of data
X, y = data # X is the batch of features, y is the batch of targets.
net.zero_grad() # sets gradients to 0 before loss calc. You will do this likely every step.
output = net(X.view(-1, 784)) # pass in the reshaped batch (recall they are 28x28 atm)
- loss = F.nll_loss(output, y) # calc and grab the loss value
+ loss = loss_function(output, y) # calc and grab the loss value
loss.backward() # apply this loss backwards thru the network's parameters
optimizer.step() # attempt to optimize weights to account for loss/gradients
+ wandb.log({'loss': loss})
- print(loss) # print loss. We hope loss (a measure of wrong-ness) declines!
- torch.save(net, './nets/net_' + str(epoch) + ".pt")
+ # torch.save(net, './nets/net_' + str(epoch) + ".pt")
correct = 0
total = 0
with torch.no_grad():
for data in testset:
X, y = data
output = net(X.view(-1, 784))
- # print(output)
for idx, i in enumerate(output):
- # print(torch.argmax(i), y[idx])
if torch.argmax(i) == y[idx]:
correct += 1
total += 1
+ wandb.log({'test_accuracy': correct / total})
print("Accuracy: ", round(correct / total, 3))
+ wandb.log({'epoch': epoch})
diff --git a/wandb/settings b/wandb/settings
index 8dae664..73c329e 100644
--- a/wandb/settings
+++ b/wandb/settings
@@ -1,2 +1,4 @@
[default]
+project = pytorch_ai
+entity = cdautermann

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,109 @@
apturl==0.5.2
argh==0.26.2
asn1crypto==0.24.0
bcrypt==3.1.6
binwalk==2.1.2
blinker==1.4
brlapi==0.6.7
certifi==2018.8.24
chardet==3.0.4
click==7.0
command-not-found==0.3
configparser==4.0.2
cryptography==2.6.1
cupshelpers==1.0
cycler==0.10.0
dbus-python==1.2.12
decorator==4.3.0
defer==1.0.6
distro-info==0.21ubuntu4
distro==1.3.0
docker-pycreds==0.4.0
duplicity==0.8.4
entrypoints==0.3
fasteners==0.12.0
future==0.16.0
gitdb2==2.0.6
gitpython==3.0.5
gql==0.2.0
graphql-core==1.1
httplib2==0.11.3
idna==2.6
keyring==18.0.1
keyrings.alt==3.1.1
kiwisolver==1.0.1
language-selector==0.1
launchpadlib==1.10.7
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
lockfile==0.12.2
louis==3.10.0
macaroonbakery==1.2.3
mako==1.0.7
markupsafe==1.1.0
matplotlib==3.0.2
monotonic==1.5
netifaces==0.10.4
numpy==1.16.2
nvidia-ml-py3==7.352.0
oauth==1.0.1
oauthlib==2.1.0
olefile==0.46
paramiko==2.6.0
pathtools==0.1.2
pexpect==4.6.0
pillow==6.1.0
pip==18.1
promise==2.3
protobuf==3.6.1
psutil==5.6.7
pycairo==1.16.2
pycrypto==2.6.1
pycups==1.9.73
pygments==2.3.1
pygobject==3.34.0
pyjwt==1.7.0
pymacaroons==0.13.0
pynacl==1.3.0
pyopengl==3.1.0
pyparsing==2.2.0
pyqt5==5.12.3
pyqtgraph==0.11.0.dev0
pyrfc3339==1.1
python-apt==1.9.0+ubuntu1.3
python-dateutil==2.7.3
python-debian==0.1.36
pytz==2019.2
pyxdg==0.25
pyyaml==5.1.2
reportlab==3.5.23
requests-unixsocket==0.1.5
requests==2.21.0
scipy==1.2.2
secretstorage==2.3.1
sentry-sdk==0.14.0
setuptools==41.1.0
shortuuid==0.5.0
simplejson==3.16.0
sip==4.19.18
six==1.12.0
smmap2==2.0.5
subprocess32==3.5.4
system-service==0.3
systemd-python==234
torch==1.3.1+cpu
torchvision==0.4.2+cpu
tqdm==4.41.0
ubuntu-advantage-tools==19.5
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
urllib3==1.24.1
usb-creator==0.3.7
virtualenv==15.1.0
wadllib==1.3.3
wandb==0.8.22
watchdog==0.9.0
wheel==0.32.3
xkit==0.0.0
zope.interface==4.3.2

View file

@ -0,0 +1,2 @@
{"system.cpu": 60.79, "system.memory": 41.35, "system.disk": 8.1, "system.proc.memory.availableMB": 4517.53, "system.proc.memory.rssMB": 174.98, "system.proc.memory.percent": 2.27, "system.proc.cpu.threads": 5.67, "system.network.sent": 316198, "system.network.recv": 232223, "_wandb": true, "_timestamp": 1580049687, "_runtime": 29}
{"system.cpu": 38.45, "system.memory": 41.2, "system.disk": 8.1, "system.proc.memory.availableMB": 4528.38, "system.proc.memory.rssMB": 178.53, "system.proc.memory.percent": 2.32, "system.proc.cpu.threads": 6.0, "system.network.sent": 389159, "system.network.recv": 245293, "_wandb": true, "_timestamp": 1580049691, "_runtime": 33}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,23 @@
{
"root": "/home/clemens/repositorys/pytorch-ai",
"program": "mnist_classifier.py",
"git": {
"remote": "git@github.com:Clemens-Dautermann/pytorch-ai.git",
"commit": "8aec5e4d07a210e412aaea245303788228d5cf72"
},
"email": "clemens.dautermann@gmail.com",
"startedAt": "2020-01-26T14:40:58.218384",
"host": "ubuntu-laptop",
"username": "clemens",
"executable": "/usr/bin/python3",
"os": "Linux-5.3.0-26-generic-x86_64-with-Ubuntu-19.10-eoan",
"python": "3.7.5",
"cpu_count": 2,
"args": [],
"state": "killed",
"jobType": null,
"mode": "run",
"project": "pytorch_ai",
"heartbeatAt": "2020-01-26T14:41:31.740178",
"exitcode": 255
}

File diff suppressed because one or more lines are too long