Example #1
0
def startRun(continuation, attribs, architecture, solver, callerFilePath):
    global nrun
    global filecontents
    filecontents = ""
    if callerFilePath is not None:

        def getC(f):
            global filecontents
            with open(f, "r") as ff:
                filecontents = filecontents + f + "\n" + ff.read()

        if (type(callerFilePath) == tuple):
            for f in callerFilePath:
                getC(f)
        else:
            getC(callerFilePath)
    runColList = "(COUNT INTEGER PRIMARY KEY, TIME TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL, REPN TEXT, REPNLENGTH INT, CONTINUATION TEXT, BATCHTR INT, BATCHTE INT, LAYERTYPE TEXT, LAYERS INT, WIDTH INT, ARCHITECTURE TEXT, SOLVER TEXT, CODE TEXT)"
    if not oldColumns:
        runColList = "(COUNT INTEGER PRIMARY KEY, TIME TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL, CONTINUATION TEXT, ARCHITECTURE TEXT, SOLVER TEXT, CODE TEXT)"
    setup = [
        "create table if not exists RUNS" +
        runColList,  #these default keys start at 1
        "create table if not exists STEPS(STEP INTEGER PRIMARY KEY, RUN int, OBJECTIVE real, TRAINACC real, TESTOBJECTIVE real, TESTACC REAL )",
        "create table if not exists TIMES(RUN INT, TIME real)",  # stores the time of the tenth step of each run, allowing speed to be measured
        "create table if not exists ATTRIBS(RUN INT, NAME TEXT, ISRESULT INT, VALUE)"  #value deliberately has no affinity. some are numbers
    ]
    infoquery = "insert into RUNS (CONTINUATION, ARCHITECTURE, SOLVER, CODE) VALUES (?,?,?,?)"
    info = (continuation, architecture, solver, filecontents)
    attribquery = "insert into ATTRIBS(RUN, NAME, ISRESULT, VALUE) VALUES (?,?,0,?)"
    if useCPP:
        for s in setup:
            report.resultless(s)
        report.sink(infoquery, info)
        nrun = report.lastRow()
        for k, v in sorted(attribs.items()):
            report.sink(attribquery, (nrun, k, v))
    else:
        c = con.cursor()
        for s in setup:
            c.execute(s)
        c.execute(infoquery, info)
        nrun = c.lastrowid
        c.executemany(attribquery,
                      [([nrun] + list(i)) for i in sorted(attribs.items())])
        con.commit()
Example #2
0
def step(obj, train, objte, test):
    global nsteps
    q = [("insert into steps values (NULL, ?, ?, ?, ?, ?)", (nrun, obj, train,
                                                             objte, test))]
    nsteps = 1 + nsteps
    if nsteps == 10:
        #c.execute("insert into TIMES (RUN) VALUES (?)", (nrun,))
        q.append(
            ("insert into TIMES VALUES (?,?)",
             (nrun, (datetime.datetime.now() - starttime).total_seconds())))

    if useCPP:
        for sql, data in q:
            report.sink(sql, data)
    else:
        c = con.cursor()
        for sql, data in q:
            c.execute(sql, data)
        con.commit()
Example #3
0
def startRun(repnname, repnlength, continuation, batchTr, batchTe, layertype,
             layers, width, architecture, solver, callerFilePath):
    global nrun
    global starttime
    global filecontents
    filecontents = ""
    if callerFilePath is not None:

        def getC(f):
            global filecontents
            with open(f, "r") as ff:
                filecontents = filecontents + f + "\n" + ff.read()

        if (type(callerFilePath) == tuple):
            for f in callerFilePath:
                getC(f)
        else:
            getC(callerFilePath)
    setup = [
        "create table if not exists RUNS(COUNT INTEGER PRIMARY KEY, TIME TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL, REPN TEXT, REPNLENGTH INT, CONTINUATION TEXT, BATCHTR INT, BATCHTE INT, LAYERTYPE TEXT, LAYERS INT, WIDTH INT, ARCHITECTURE TEXT, SOLVER TEXT, CODE TEXT)",  #these default keys start at 1
        "create table if not exists STEPS(STEP INTEGER PRIMARY KEY, RUN int, OBJECTIVE real, TRAINACC real, TESTOBJECTIVE real, TESTACC REAL )",
        "create table if not exists TIMES(RUN INT, TIME real)"  # stores the time of the tenth step of each run, allowing speed to be measured
    ]
    infoquery = "insert into RUNS (REPN, REPNLENGTH, CONTINUATION, BATCHTR, BATCHTE, LAYERTYPE, LAYERS, WIDTH, ARCHITECTURE, SOLVER, CODE) VALUES (?,?,?,?,?,?,?,?,?,?,?)"
    info = (repnname, repnlength, continuation, batchTr, batchTe, layertype,
            layers, width, architecture, solver, filecontents)
    if useCPP:
        for s in setup:
            report.resultless(s)
        report.sink(infoquery, info)
        nrun = report.lastRow()
    else:
        c = con.cursor()
        for s in setup:
            c.execute(s)
        c.execute(infoquery, info)
        nrun = c.lastrowid
        con.commit()
    starttime = datetime.datetime.now()