Stuff
This commit is contained in:
parent
da87b5f0c3
commit
e3c8d97386
@ -19,7 +19,7 @@ pipeline {
|
||||
stage('Load Artifact') {
|
||||
steps {
|
||||
script {
|
||||
copyArtifacts fingerprintArtifacts: true, projectName: 's452627-training', selector: buildParameter("BUILD_SELECTOR")
|
||||
copyArtifacts fingerprintArtifacts: true, projectName: 's452627-training/master/', selector: buildParameter("BUILD_SELECTOR")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
cifar_net.pth
BIN
cifar_net.pth
Binary file not shown.
5
my_runs/1/config.json
Normal file
5
my_runs/1/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"epochs": 10,
|
||||
"learning_rate": 0.001,
|
||||
"seed": 577991242
|
||||
}
|
1
my_runs/1/cout.txt
Normal file
1
my_runs/1/cout.txt
Normal file
@ -0,0 +1 @@
|
||||
10 0.001
|
1
my_runs/1/metrics.json
Normal file
1
my_runs/1/metrics.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
90
my_runs/1/run.json
Normal file
90
my_runs/1/run.json
Normal file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"artifacts": [],
|
||||
"command": "my_main",
|
||||
"experiment": {
|
||||
"base_dir": "e:\\Pyton\\IUM\\ium_452627",
|
||||
"dependencies": [
|
||||
"numpy==1.20.0",
|
||||
"pandas==1.4.1",
|
||||
"sacred==0.8.4",
|
||||
"torch==1.8.1+cu102",
|
||||
"torchvision==0.9.1+cu102"
|
||||
],
|
||||
"mainfile": "sacred_train.py",
|
||||
"name": "sacred_scopes",
|
||||
"repositories": [
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": false,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
},
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": false,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
}
|
||||
],
|
||||
"sources": [
|
||||
[
|
||||
"sacred_train.py",
|
||||
"_sources\\sacred_train_69457f4c158c0d7ad12c17d05b383cdb.py"
|
||||
],
|
||||
[
|
||||
"zadanie1.py",
|
||||
"_sources\\zadanie1_214ad86c108ac00197ed071c54ee3658.py"
|
||||
]
|
||||
]
|
||||
},
|
||||
"heartbeat": "2023-05-11T17:46:55.740189",
|
||||
"host": {
|
||||
"ENV": {},
|
||||
"cpu": "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz",
|
||||
"gpus": {
|
||||
"driver_version": "472.12",
|
||||
"gpus": [
|
||||
{
|
||||
"model": "NVIDIA GeForce GTX 1070",
|
||||
"persistence_mode": false,
|
||||
"total_memory": 8192
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostname": "JAKUB-HENYK",
|
||||
"os": [
|
||||
"Windows",
|
||||
"Windows-10-10.0.19041-SP0"
|
||||
],
|
||||
"python_version": "3.8.3"
|
||||
},
|
||||
"meta": {
|
||||
"command": "my_main",
|
||||
"named_configs": [],
|
||||
"options": {
|
||||
"--beat-interval": null,
|
||||
"--capture": null,
|
||||
"--comment": null,
|
||||
"--debug": false,
|
||||
"--enforce_clean": false,
|
||||
"--file_storage": null,
|
||||
"--force": false,
|
||||
"--help": false,
|
||||
"--id": null,
|
||||
"--loglevel": null,
|
||||
"--mongo_db": null,
|
||||
"--name": null,
|
||||
"--pdb": false,
|
||||
"--print-config": false,
|
||||
"--priority": null,
|
||||
"--queue": false,
|
||||
"--s3": null,
|
||||
"--sql": null,
|
||||
"--tiny_db": null,
|
||||
"--unobserved": false
|
||||
}
|
||||
},
|
||||
"resources": [],
|
||||
"result": null,
|
||||
"start_time": "2023-05-11T17:46:55.705192",
|
||||
"status": "COMPLETED",
|
||||
"stop_time": "2023-05-11T17:46:55.740189"
|
||||
}
|
5
my_runs/2/config.json
Normal file
5
my_runs/2/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"epochs": 10,
|
||||
"learning_rate": 0.001,
|
||||
"seed": 330865802
|
||||
}
|
0
my_runs/2/cout.txt
Normal file
0
my_runs/2/cout.txt
Normal file
1
my_runs/2/metrics.json
Normal file
1
my_runs/2/metrics.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
97
my_runs/2/run.json
Normal file
97
my_runs/2/run.json
Normal file
@ -0,0 +1,97 @@
|
||||
{
|
||||
"artifacts": [],
|
||||
"command": "my_main",
|
||||
"experiment": {
|
||||
"base_dir": "e:\\Pyton\\IUM\\ium_452627",
|
||||
"dependencies": [
|
||||
"numpy==1.20.0",
|
||||
"pandas==1.4.1",
|
||||
"sacred==0.8.4",
|
||||
"torch==1.8.1+cu102",
|
||||
"torchvision==0.9.1+cu102"
|
||||
],
|
||||
"mainfile": "sacred_train.py",
|
||||
"name": "sacred_scopes",
|
||||
"repositories": [
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": false,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
},
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": false,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
}
|
||||
],
|
||||
"sources": [
|
||||
[
|
||||
"sacred_train.py",
|
||||
"_sources\\sacred_train_b6fddd734c43fc70e41befe914387fe7.py"
|
||||
],
|
||||
[
|
||||
"zadanie1.py",
|
||||
"_sources\\zadanie1_214ad86c108ac00197ed071c54ee3658.py"
|
||||
]
|
||||
]
|
||||
},
|
||||
"fail_trace": [
|
||||
"Traceback (most recent call last):\n",
|
||||
" File \"C:\\Users\\kubak\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\sacred\\config\\captured_function.py\", line 42, in captured_function\n result = wrapped(*args, **kwargs)\n",
|
||||
" File \"e:/Pyton/IUM/ium_452627/sacred_train.py\", line 87, in my_main\n trainNet(trainloader, criterion, optimizer, int(float(epochs)))\n",
|
||||
" File \"e:/Pyton/IUM/ium_452627/sacred_train.py\", line 46, in trainNet\n outputs = net(inputs)\n",
|
||||
"NameError: name 'net' is not defined\n"
|
||||
],
|
||||
"heartbeat": "2023-05-11T17:51:09.781453",
|
||||
"host": {
|
||||
"ENV": {},
|
||||
"cpu": "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz",
|
||||
"gpus": {
|
||||
"driver_version": "472.12",
|
||||
"gpus": [
|
||||
{
|
||||
"model": "NVIDIA GeForce GTX 1070",
|
||||
"persistence_mode": false,
|
||||
"total_memory": 8192
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostname": "JAKUB-HENYK",
|
||||
"os": [
|
||||
"Windows",
|
||||
"Windows-10-10.0.19041-SP0"
|
||||
],
|
||||
"python_version": "3.8.3"
|
||||
},
|
||||
"meta": {
|
||||
"command": "my_main",
|
||||
"named_configs": [],
|
||||
"options": {
|
||||
"--beat-interval": null,
|
||||
"--capture": null,
|
||||
"--comment": null,
|
||||
"--debug": false,
|
||||
"--enforce_clean": false,
|
||||
"--file_storage": null,
|
||||
"--force": false,
|
||||
"--help": false,
|
||||
"--id": null,
|
||||
"--loglevel": null,
|
||||
"--mongo_db": null,
|
||||
"--name": null,
|
||||
"--pdb": false,
|
||||
"--print-config": false,
|
||||
"--priority": null,
|
||||
"--queue": false,
|
||||
"--s3": null,
|
||||
"--sql": null,
|
||||
"--tiny_db": null,
|
||||
"--unobserved": false
|
||||
}
|
||||
},
|
||||
"resources": [],
|
||||
"result": null,
|
||||
"start_time": "2023-05-11T17:51:03.476454",
|
||||
"status": "FAILED",
|
||||
"stop_time": "2023-05-11T17:51:09.782454"
|
||||
}
|
BIN
my_runs/3/cifar_net.pth
Normal file
BIN
my_runs/3/cifar_net.pth
Normal file
Binary file not shown.
5
my_runs/3/config.json
Normal file
5
my_runs/3/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"epochs": 10,
|
||||
"learning_rate": 0.001,
|
||||
"seed": 567277158
|
||||
}
|
1
my_runs/3/cout.txt
Normal file
1
my_runs/3/cout.txt
Normal file
@ -0,0 +1 @@
|
||||
Finished Training
|
1
my_runs/3/metrics.json
Normal file
1
my_runs/3/metrics.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
92
my_runs/3/run.json
Normal file
92
my_runs/3/run.json
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"artifacts": [
|
||||
"cifar_net.pth"
|
||||
],
|
||||
"command": "my_main",
|
||||
"experiment": {
|
||||
"base_dir": "e:\\Pyton\\IUM\\ium_452627",
|
||||
"dependencies": [
|
||||
"numpy==1.20.0",
|
||||
"pandas==1.4.1",
|
||||
"sacred==0.8.4",
|
||||
"torch==1.8.1+cu102",
|
||||
"torchvision==0.9.1+cu102"
|
||||
],
|
||||
"mainfile": "sacred_train.py",
|
||||
"name": "sacred_scopes",
|
||||
"repositories": [
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": false,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
},
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": false,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
}
|
||||
],
|
||||
"sources": [
|
||||
[
|
||||
"sacred_train.py",
|
||||
"_sources\\sacred_train_f2e895e7d4eaf1570420fc943ad98f4b.py"
|
||||
],
|
||||
[
|
||||
"zadanie1.py",
|
||||
"_sources\\zadanie1_214ad86c108ac00197ed071c54ee3658.py"
|
||||
]
|
||||
]
|
||||
},
|
||||
"heartbeat": "2023-05-11T17:52:55.082803",
|
||||
"host": {
|
||||
"ENV": {},
|
||||
"cpu": "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz",
|
||||
"gpus": {
|
||||
"driver_version": "472.12",
|
||||
"gpus": [
|
||||
{
|
||||
"model": "NVIDIA GeForce GTX 1070",
|
||||
"persistence_mode": false,
|
||||
"total_memory": 8192
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostname": "JAKUB-HENYK",
|
||||
"os": [
|
||||
"Windows",
|
||||
"Windows-10-10.0.19041-SP0"
|
||||
],
|
||||
"python_version": "3.8.3"
|
||||
},
|
||||
"meta": {
|
||||
"command": "my_main",
|
||||
"named_configs": [],
|
||||
"options": {
|
||||
"--beat-interval": null,
|
||||
"--capture": null,
|
||||
"--comment": null,
|
||||
"--debug": false,
|
||||
"--enforce_clean": false,
|
||||
"--file_storage": null,
|
||||
"--force": false,
|
||||
"--help": false,
|
||||
"--id": null,
|
||||
"--loglevel": null,
|
||||
"--mongo_db": null,
|
||||
"--name": null,
|
||||
"--pdb": false,
|
||||
"--print-config": false,
|
||||
"--priority": null,
|
||||
"--queue": false,
|
||||
"--s3": null,
|
||||
"--sql": null,
|
||||
"--tiny_db": null,
|
||||
"--unobserved": false
|
||||
}
|
||||
},
|
||||
"resources": [],
|
||||
"result": null,
|
||||
"start_time": "2023-05-11T17:51:55.172453",
|
||||
"status": "COMPLETED",
|
||||
"stop_time": "2023-05-11T17:52:55.082803"
|
||||
}
|
BIN
my_runs/4/cifar_net.pth
Normal file
BIN
my_runs/4/cifar_net.pth
Normal file
Binary file not shown.
5
my_runs/4/config.json
Normal file
5
my_runs/4/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"epochs": 10,
|
||||
"learning_rate": 0.001,
|
||||
"seed": 149208276
|
||||
}
|
1
my_runs/4/cout.txt
Normal file
1
my_runs/4/cout.txt
Normal file
@ -0,0 +1 @@
|
||||
Finished Training
|
49610
my_runs/4/metrics.json
Normal file
49610
my_runs/4/metrics.json
Normal file
File diff suppressed because it is too large
Load Diff
97
my_runs/4/run.json
Normal file
97
my_runs/4/run.json
Normal file
@ -0,0 +1,97 @@
|
||||
{
|
||||
"artifacts": [
|
||||
"cifar_net.pth"
|
||||
],
|
||||
"command": "my_main",
|
||||
"experiment": {
|
||||
"base_dir": "e:\\Pyton\\IUM\\ium_452627",
|
||||
"dependencies": [
|
||||
"numpy==1.20.0",
|
||||
"pandas==1.4.1",
|
||||
"sacred==0.8.4",
|
||||
"torch==1.8.1+cu102",
|
||||
"torchvision==0.9.1+cu102"
|
||||
],
|
||||
"mainfile": "sacred_train.py",
|
||||
"name": "s452627",
|
||||
"repositories": [
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": true,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
},
|
||||
{
|
||||
"commit": "da87b5f0c3566577958feaa4005909d12ce8f0c7",
|
||||
"dirty": true,
|
||||
"url": "git@git.wmi.amu.edu.pl:s452627/ium_452627.git"
|
||||
}
|
||||
],
|
||||
"sources": [
|
||||
[
|
||||
"sacred_train.py",
|
||||
"_sources\\sacred_train_9b02b8fd3ddb3f4ddfc9a057f76bf6a2.py"
|
||||
],
|
||||
[
|
||||
"zadanie1.py",
|
||||
"_sources\\zadanie1_214ad86c108ac00197ed071c54ee3658.py"
|
||||
]
|
||||
]
|
||||
},
|
||||
"heartbeat": "2023-05-11T18:07:52.077252",
|
||||
"host": {
|
||||
"ENV": {},
|
||||
"cpu": "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz",
|
||||
"gpus": {
|
||||
"driver_version": "472.12",
|
||||
"gpus": [
|
||||
{
|
||||
"model": "NVIDIA GeForce GTX 1070",
|
||||
"persistence_mode": false,
|
||||
"total_memory": 8192
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostname": "JAKUB-HENYK",
|
||||
"os": [
|
||||
"Windows",
|
||||
"Windows-10-10.0.19041-SP0"
|
||||
],
|
||||
"python_version": "3.8.3"
|
||||
},
|
||||
"meta": {
|
||||
"command": "my_main",
|
||||
"named_configs": [],
|
||||
"options": {
|
||||
"--beat-interval": null,
|
||||
"--capture": null,
|
||||
"--comment": null,
|
||||
"--debug": false,
|
||||
"--enforce_clean": false,
|
||||
"--file_storage": null,
|
||||
"--force": false,
|
||||
"--help": false,
|
||||
"--id": null,
|
||||
"--loglevel": null,
|
||||
"--mongo_db": null,
|
||||
"--name": null,
|
||||
"--pdb": false,
|
||||
"--print-config": false,
|
||||
"--priority": null,
|
||||
"--queue": false,
|
||||
"--s3": null,
|
||||
"--sql": null,
|
||||
"--tiny_db": null,
|
||||
"--unobserved": false
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
[
|
||||
"E:\\Pyton\\IUM\\ium_452627\\Customers.csv",
|
||||
"my_runs\\_resources\\Customers_6514be2808e61a30190fa6265e2352da.csv"
|
||||
]
|
||||
],
|
||||
"result": null,
|
||||
"start_time": "2023-05-11T18:06:52.739065",
|
||||
"status": "COMPLETED",
|
||||
"stop_time": "2023-05-11T18:07:52.077252"
|
||||
}
|
2001
my_runs/_resources/Customers_6514be2808e61a30190fa6265e2352da.csv
Normal file
2001
my_runs/_resources/Customers_6514be2808e61a30190fa6265e2352da.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import zadanie1 as z
|
||||
import torch
|
||||
import torchvision
|
||||
import torchvision.transforms as transforms
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import torch.optim as optim
|
||||
from sacred import Experiment
|
||||
from sacred.observers import FileStorageObserver
|
||||
|
||||
class Net(nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#self.conv1 = nn.Conv2d(3, 6, 5)
|
||||
#self.pool = nn.MaxPool2d(2, 2)
|
||||
#self.conv2 = nn.Conv2d(6, 16, 5)
|
||||
#self.fc1 = nn.Linear(16 * 5 * 5, 120)
|
||||
#self.fc2 = nn.Linear(20, 6)
|
||||
self.fc3 = nn.Linear(6, 6)
|
||||
|
||||
def forward(self, x):
|
||||
#x = self.pool(F.relu(self.conv1(x)))
|
||||
#x = self.pool(F.relu(self.conv2(x)))
|
||||
#x = torch.flatten(x, 1)
|
||||
#x = F.relu(self.fc1(x))
|
||||
#x = F.relu(self.fc2(x))
|
||||
x = self.fc3(x)
|
||||
return x
|
||||
|
||||
|
||||
def trainNet(trainloader, criterion, optimizer, epochs=20):
|
||||
for epoch in range(epochs):
|
||||
|
||||
for i, data in enumerate(trainloader, 0):
|
||||
inputs, labels = data
|
||||
|
||||
labelsX = torch.Tensor([x for x in labels])
|
||||
labels = labelsX.type(torch.LongTensor)
|
||||
|
||||
optimizer.zero_grad()
|
||||
|
||||
outputs = net(inputs)
|
||||
|
||||
loss = criterion(outputs, labels)
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
|
||||
print('Finished Training')
|
||||
|
||||
ex = Experiment("sacred_scopes", interactive=True)
|
||||
ex.observers.append(FileStorageObserver('my_runs'))
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
epochs = 10
|
||||
learning_rate = 0.001
|
||||
|
||||
@ex.main
|
||||
def my_main(epochs, learning_rate):
|
||||
print(f'{epochs} {learning_rate}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
ex.run()
|
||||
train, dev, test = z.prepareData()
|
||||
|
||||
batch_size = 4
|
||||
|
||||
trainlist = train.values.tolist()
|
||||
testlist = test.values.tolist()
|
||||
|
||||
trainset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in trainlist]
|
||||
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
|
||||
shuffle=True, num_workers=2)
|
||||
|
||||
testset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in testlist]
|
||||
testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size,
|
||||
shuffle=False, num_workers=2)
|
||||
|
||||
classes = ('male', 'female')
|
||||
|
||||
net = Net()
|
||||
|
||||
criterion = nn.CrossEntropyLoss()
|
||||
optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)
|
||||
|
||||
#trainNet(trainloader, criterion, optimizer, int(float(epochs)))
|
||||
|
||||
#PATH = './cifar_net.pth'
|
||||
#torch.save(net.state_dict(), PATH)
|
||||
|
@ -0,0 +1,103 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import zadanie1 as z
|
||||
import torch
|
||||
import torchvision
|
||||
import torchvision.transforms as transforms
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import torch.optim as optim
|
||||
from sacred import Experiment
|
||||
from sacred.observers import FileStorageObserver
|
||||
from sacred.observers import MongoObserver
|
||||
|
||||
class Net(nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#self.conv1 = nn.Conv2d(3, 6, 5)
|
||||
#self.pool = nn.MaxPool2d(2, 2)
|
||||
#self.conv2 = nn.Conv2d(6, 16, 5)
|
||||
#self.fc1 = nn.Linear(16 * 5 * 5, 120)
|
||||
#self.fc2 = nn.Linear(20, 6)
|
||||
self.fc3 = nn.Linear(6, 6)
|
||||
|
||||
def forward(self, x):
|
||||
#x = self.pool(F.relu(self.conv1(x)))
|
||||
#x = self.pool(F.relu(self.conv2(x)))
|
||||
#x = torch.flatten(x, 1)
|
||||
#x = F.relu(self.fc1(x))
|
||||
#x = F.relu(self.fc2(x))
|
||||
x = self.fc3(x)
|
||||
return x
|
||||
|
||||
|
||||
def trainNet(_run, trainloader, criterion, optimizer, net, epochs=20):
|
||||
for epoch in range(epochs):
|
||||
|
||||
for i, data in enumerate(trainloader, 0):
|
||||
inputs, labels = data
|
||||
|
||||
labelsX = torch.Tensor([x for x in labels])
|
||||
labels = labelsX.type(torch.LongTensor)
|
||||
|
||||
optimizer.zero_grad()
|
||||
|
||||
outputs = net(inputs)
|
||||
|
||||
loss = criterion(outputs, labels)
|
||||
|
||||
_run.log_scalar("training.loss", loss)
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
|
||||
print('Finished Training')
|
||||
|
||||
ex = Experiment("s452627", interactive=True)
|
||||
ex.observers.append(FileStorageObserver('my_runs'))
|
||||
#ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
epochs = 10
|
||||
learning_rate = 0.001
|
||||
|
||||
@ex.main
|
||||
def my_main(epochs, learning_rate, _run):
|
||||
|
||||
ex.open_resource("Customers.csv", "r")
|
||||
|
||||
train, dev, test = z.prepareData()
|
||||
|
||||
batch_size = 4
|
||||
|
||||
trainlist = train.values.tolist()
|
||||
testlist = test.values.tolist()
|
||||
|
||||
trainset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in trainlist]
|
||||
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
|
||||
shuffle=True, num_workers=2)
|
||||
|
||||
testset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in testlist]
|
||||
testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size,
|
||||
shuffle=False, num_workers=2)
|
||||
|
||||
classes = ('male', 'female')
|
||||
|
||||
net = Net()
|
||||
|
||||
criterion = nn.CrossEntropyLoss()
|
||||
optimizer = optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9)
|
||||
|
||||
trainNet(_run, trainloader, criterion, optimizer, net, int(float(epochs)))
|
||||
|
||||
PATH = './cifar_net.pth'
|
||||
torch.save(net.state_dict(), PATH)
|
||||
|
||||
ex.add_artifact("cifar_net.pth")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
ex.run()
|
||||
|
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import zadanie1 as z
|
||||
import torch
|
||||
import torchvision
|
||||
import torchvision.transforms as transforms
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import torch.optim as optim
|
||||
from sacred import Experiment
|
||||
from sacred.observers import FileStorageObserver
|
||||
|
||||
class Net(nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#self.conv1 = nn.Conv2d(3, 6, 5)
|
||||
#self.pool = nn.MaxPool2d(2, 2)
|
||||
#self.conv2 = nn.Conv2d(6, 16, 5)
|
||||
#self.fc1 = nn.Linear(16 * 5 * 5, 120)
|
||||
#self.fc2 = nn.Linear(20, 6)
|
||||
self.fc3 = nn.Linear(6, 6)
|
||||
|
||||
def forward(self, x):
|
||||
#x = self.pool(F.relu(self.conv1(x)))
|
||||
#x = self.pool(F.relu(self.conv2(x)))
|
||||
#x = torch.flatten(x, 1)
|
||||
#x = F.relu(self.fc1(x))
|
||||
#x = F.relu(self.fc2(x))
|
||||
x = self.fc3(x)
|
||||
return x
|
||||
|
||||
|
||||
def trainNet(trainloader, criterion, optimizer, epochs=20):
|
||||
for epoch in range(epochs):
|
||||
|
||||
for i, data in enumerate(trainloader, 0):
|
||||
inputs, labels = data
|
||||
|
||||
labelsX = torch.Tensor([x for x in labels])
|
||||
labels = labelsX.type(torch.LongTensor)
|
||||
|
||||
optimizer.zero_grad()
|
||||
|
||||
outputs = net(inputs)
|
||||
|
||||
loss = criterion(outputs, labels)
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
|
||||
print('Finished Training')
|
||||
|
||||
ex = Experiment("sacred_scopes", interactive=True)
|
||||
ex.observers.append(FileStorageObserver('my_runs'))
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
epochs = 10
|
||||
learning_rate = 0.001
|
||||
|
||||
@ex.main
|
||||
def my_main(epochs, learning_rate):
|
||||
|
||||
train, dev, test = z.prepareData()
|
||||
|
||||
batch_size = 4
|
||||
|
||||
trainlist = train.values.tolist()
|
||||
testlist = test.values.tolist()
|
||||
|
||||
trainset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in trainlist]
|
||||
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
|
||||
shuffle=True, num_workers=2)
|
||||
|
||||
testset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in testlist]
|
||||
testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size,
|
||||
shuffle=False, num_workers=2)
|
||||
|
||||
classes = ('male', 'female')
|
||||
|
||||
net = Net()
|
||||
|
||||
criterion = nn.CrossEntropyLoss()
|
||||
optimizer = optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9)
|
||||
|
||||
trainNet(trainloader, criterion, optimizer, int(float(epochs)))
|
||||
|
||||
PATH = './cifar_net.pth'
|
||||
torch.save(net.state_dict(), PATH)
|
||||
ex.add_artifact("cifar_net.pth")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
ex.run()
|
||||
|
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import zadanie1 as z
|
||||
import torch
|
||||
import torchvision
|
||||
import torchvision.transforms as transforms
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import torch.optim as optim
|
||||
from sacred import Experiment
|
||||
from sacred.observers import FileStorageObserver
|
||||
|
||||
class Net(nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#self.conv1 = nn.Conv2d(3, 6, 5)
|
||||
#self.pool = nn.MaxPool2d(2, 2)
|
||||
#self.conv2 = nn.Conv2d(6, 16, 5)
|
||||
#self.fc1 = nn.Linear(16 * 5 * 5, 120)
|
||||
#self.fc2 = nn.Linear(20, 6)
|
||||
self.fc3 = nn.Linear(6, 6)
|
||||
|
||||
def forward(self, x):
|
||||
#x = self.pool(F.relu(self.conv1(x)))
|
||||
#x = self.pool(F.relu(self.conv2(x)))
|
||||
#x = torch.flatten(x, 1)
|
||||
#x = F.relu(self.fc1(x))
|
||||
#x = F.relu(self.fc2(x))
|
||||
x = self.fc3(x)
|
||||
return x
|
||||
|
||||
|
||||
def trainNet(trainloader, criterion, optimizer, net, epochs=20):
|
||||
for epoch in range(epochs):
|
||||
|
||||
for i, data in enumerate(trainloader, 0):
|
||||
inputs, labels = data
|
||||
|
||||
labelsX = torch.Tensor([x for x in labels])
|
||||
labels = labelsX.type(torch.LongTensor)
|
||||
|
||||
optimizer.zero_grad()
|
||||
|
||||
outputs = net(inputs)
|
||||
|
||||
loss = criterion(outputs, labels)
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
|
||||
print('Finished Training')
|
||||
|
||||
ex = Experiment("sacred_scopes", interactive=True)
|
||||
ex.observers.append(FileStorageObserver('my_runs'))
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
epochs = 10
|
||||
learning_rate = 0.001
|
||||
|
||||
@ex.main
|
||||
def my_main(epochs, learning_rate):
|
||||
|
||||
train, dev, test = z.prepareData()
|
||||
|
||||
batch_size = 4
|
||||
|
||||
trainlist = train.values.tolist()
|
||||
testlist = test.values.tolist()
|
||||
|
||||
trainset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in trainlist]
|
||||
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
|
||||
shuffle=True, num_workers=2)
|
||||
|
||||
testset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in testlist]
|
||||
testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size,
|
||||
shuffle=False, num_workers=2)
|
||||
|
||||
classes = ('male', 'female')
|
||||
|
||||
net = Net()
|
||||
|
||||
criterion = nn.CrossEntropyLoss()
|
||||
optimizer = optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9)
|
||||
|
||||
trainNet(trainloader, criterion, optimizer, net, int(float(epochs)))
|
||||
|
||||
PATH = './cifar_net.pth'
|
||||
torch.save(net.state_dict(), PATH)
|
||||
ex.add_artifact("cifar_net.pth")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
ex.run()
|
||||
|
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
|
||||
def prepareData():
|
||||
data = pd.read_csv("Customers.csv")
|
||||
#print(data[:10])
|
||||
|
||||
dataF = data
|
||||
|
||||
mapping = {'NaN' : 0, 'Healthcare' : 1, 'Engineer' : 2, 'Lawyer' : 3, 'Entertainment' : 4, 'Artist' : 5, 'Executive' : 6,
|
||||
'Doctor' : 7, 'Homemaker' : 8, 'Marketing' : 9}
|
||||
|
||||
mapping2 = {'Male' : 0, 'Female' : 1}
|
||||
|
||||
dataF = dataF.replace({'Profession': mapping})
|
||||
dataF = dataF.replace({'Gender': mapping2})
|
||||
|
||||
dataF = dataF.drop(columns=['CustomerID'])
|
||||
|
||||
dataF['Profession'] = dataF['Profession'].fillna(0)
|
||||
|
||||
normalized_dataF = (dataF - dataF.min())/(dataF.max() - dataF.min())
|
||||
|
||||
#print(normalized_dataF[:10])
|
||||
|
||||
train_data = normalized_dataF[0:1600]
|
||||
dev_data = normalized_dataF[1600:1800]
|
||||
test_data = normalized_dataF[1800:]
|
||||
|
||||
#print(f"Wielkość zbioru Customers: {len(data)} elementów")
|
||||
#print(f"Wielkość zbioru trenującego: {len(train_data)} elementów")
|
||||
#print(f"Wielkość zbioru walidującego: {len(dev_data)} elementów")
|
||||
#print(f"Wielkość zbioru testującego: {len(test_data)} elementów")
|
||||
|
||||
#print(f" \nDane i wartości na temat zbioru: \n \n {normalized_dataF.describe()}")
|
||||
|
||||
return train_data, dev_data, test_data
|
103
sacred_train.py
Normal file
103
sacred_train.py
Normal file
@ -0,0 +1,103 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import zadanie1 as z
|
||||
import torch
|
||||
import torchvision
|
||||
import torchvision.transforms as transforms
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import torch.optim as optim
|
||||
from sacred import Experiment
|
||||
from sacred.observers import FileStorageObserver
|
||||
from sacred.observers import MongoObserver
|
||||
|
||||
class Net(nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#self.conv1 = nn.Conv2d(3, 6, 5)
|
||||
#self.pool = nn.MaxPool2d(2, 2)
|
||||
#self.conv2 = nn.Conv2d(6, 16, 5)
|
||||
#self.fc1 = nn.Linear(16 * 5 * 5, 120)
|
||||
#self.fc2 = nn.Linear(20, 6)
|
||||
self.fc3 = nn.Linear(6, 6)
|
||||
|
||||
def forward(self, x):
|
||||
#x = self.pool(F.relu(self.conv1(x)))
|
||||
#x = self.pool(F.relu(self.conv2(x)))
|
||||
#x = torch.flatten(x, 1)
|
||||
#x = F.relu(self.fc1(x))
|
||||
#x = F.relu(self.fc2(x))
|
||||
x = self.fc3(x)
|
||||
return x
|
||||
|
||||
|
||||
def trainNet(_run, trainloader, criterion, optimizer, net, epochs=20):
|
||||
for epoch in range(epochs):
|
||||
|
||||
for i, data in enumerate(trainloader, 0):
|
||||
inputs, labels = data
|
||||
|
||||
labelsX = torch.Tensor([x for x in labels])
|
||||
labels = labelsX.type(torch.LongTensor)
|
||||
|
||||
optimizer.zero_grad()
|
||||
|
||||
outputs = net(inputs)
|
||||
|
||||
loss = criterion(outputs, labels)
|
||||
|
||||
_run.log_scalar("training.loss", loss)
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
|
||||
print('Finished Training')
|
||||
|
||||
ex = Experiment("s452627", interactive=True)
|
||||
ex.observers.append(FileStorageObserver('my_runs'))
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
epochs = 10
|
||||
learning_rate = 0.001
|
||||
|
||||
@ex.main
|
||||
def my_main(epochs, learning_rate, _run):
|
||||
|
||||
ex.open_resource("Customers.csv", "r")
|
||||
|
||||
train, dev, test = z.prepareData()
|
||||
|
||||
batch_size = 4
|
||||
|
||||
trainlist = train.values.tolist()
|
||||
testlist = test.values.tolist()
|
||||
|
||||
trainset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in trainlist]
|
||||
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
|
||||
shuffle=True, num_workers=2)
|
||||
|
||||
testset = [[torch.Tensor(x[1:]), torch.Tensor([x[0]])] for x in testlist]
|
||||
testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size,
|
||||
shuffle=False, num_workers=2)
|
||||
|
||||
classes = ('male', 'female')
|
||||
|
||||
net = Net()
|
||||
|
||||
criterion = nn.CrossEntropyLoss()
|
||||
optimizer = optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9)
|
||||
|
||||
trainNet(_run, trainloader, criterion, optimizer, net, int(float(epochs)))
|
||||
|
||||
PATH = './cifar_net.pth'
|
||||
torch.save(net.state_dict(), PATH)
|
||||
|
||||
ex.add_artifact("cifar_net.pth")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
ex.run()
|
||||
|
Loading…
Reference in New Issue
Block a user