sacred
This commit is contained in:
parent
e94a14e8e7
commit
a5b9eb3882
@ -34,7 +34,7 @@ pipeline {
|
|||||||
stage('sendMail') {
|
stage('sendMail') {
|
||||||
steps{
|
steps{
|
||||||
emailext body: currentBuild.result ?: 'SUCCESS',
|
emailext body: currentBuild.result ?: 'SUCCESS',
|
||||||
subject: 's434766 training',
|
subject: 's434766 evaluation',
|
||||||
to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
|
to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,14 @@ from sklearn.preprocessing import MinMaxScaler
|
|||||||
from sklearn.metrics import accuracy_score
|
from sklearn.metrics import accuracy_score
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from sacred import Experiment
|
||||||
|
from sacred.observers import FileStorageObserver
|
||||||
np.set_printoptions(suppress=False)
|
np.set_printoptions(suppress=False)
|
||||||
|
|
||||||
|
ex = Experiment("stroke-pytorch", interactive=True)
|
||||||
|
ex.observers.append(FileStorageObserver('ium_s434766O_files'))
|
||||||
|
ex.observers.append(MongoObserver(url='mongodb://mongo_user:mongo_password_IUM_2021@localhost:27017',
|
||||||
|
db_name='sacred'))
|
||||||
class LogisticRegressionModel(nn.Module):
|
class LogisticRegressionModel(nn.Module):
|
||||||
def __init__(self, input_dim, output_dim):
|
def __init__(self, input_dim, output_dim):
|
||||||
super(LogisticRegressionModel, self).__init__()
|
super(LogisticRegressionModel, self).__init__()
|
||||||
@ -21,6 +26,8 @@ class LogisticRegressionModel(nn.Module):
|
|||||||
out = self.linear(x)
|
out = self.linear(x)
|
||||||
return self.sigmoid(out)
|
return self.sigmoid(out)
|
||||||
|
|
||||||
|
@ex.main
|
||||||
|
def my_main(_log):
|
||||||
data_train = pd.read_csv("data_train.csv")
|
data_train = pd.read_csv("data_train.csv")
|
||||||
data_test = pd.read_csv("data_test.csv")
|
data_test = pd.read_csv("data_test.csv")
|
||||||
data_val = pd.read_csv("data_val.csv")
|
data_val = pd.read_csv("data_val.csv")
|
||||||
@ -43,7 +50,8 @@ num_epochs = int(sys.argv[2]) if len(sys.argv) > 2 else 5
|
|||||||
learning_rate = 0.001
|
learning_rate = 0.001
|
||||||
input_dim = 6
|
input_dim = 6
|
||||||
output_dim = 1
|
output_dim = 1
|
||||||
|
info_params = "Batch size = " + str(batch_size) + " Epochs = " + str(num_epochs)
|
||||||
|
_log.info(info_params)
|
||||||
model = LogisticRegressionModel(input_dim, output_dim)
|
model = LogisticRegressionModel(input_dim, output_dim)
|
||||||
|
|
||||||
criterion = torch.nn.BCELoss(reduction='mean')
|
criterion = torch.nn.BCELoss(reduction='mean')
|
||||||
@ -57,13 +65,15 @@ for epoch in range(num_epochs):
|
|||||||
y_pred = model(fTrain)
|
y_pred = model(fTrain)
|
||||||
# Compute Loss
|
# Compute Loss
|
||||||
loss = criterion(y_pred, tTrain)
|
loss = criterion(y_pred, tTrain)
|
||||||
print(loss.item())
|
# print(loss.item())
|
||||||
# Backward pass
|
# Backward pass
|
||||||
loss.backward()
|
loss.backward()
|
||||||
optimizer.step()
|
optimizer.step()
|
||||||
|
info_loss = "Last loss = " + str(loss.item())
|
||||||
|
_log.info(info_loss)
|
||||||
y_pred = model(fTest)
|
y_pred = model(fTest)
|
||||||
print("predicted Y value: ", y_pred.data)
|
# print("predicted Y value: ", y_pred.data)
|
||||||
|
|
||||||
torch.save(model.state_dict(), 'stroke.pth')
|
torch.save(model.state_dict(), 'stroke.pth')
|
||||||
|
|
||||||
|
ex.run()
|
Loading…
Reference in New Issue
Block a user