Added sacred script
This commit is contained in:
parent
6ef6474403
commit
4686b93132
@ -15,6 +15,8 @@ RUN pip3 install tensorflow
|
||||
RUN pip3 install scikit-learn
|
||||
RUN pip3 install argparse
|
||||
RUN pip3 install matplotlib
|
||||
RUN pip3 install sacred
|
||||
RUN pip3 install pymongo
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
@ -24,6 +26,7 @@ COPY ./stats.sh ./
|
||||
COPY ./data.py ./
|
||||
COPY ./ium_train.py ./
|
||||
COPY ./ium_predict.py ./
|
||||
COPY ./ium_sacred.py ./
|
||||
COPY ./baltimore_dev.csv ./
|
||||
COPY ./baltimore_test.csv ./
|
||||
COPY ./baltimore_train.csv ./
|
||||
|
@ -25,10 +25,10 @@ node {
|
||||
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's487197', url: 'https://git.wmi.amu.edu.pl/s487197/ium_487197']]])
|
||||
}
|
||||
stage('Dockerfile'){
|
||||
def testImage = docker.image('s487197/ium:38')
|
||||
def testImage = docker.image('s487197/ium:39')
|
||||
testImage.inside{
|
||||
copyArtifacts filter: 'baltimore_train.csv', projectName: 's487197-create-dataset'
|
||||
sh "python3 ium_train.py -epochs $EPOCHS -lr $LR -validation_split $VALIDATION_SPLIT"
|
||||
sh "python3 ium_sacred.py -epochs $EPOCHS -lr $LR -validation_split $VALIDATION_SPLIT"
|
||||
archiveArtifacts artifacts: 'baltimore.zip'
|
||||
stage('Buil'){
|
||||
build job: 's487197-evaluation.eg/master', parameters: [string(name: 'build', value: "${currentBuild.number}")], wait:false
|
||||
|
27
ium_train.py
27
ium_train.py
@ -11,7 +11,10 @@ import numpy as np
|
||||
from sklearn.preprocessing import LabelEncoder
|
||||
import argparse
|
||||
import shutil
|
||||
from sacred.observers import FileStorageObserver, MongoObserver
|
||||
from sacred import Experiment
|
||||
|
||||
ex = Experiment('s487197-train', save_git_info=False)
|
||||
|
||||
def get_x_y(data):
|
||||
|
||||
@ -27,15 +30,31 @@ def get_x_y(data):
|
||||
|
||||
return data, x, y
|
||||
|
||||
|
||||
def train_model():
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
parser = argparse.ArgumentParser(description='Train')
|
||||
|
||||
parser.add_argument('-epochs', type=int, default=20)
|
||||
parser.add_argument('-lr', type=float, default=0.01)
|
||||
parser.add_argument('-validation_split', type=float, default=0.2)
|
||||
args = parser.parse_args()
|
||||
epochs=args.epochs
|
||||
lr=args.lr
|
||||
validation_split=args.validation_split
|
||||
return args
|
||||
|
||||
@ex.automain
|
||||
def train_model(config):
|
||||
|
||||
# parser = argparse.ArgumentParser(description='Train')
|
||||
|
||||
# parser.add_argument('-epochs', type=int, default=20)
|
||||
# parser.add_argument('-lr', type=float, default=0.01)
|
||||
#parser.add_argument('-validation_split', type=float, default=0.2)
|
||||
ex.observers.append(FileStorageObserver('s487197'))
|
||||
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
args = config
|
||||
|
||||
train = pd.read_csv('baltimore_train.csv')
|
||||
|
||||
@ -62,5 +81,5 @@ def train_model():
|
||||
shutil.make_archive('baltimore', 'zip', 'baltimore_model')
|
||||
|
||||
|
||||
train_model()
|
||||
train_model(my_config())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user