コード例 #1
0
def loadRepeatedExperiments(expDir, killCellPercentRange, seedRange,
                            killCellAt):
    meanAccuracy = []
    stdAccuracy = []
    for killCellPercent in killCellPercentRange:
        accuracyList = []
        for seed in range(10):
            if killCellPercent == 0:
                experiment = os.path.join(
                    expDir, "kill_cell_percent{:1.1f}seed{:1.1f}/0.log".format(
                        killCellPercent, seed))
            else:
                experiment = os.path.join(
                    expDir, "kill_cell_percent{:1.2f}seed{:1.1f}/0.log".format(
                        killCellPercent, seed))
            expResults = readExperiment(experiment)
            print "Load Experiment: ", experiment

            (accuracy, x) = computeAccuracy(expResults['predictions'],
                                            expResults['truths'],
                                            expResults['iterations'],
                                            resets=expResults['resets'],
                                            randoms=expResults['randoms'])
            idx = numpy.array([i for i in range(len(x)) if x[i] > killCellAt])
            accuracy = numpy.array(accuracy)
            accuracyList.append(
                float(numpy.sum(accuracy[idx])) / len(accuracy[idx]))
        meanAccuracy.append(numpy.mean(accuracyList))
        stdAccuracy.append(numpy.std(accuracyList))
    return meanAccuracy, stdAccuracy
コード例 #2
0
def loadRepeatedExperiments(expDir, killCellPercentRange, seedRange, killCellAt):
  meanAccuracy = []
  stdAccuracy = []
  for killCellPercent in killCellPercentRange:
    accuracyList = []
    for seed in range(10):
      if killCellPercent == 0:
        experiment = os.path.join(
          expDir,"kill_cell_percent{:1.1f}seed{:1.1f}/0.log".format(
            killCellPercent, seed))
      else:
        experiment = os.path.join(
          expDir,"kill_cell_percent{:1.2f}seed{:1.1f}/0.log".format(
            killCellPercent, seed))
      expResults = readExperiment(experiment)
      print "Load Experiment: ", experiment

      (accuracy, x) = computeAccuracy(expResults['predictions'],
                                      expResults['truths'],
                                      expResults['iterations'],
                                      resets=expResults['resets'],
                                      randoms=expResults['randoms'])
      idx = numpy.array([i for i in range(len(x)) if x[i] > killCellAt])
      accuracy = numpy.array(accuracy)
      accuracyList.append(float(numpy.sum(accuracy[idx])) / len(accuracy[idx]))
    meanAccuracy.append(numpy.mean(accuracyList))
    stdAccuracy.append(numpy.std(accuracyList))
  return meanAccuracy, stdAccuracy
コード例 #3
0
def loadExperiment(experiment):
  print "Loading experiment ", experiment
  data = readExperiment(experiment)
  (accuracy, x) = computeAccuracy(data['predictions'],
                                  data['truths'],
                                  data['iterations'],
                                  resets=data['resets'],
                                  randoms=data['randoms'])
  return (accuracy, x)
コード例 #4
0
def loadExperiment(experiment):
    print "Loading experiment ", experiment
    data = readExperiment(experiment)
    (accuracy, x) = computeAccuracy(data['predictions'],
                                    data['truths'],
                                    data['iterations'],
                                    resets=data['resets'],
                                    randoms=data['randoms'])
    return (accuracy, x)
コード例 #5
0
from plot import readExperiment
mpl.rcParams['pdf.fonttype'] = 42
pyplot.ion()
pyplot.close('all')

if __name__ == '__main__':

    experiments = [
        os.path.join("lstm/results", "high-order-noise",
                     "inject_noise_after0.0", "0.log"),
        os.path.join("tm/results", "high-order-noise", "inject_noise_after0.0",
                     "0.log")
    ]

    for experiment in experiments:
        data = readExperiment(experiment)
        (accuracy, x) = computeAccuracy(data['predictions'],
                                        data['truths'],
                                        data['iterations'],
                                        resets=data['resets'],
                                        randoms=data['randoms'])

        plotAccuracy((accuracy, x),
                     data['trains'],
                     window=100,
                     type=type,
                     label='NoiseExperiment',
                     hideTraining=True,
                     lineSize=1.0)
        pyplot.xlim([10500, 14500])
        pyplot.xlabel('Number of elements seen')
コード例 #6
0
plt.ion()
plt.close('all')

if __name__ == '__main__':

  outdir = 'tm/result/'
  KILLCELL_PERCENT = list(numpy.arange(7) / 10.0)
  accuracyListTM = []
  accuracyListLSTM = []
  accuracyListELM = []
  for killCellPercent in KILLCELL_PERCENT:
    # HTM experiments
    experiment = os.path.join(outdir, "kill_cell_percent{:1.1f}".format(
      killCellPercent)) + '/0.log'

    expResults = readExperiment(experiment)

    killCellAt = 10000
    (accuracy, x) = computeAccuracy(expResults['predictions'][killCellAt:],
                                    expResults['truths'][killCellAt:],
                                    expResults['iterations'][killCellAt:],
                                    resets=expResults['resets'][killCellAt:],
                                    randoms=expResults['randoms'][killCellAt:])
    accuracyListTM.append(float(numpy.sum(accuracy)) / len(accuracy))

    # LSTM experiments
    experiment = 'lstm/results/high-order-distributed-random-kill-cell/' \
                 'kill_cell_percent' + "{:1.2f}".format(killCellPercent) + '/0.log'

    expResults = readExperiment(experiment)
コード例 #7
0
mpl.rcParams['pdf.fonttype'] = 42
pyplot.ion()

if __name__ == '__main__':

    outdir = 'tm/result/'
    KILLCELL_PERCENT = list(numpy.arange(7) / 10.0)
    accuracyListTM = []
    accuracyListLSTM = []
    for killCellPercent in KILLCELL_PERCENT:
        experiment = os.path.join(
            outdir,
            "kill_cell_percent{:1.1f}".format(killCellPercent)) + '/0.log'

        (predictions, truths, iterations, resets, randoms, trains,
         killCell) = readExperiment(experiment)

        killCellAt = 10000
        (accuracy, x) = computeAccuracy(predictions[killCellAt:],
                                        truths[killCellAt:],
                                        iterations[killCellAt:],
                                        resets=resets[killCellAt:],
                                        randoms=randoms[killCellAt:])

        accuracyListTM.append(float(numpy.sum(accuracy)) / len(accuracy))

        experiment = 'lstm/results/high-order-distributed-random-kill-cell/' \
                     'kill_cell_percent' + "{:1.2f}".format(killCellPercent) + '/0.log'

        (predictions, truths, iterations, resets, randoms,
         killCell) = readExperiment(experiment)
コード例 #8
0
  lengths = [10, 20, 40, 60, 80, 100]

  tmResults = os.path.join("tm/results",
                           "high-order-variable-length")

  try:
    # Load raw experiment results
    # You have to run the experiments in ./tm
    # python tm_suite.py --experiment="high-order-variable-length" -d
    expResults = {}
    for length in lengths:
      experiment = os.path.join(tmResults,
                                "sequence_length"+"{:.1f}".format(length),
                                "0.log")
      print "Load Experiment", experiment
      data = readExperiment(experiment)

      (accuracy, numIteration, numSequences) = computeAccuracyEnding(
        data['predictions'],
        data['truths'],
        data['iterations'],
        resets=data['resets'],
        randoms=data['randoms'],
        sequenceCounter=data['sequenceCounter'])


      (accuracyAll, numIterationAll, numSequencesAll) = computeAccuracy(
        data['predictions'],
        data['truths'],
        data['iterations'],
        resets=data['resets'],