Commit 4b4b3124 authored by ymir's avatar ymir

request training set

parent 97001323
Here are some examples for each possible resource and actions
***** PERCEPTRON *****
PERCEPTRON_FILE=/tmp/perceptron.gz
PERCEPTRON_ARCHIVE=/tmp/perceptron.gz
-> randomize
rm ${PERCEPTRON_FILE}
python3 neuralnetworktrainercli.py randomize perceptron -d 784 18 16 10 -c "randomized perceptron" -a ${PERCEPTRON_FILE}
ls -lh ${PERCEPTRON_FILE}
rm ${PERCEPTRON_ARCHIVE}
python3 neuralnetworktrainercli.py randomize perceptron -d 10 2 -c "randomized perceptron" -a ${PERCEPTRON_ARCHIVE}
ls -lh ${PERCEPTRON_ARCHIVE}
-> create
PERCEPTRON_ID=`python3 neuralnetworktrainercli.py create perceptron -a ${PERCEPTRON_FILE}`
PERCEPTRON_ID=`python3 neuralnetworktrainercli.py create perceptron -a ${PERCEPTRON_ARCHIVE}`
echo ${PERCEPTRON_ID}
-> read single
rm ${PERCEPTRON_FILE}
python3 neuralnetworktrainercli.py read perceptron -i ${PERCEPTRON_ID} -a ${PERCEPTRON_FILE}
ls -lh ${PERCEPTRON_FILE}
rm ${PERCEPTRON_ARCHIVE}
python3 neuralnetworktrainercli.py read perceptron -i ${PERCEPTRON_ID} -a ${PERCEPTRON_ARCHIVE}
ls -lh ${PERCEPTRON_ARCHIVE}
-> update
python3 neuralnetworktrainercli.py update perceptron -i ${PERCEPTRON_ID} -a ${PERCEPTRON_FILE}
python3 neuralnetworktrainercli.py update perceptron -i ${PERCEPTRON_ID} -a ${PERCEPTRON_ARCHIVE}
-> patch
python3 neuralnetworktrainercli.py patch perceptron -i ${PERCEPTRON_ID} -c "patched perceptron"
-> summarize
......@@ -23,13 +23,50 @@ python3 neuralnetworktrainercli.py delete perceptron -i ${PERCEPTRON_ID}
-> read all
for i in {0..7}
do
python3 neuralnetworktrainercli.py randomize perceptron -d 1 1 -a ${PERCEPTRON_FILE}
python3 neuralnetworktrainercli.py create perceptron -a ${PERCEPTRON_FILE}
python3 neuralnetworktrainercli.py randomize perceptron -d 1 1 -a ${PERCEPTRON_ARCHIVE}
python3 neuralnetworktrainercli.py create perceptron -a ${PERCEPTRON_ARCHIVE}
done
python3 neuralnetworktrainercli.py read perceptron
-> delete all
python3 neuralnetworktrainercli.py delete perceptron
***** TRAINING SET *****
TRAININGSET_ARCHIVE=/tmp/trainingset.gz
rm ${TRAININGSET_ARCHIVE}
echo '{
"trainingElements":[
{
"input": [-0.9590387375223313, -0.7262874916604634, -0.15411733801644223, 0.9503177420051971, 0.007182389274566603, 0.6349310840236144, -0.418378372924193, -0.9941401399635585, 0.0602208156225954, -0.12071835034378808],
"expectedOutput": [0.45085160191500107, 0.7830055085276899]
},{
"input": [-0.17877111935151802, 0.289292172939271, 0.8031789521859756, -0.608460316151133, -0.01609260193495632, 0.7455596835370322, -0.6635541930394633, 0.5931539474269061, -0.1983855626859896, -0.8826222233730008],
"expectedOutput": [-0.8648873171128424, -0.407992733247007]
}
],
"comments": "test training set"
}' | gzip > ${TRAININGSET_ARCHIVE}
-> create
TRAININGSET_ID=`python3 neuralnetworktrainercli.py create trainingset -a ${TRAININGSET_ARCHIVE}`
echo ${TRAININGSET_ID}
-> read single
rm ${TRAININGSET_ARCHIVE}
python3 neuralnetworktrainercli.py read trainingset -i ${TRAININGSET_ID} -a ${TRAININGSET_ARCHIVE}
ls -lh ${TRAININGSET_ARCHIVE}
-> update
python3 neuralnetworktrainercli.py update trainingset -i ${TRAININGSET_ID} -a ${TRAININGSET_ARCHIVE}
-> patch
python3 neuralnetworktrainercli.py patch trainingset -i ${TRAININGSET_ID} -c "patched trainingset"
-> summarize
python3 neuralnetworktrainercli.py summarize trainingset -i ${TRAININGSET_ID}
-> delete single
python3 neuralnetworktrainercli.py delete trainingset -i ${TRAININGSET_ID}
-> read all
for i in {0..7}
do
python3 neuralnetworktrainercli.py create trainingset -a ${TRAININGSET_ARCHIVE}
done
python3 neuralnetworktrainercli.py read trainingset
-> delete all
python3 neuralnetworktrainercli.py delete trainingset
***** TRAINING SESSION *****
***** TRAINER *****
-------------------------------------------------------------
\ No newline at end of file
......@@ -27,7 +27,7 @@ parser.add_argument("action", type=str, help="the action to execute : randomize,
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("-d", "--dimensions", type=int, nargs='+', help="ordered perceptrons layers sizes, i.e. 784 18 16 10")
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")
# display extra help
def displayExtraHelp():
......@@ -49,7 +49,8 @@ def loadArchive(archive):
content=file.read()
file.close()
return content
# randomize perceptron
# ***** PERCEPTRON *****
# randomize
def randomizePerceptron(dimensions,comments,archive):
URL=baseURL+"/perceptron/random"
data=dumps({"dimensions":dimensions,"comments":comments})
......@@ -57,7 +58,7 @@ def randomizePerceptron(dimensions,comments,archive):
checkresponse(response)
dumpArchive(archive, response.content)
pass
# create perceptron
# create
def createPerceptron(archive):
URL=baseURL+"/perceptron"
data=loadArchive(archive)
......@@ -65,64 +66,149 @@ def createPerceptron(archive):
checkresponse(response)
print(response.text)
pass
# read single perceptron
# read single
def readSinglePerceptron(id,archive):
URL=baseURL+"/perceptron/"+str(id)
response = get(URL, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# read all perceptron
# read all
def readAllPerceptron():
URL=baseURL+"/perceptron"
response = get(URL, headers=ContentType.JSON.value)
checkresponse(response)
print(response.text)
pass
# update perceptron
# update
def updatePerceptron(id,archive):
URL=baseURL+"/perceptron/"+str(id)
data=loadArchive(archive)
response = put(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# patch perceptron
# patch
def patchPerceptron(id,comments):
URL=baseURL+"/perceptron/"+str(id)
data=dumps({"comments":comments})
response = patch(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# summarize perceptron
# summarize
def summarizePerceptron(id):
URL=baseURL+"/perceptron/"+str(id)+"/summary"
response = get(URL, headers=ContentType.JSON.value)
checkresponse(response)
print(response.text)
pass
# delete single perceptron
# delete
def deleteSinglePerceptron(id):
URL=baseURL+"/perceptron/"+str(id)
response = delete(URL, headers=ContentType.JSON.value)
checkresponse(response)
pass
# delete all perceptron
# delete
def deleteAllPerceptron():
URL=baseURL+"/perceptron"
response = delete(URL, headers=ContentType.JSON.value)
checkresponse(response)
pass
# ***** TRAINING SET *****
# create
def createTrainingSet(archive):
URL=baseURL+"/trainingset"
data=loadArchive(archive)
response = post(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
print(response.text)
pass
# read single
def readSingleTrainingSet(id,archive):
URL=baseURL+"/trainingset/"+str(id)
response = get(URL, headers=ContentType.GZIP.value)
checkresponse(response)
dumpArchive(archive, response.content)
pass
# read all
def readAllTrainingSet():
URL=baseURL+"/trainingset"
response = get(URL, headers=ContentType.JSON.value)
checkresponse(response)
print(response.text)
pass
# update
def updateTrainingSet(id,archive):
URL=baseURL+"/trainingset/"+str(id)
data=loadArchive(archive)
response = put(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# patch
def patchTrainingSet(id,comments):
URL=baseURL+"/trainingset/"+str(id)
data=dumps({"comments":comments})
response = patch(URL, data=data, headers=ContentType.GZIP.value)
checkresponse(response)
pass
# summarize
def summarizeTrainingSet(id):
URL=baseURL+"/trainingset/"+str(id)+"/summary"
response = get(URL, headers=ContentType.JSON.value)
checkresponse(response)
print(response.text)
pass
# delete
def deleteSingleTrainingSet(id):
URL=baseURL+"/trainingset/"+str(id)
response = delete(URL, headers=ContentType.JSON.value)
checkresponse(response)
pass
# delete
def deleteAllTrainingSet():
URL=baseURL+"/trainingset"
response = delete(URL, headers=ContentType.JSON.value)
checkresponse(response)
pass
# parse arguments
# parse arguments
def dispatchRequest(arguments):
# ***** PERCEPTRON *****
# randomize
if arguments.action.upper()=="RANDOMIZE" and arguments.resource.upper()=="PERCEPTRON": randomizePerceptron(arguments.dimensions,arguments.comments,arguments.archive)
# create
elif arguments.action.upper()=="CREATE" and arguments.resource.upper()=="PERCEPTRON": createPerceptron(arguments.archive)
# read single
elif arguments.action.upper()=="READ" and arguments.resource.upper()=="PERCEPTRON" and arguments.id: readSinglePerceptron(arguments.id,arguments.archive)
# read all
elif arguments.action.upper()=="READ" and arguments.resource.upper()=="PERCEPTRON": readAllPerceptron()
# update
elif arguments.action.upper()=="UPDATE" and arguments.resource.upper()=="PERCEPTRON": updatePerceptron(arguments.id,arguments.archive)
# patch
elif arguments.action.upper()=="PATCH" and arguments.resource.upper()=="PERCEPTRON": patchPerceptron(arguments.id,arguments.comments)
# summarize
elif arguments.action.upper()=="SUMMARIZE" and arguments.resource.upper()=="PERCEPTRON": summarizePerceptron(arguments.id)
# delete single
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="PERCEPTRON" and arguments.id: deleteSinglePerceptron(arguments.id)
# delete all
elif arguments.action.upper()=="DELETE" and arguments.resource.upper()=="PERCEPTRON": deleteAllPerceptron()
# ***** TRAINING SET *****
# create
elif arguments.action.upper()=="CREATE" and arguments.resource.upper()=="TRAININGSET": createTrainingSet(arguments.archive)
# read single
elif arguments.action.upper()=="READ" and arguments.resource.upper()=="TRAININGSET" and arguments.id: readSingleTrainingSet(arguments.id,arguments.archive)
# read all
elif arguments.action.upper()=="READ" and arguments.resource.upper()=="TRAININGSET": readAllTrainingSet()
# update
elif arguments.action.upper()=="UPDATE" and arguments.resource.upper()=="TRAININGSET": updateTrainingSet(arguments.id,arguments.archive)
# patch
elif arguments.action.upper()=="PATCH" and arguments.resource.upper()=="TRAININGSET": patchTrainingSet(arguments.id,arguments.comments)
# summarize
elif arguments.action.upper()=="SUMMARIZE" and arguments.resource.upper()=="TRAININGSET": summarizeTrainingSet(arguments.id)
# delete single
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()
# ***** error in command line positional arguments *****
else: raise Exception("couple action/resource does not match : " + arguments.action + "/" + arguments.resource)
pass
# run program
......
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