コード例 #1
0
    def loadExperiment(self, experiment):
        suite = Suite()
        suite.parse_opt()
        suite.parse_cfg()

        experiment_dir = experiment.split('/')[1]
        params = suite.items_to_params(suite.cfgparser.items(experiment_dir))
        self.params = params

        predictions = suite.get_history(experiment, 0, 'predictions')
        truth = suite.get_history(experiment, 0, 'truth')

        self.iteration = suite.get_history(experiment, 0, 'iteration')
        self.train = suite.get_history(experiment, 0, 'train')

        self.truth = np.array(truth, dtype=np.float)

        if params['output_encoding'] == 'likelihood':
            from nupic.encoders.scalar import ScalarEncoder as NupicScalarEncoder
            self.outputEncoder = NupicScalarEncoder(w=1,
                                                    minval=0,
                                                    maxval=40000,
                                                    n=22,
                                                    forced=True)
            predictions_np = np.zeros((len(predictions), self.outputEncoder.n))
            for i in xrange(len(predictions)):
                if predictions[i] is not None:
                    predictions_np[i, :] = np.array(predictions[i])
            self.predictions = predictions_np
        else:
            self.predictions = np.array(predictions, dtype=np.float)
コード例 #2
0
PADDING = 0
KERNEL_SIZE = 5


def computeMaxPool(input_width):
    """
  Compute CNN max pool width
  """
    wout = math.floor((input_width + 2 * PADDING - KERNEL_SIZE) / STRIDE + 1)
    return int(math.floor(wout / 2.0))


if __name__ == '__main__':
    suite = PyExperimentSuite()
    suite.parse_opt()
    suite.parse_cfg()
    experiments = suite.options.experiments or suite.cfgparser.sections()

    paramsTable = [[
        "Network", "L1 F", "L1 Sparsity", "L2 F", "L2 Sparsity", "L3 N",
        "L3 Sparsity", "Wt Sparsity"
    ]]
    for name in experiments:

        # Iterate over experiments, skipping over errors.
        try:
            exps = suite.get_exps(suite.get_exp(name)[0])
        except:
            print("Couldn't parse experiment:", name)
            continue