Commit b22cd06b authored by ymir's avatar ymir

add training session

parent 4b4b3124
......@@ -68,5 +68,38 @@ python3 neuralnetworktrainercli.py read trainingset
-> delete all
python3 neuralnetworktrainercli.py delete trainingset
***** TRAINING SESSION *****
PERCEPTRON_ID=`python3 neuralnetworktrainercli.py create perceptron -a ${PERCEPTRON_ARCHIVE}`
echo ${PERCEPTRON_ID}
TRAININGSET_ID=`python3 neuralnetworktrainercli.py create trainingset -a ${TRAININGSET_ARCHIVE}`
echo ${TRAININGSET_ID}
TRAININGSESSION_ARCHIVE=/tmp/trainingsession.gz
-> randomize
rm ${TRAININGSESSION_ARCHIVE}
python3 neuralnetworktrainercli.py randomize trainingsession -i ${PERCEPTRON_ID} -t ${TRAININGSET_ID} -z 2 -s 5 -r 0 -c "randomized training session" -a ${TRAININGSESSION_ARCHIVE}
ls -lh ${TRAININGSESSION_ARCHIVE}
-> create
TRAININGSESSION_ID=`python3 neuralnetworktrainercli.py create trainingsession -i ${PERCEPTRON_ID} -a ${TRAININGSESSION_ARCHIVE}`
echo ${TRAININGSESSION_ID}
-> read single
rm ${TRAININGSESSION_ARCHIVE}
python3 neuralnetworktrainercli.py read trainingsession -i ${TRAININGSESSION_ID} -a ${TRAININGSESSION_ARCHIVE}
ls -lh ${TRAININGSESSION_ARCHIVE}
-> update
python3 neuralnetworktrainercli.py update trainingsession -i ${TRAININGSESSION_ID} -a ${TRAININGSESSION_ARCHIVE}
-> patch
python3 neuralnetworktrainercli.py patch trainingsession -i ${TRAININGSESSION_ID} -c "patched trainingsession"
-> summarize
python3 neuralnetworktrainercli.py summarize trainingsession -i ${TRAININGSESSION_ID}
-> delete single
python3 neuralnetworktrainercli.py delete trainingsession -i ${TRAININGSESSION_ID}
-> read all
for i in {0..7}
do
python3 neuralnetworktrainercli.py randomize trainingsession -d 1 1 -a ${TRAININGSESSION_ARCHIVE}
python3 neuralnetworktrainercli.py create trainingsession -a ${TRAININGSESSION_ARCHIVE}
done
python3 neuralnetworktrainercli.py read trainingsession
-> delete all
python3 neuralnetworktrainercli.py delete trainingsession
***** TRAINER *****
-------------------------------------------------------------
\ No newline at end of file
......@@ -23,12 +23,16 @@ configuration=configurationLoader.loadedConfiguration["service"]
baseURL="http://"+configuration["host"]+":"+configuration["port"]+"/"+configuration["endpoint"]
# initialize parser
parser = ArgumentParser()
parser.add_argument("action", type=str, help="the action to execute : randomize, create, read, update, delete, summarize, patch, start, stop")
parser.add_argument("resource", type=str, help="the type of resource to use : perceptron, trainingset, trainingsession, trainer")
parser.add_argument("-a", "--archive", type=str, help="file to archive resource")
parser.add_argument("-c", "--comments", type=str, help="any free text that can help you")
parser.add_argument("action", type=str, help="action to execute : randomize, create, read, update, delete, summarize, patch, start, stop")
parser.add_argument("resource", type=str, help="type of resource to use : perceptron, trainingset, trainingsession, trainer")
parser.add_argument("-a", "--archive", type=str, help="file to archive resource, i.e. myArchive.gz")
parser.add_argument("-c", "--comments", type=str, help="any free text that can help you, i.e. 'this is a test'")
parser.add_argument("-d", "--dimensions", type=int, nargs='+', help="ordered perceptrons layers sizes, i.e. 10 2 ...")
parser.add_argument("-i", "--id", type=int, help="specific ID for the resource")
parser.add_argument("-i", "--id", type=int, help="specific ID for the resource, i.e. 123")
parser.add_argument("-r", "--test-ratio", type=int, help="ration (between 0 and 1) of training set element that will be used for testing (after training), i.e. 0.25")
parser.add_argument("-s", "--save-interval", type=int, help="interval to save training session progress, i.e. 10")
parser.add_argument("-t", "--training-set-id", type=int, help="training set ID to link on training session, i.e. 456")
parser.add_argument("-z", "--training-chunk-size", type=int, help="chunk size to gradualy increase training session, i.e. 5")
# display extra help
def displayExtraHelp():
file = open(extraHelpFile, 'r')
......@@ -169,7 +173,70 @@ def deleteAllTrainingSet():
response = delete(URL, headers=ContentType.JSON.value)
checkresponse(response)
pass
# parse arguments
# ***** TRAINING SESSION *****
# randomize
def randomizeTrainingsession(id,trainingSetId,trainingChunkSize,saveInterval,testRatio,comments,archive):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession/random"
data=dumps({"trainingSetId":trainingSetId,"trainingChunkSize":trainingChunkSize,"saveInterval":saveInterval,"testRatio":testRatio,"comments":comments})
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# create
def createTrainingsession(archive):
URL=baseURL+"/perceptron/trainingsession"
data=loadArchive(archive)
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
print(response.text)
pass
# read single
def readSingleTrainingsession(id,archive):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
response = get(URL, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# read all
def readAllTrainingsession():
URL=baseURL+"/perceptron/trainingsession"
response = get(URL, headers=ContentType.JSON.value)
checkresponse(response)
print(response.text)
pass
# update
def updateTrainingsession(id,archive):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
data=loadArchive(archive)
response = put(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# patch
def patchTrainingsession(id,comments):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
data=dumps({"comments":comments})
response = patch(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# summarize
def summarizeTrainingsession(id):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession/summary"
response = get(URL, headers=ContentType.JSON.value)
checkresponse(response)
print(response.text)
pass
# delete
def deleteSingleTrainingsession(id):
URL=baseURL+"/perceptron/"+str(id)+"/trainingsession"
response = delete(URL, headers=ContentType.JSON.value)
checkresponse(response)
pass
# delete
def deleteAllTrainingsession():
URL=baseURL+"/perceptron/trainingsession"
response = delete(URL, headers=ContentType.JSON.value)
checkresponse(response)
pass
# parse arguments
def dispatchRequest(arguments):
# ***** PERCEPTRON *****
......@@ -208,6 +275,25 @@ def dispatchRequest(arguments):
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="TRAININGSET" and arguments.id: deleteSingleTrainingSet(arguments.id)
# delete all
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="TRAININGSET": deleteAllTrainingSet()
# ***** TRAINING SESSION *****
# randomize
if arguments.action.upper()=="RANDOMIZE" and arguments.resource.upper()=="TRAININGSESSION": randomizeTrainingsession(arguments.id,arguments.training_set_id,arguments.training_chunk_size,arguments.save_interval,arguments.test_ratio,arguments.comments,arguments.archive)
# create
elif arguments.action.upper()=="CREATE" and arguments.resource.upper()=="TRAININGSESSION": createTrainingsession(arguments.id,arguments.archive)
# read single
elif arguments.action.upper()=="READ" and arguments.resource.upper()=="TRAININGSESSION" and arguments.id: readSingleTrainingsession(arguments.id,arguments.archive)
# read all
elif arguments.action.upper()=="READ" and arguments.resource.upper()=="TRAININGSESSION": readAllTrainingsession()
# update
elif arguments.action.upper()=="UPDATE" and arguments.resource.upper()=="TRAININGSESSION": updateTrainingsession(arguments.id,arguments.archive)
# patch
elif arguments.action.upper()=="PATCH" and arguments.resource.upper()=="TRAININGSESSION": patchTrainingsession(arguments.id,arguments.comments)
# summarize
elif arguments.action.upper()=="SUMMARIZE" and arguments.resource.upper()=="TRAININGSESSION": summarizeTrainingsession(arguments.id)
# delete single
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="TRAININGSESSION" and arguments.id: deleteSingleTrainingsession(arguments.id)
# delete all
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="TRAININGSESSION": deleteAllTrainingsession()
# ***** error in command line positional arguments *****
else: raise Exception("couple action/resource does not match : " + arguments.action + "/" + arguments.resource)
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment