示例#1
0
def main(args):
    config = args

    print('loading data')
    data, iters, vocab, stats, Q_field = get_data(config)

    config.q_size = stats['question_size']
    config.a_size = stats['answer_size']
    config.c_size = stats['topic_size']
    config.keys = ['A', 'c']
    config.sizes = {'A': config.a_size, 'c': config.c_size}

    if config.verbose:
        x = next(iter(iters['val']))
        print(x.answers[0].data)

    print('loading model')
    net, best_acc, config.start_epoch = get_net(config, vocab)

    if config.train:
        print("Let\'s start Training")
        train_all(net, data, iters, config)
    else:
        print("Let\'s start Testing")
        test_and_save(net, data, iters[config.test_iter], config)
示例#2
0
    rStatesSave = []
    mStatesSave = []

    for i, fileLists in enumerate(fileNames):
        for j, fList in enumerate(fileLists):
            dists = []

            for f in fList:
                print i, j
                print f

                fbProbs, numSteps, model, statesInRbt, states, logProbs_T, logProbs_O, logProbs, poses, actions, obs, \
                         actionType, actionSelectionType, numMechanismTypes, numParticles, numRepeats, neff_fract, \
                         modelNums, realStates, BIAS, FTSD, FOSD, RTSD, ROSD \
                         = readData.get_data(dirName+f)

                # save real
                rStatesSave.append(realStates[1:])

                # find max state at each step
                mStatesSave.append([])
                for k, (Ss, lPs) in enumerate(zip(states[1:], logProbs[1:])):
                    maxProbs = []
                    maxProbInds = []
                    for l in relevantMT:
                        maxProbs.append(max(lPs[l]))
                        maxProbInds.append(lPs[l].index(maxProbs[-1]))

                    maxModelInd = maxProbs.index(max(maxProbs))
                    maxProbInd = maxProbInds[maxModelInd]
    rStatesSave = []
    mStatesSave = []

    for i,fileLists in enumerate(fileNames):
        for j,fList in enumerate(fileLists):
            dists = []

            for f in fList:
                print i,j
                print f

                fbProbs, numSteps, model, statesInRbt, states, logProbs_T, logProbs_O, logProbs, poses, actions, obs, \
                         actionType, actionSelectionType, numMechanismTypes, numParticles, numRepeats, neff_fract, \
                         modelNums, realStates, BIAS, FTSD, FOSD, RTSD, ROSD \
                         = readData.get_data(dirName+f)

                # save real
                rStatesSave.append(realStates[1:])

                # find max state at each step
                mStatesSave.append([])
                for k,(Ss,lPs) in enumerate(zip(states[1:],logProbs[1:])):
                    maxProbs = []
                    maxProbInds = []
                    for l in relevantMT:
                        maxProbs.append(max(lPs[l]))
                        maxProbInds.append(lPs[l].index(maxProbs[-1]))

                    maxModelInd = maxProbs.index(max(maxProbs))
                    maxProbInd = maxProbInds[maxModelInd]
def runNet():
    np.random.seed(10)
    sp.random.seed(10)
    net = neuralNet.createNet()
    train_ds, test_ds = readData.get_data()
    train_model(net, train_ds, test_ds)
    mStatesSave = []
    fbProbsSave = []

    for i, fileLists in enumerate(fileNames):
        for j, fList in enumerate(fileLists):
            dists = []

            fbProbsList = []
            for f in fList:
                print i, j
                print f

                fbProbs, numSteps, model, statesInRbt, states, logProbs_T, logProbs_O, logProbs, poses, actions, obs, \
                         actionType, actionSelectionType, numMechanismTypes, numParticles, numRepeats, neff_fract, \
                         modelNums, realStates, BIAS, FTSD, FOSD, RTSD, ROSD \
                         = readData.get_data(f) # used to be dirName+f

                # save fbProbs
                fbProbsList.append(fbProbs)

                # save real
                #rStatesSave.append(realStates[1:])

                # find max state at each step
                #mStatesSave.append([])
                #for k,(Ss,lPs) in enumerate(zip(states[1:],logProbs[1:])):
                #maxProbs = []
                #maxProbInds = []
                #for l in relevantMT:
                #maxProbs.append(max(lPs[l]))
                #maxProbInds.append(lPs[l].index(maxProbs[-1]))
import readData
import sys

f = sys.argv[1] 

fbProbs, numSteps, model, statesInRbt, states, logProbs_T, \
         logProbs_O, logProbs, poses, actions, obs, \
         actionType, actionSelectionType, numMechanismTypes, \
         numParticles, numRepeats, neff_fract, \
         modelNums, realStates, BIAS, FTSD, FOSD, RTSD, ROSD \
         = readData.get_data(f)

print fbProbs
        for j in range(numMT):
            fileNames[i][j] = files[numMT * numT * i + numT * j : numMT * numT * i + numT * j + numT]

    rStatesSave = []
    mStatesSave = []

    for i, fileLists in enumerate(fileNames):
        for j, fList in enumerate(fileLists):
            dists = []

            for f in fList:
                print i, j
                print f

                fbProbs, numSteps, model, statesInRbt, states, logProbs_T, logProbs_O, logProbs, poses, actions, obs, actionType, actionSelectionType, numMechanismTypes, numParticles, numRepeats, neff_fract, modelNums, realStates, BIAS, FTSD, FOSD, RTSD, ROSD = readData.get_data(
                    dirName + f
                )

                # find max state
                maxProbs = []
                maxProbInds = []
                for l in relevantMT:
                    maxProbs.append(max(logProbs[-1][l]))
                    maxProbInds.append(logProbs[-1][l].index(maxProbs[-1]))

                maxModelInd = maxProbs.index(max(maxProbs))
                maxProbInd = maxProbInds[maxModelInd]
                maxState = states[-1][relevantMT[maxModelInd]][maxProbInd]

                print realStates[-1]
                print maxState
    rStatesSave = []
    mStatesSave = []

    for i,fileLists in enumerate(fileNames):
        for j,fList in enumerate(fileLists):
            dists = []

            for f in fList:
                print i,j
                print f

                fbProbs, numSteps, model, statesInRbt, states, logProbs_T, logProbs_O, logProbs, poses, actions, obs, \
                         actionType, actionSelectionType, numMechanismTypes, numParticles, numRepeats, neff_fract, \
                         modelNums, realStates, BIAS, FTSD, FOSD, RTSD, ROSD \
                         = readData.get_data(f) # used to be dirName+f

                # save real
                rStatesSave.append(realStates[1:])

                # find max state at each step
                mStatesSave.append([])
                for k,(Ss,lPs) in enumerate(zip(states[1:],logProbs[1:])):
                    maxProbs = []
                    maxProbInds = []
                    for l in relevantMT:
                        maxProbs.append(max(lPs[l]))
                        maxProbInds.append(lPs[l].index(maxProbs[-1]))

                    maxModelInd = maxProbs.index(max(maxProbs))
                    maxProbInd = maxProbInds[maxModelInd]
示例#9
0
import readData
import sys

f = sys.argv[1]

fbProbs, numSteps, model, statesInRbt, states, logProbs_T, \
         logProbs_O, logProbs, poses, actions, obs, \
         actionType, actionSelectionType, numMechanismTypes, \
         numParticles, numRepeats, neff_fract, \
         modelNums, realStates, BIAS, FTSD, FOSD, RTSD, ROSD \
         = readData.get_data(f)

print fbProbs
def runNet():
    np.random.seed(10)
    sp.random.seed(10)
    net = neuralNet.createNet()
    train_ds, test_ds = readData.get_data()
    train_model(net, train_ds, test_ds)