Пример #1
0
 def setUp(self):
     self.R = np.asarray([[ 1.0,  0.4, -0.4],
                          [ 0.4,  1.0,  0.6],
                          [-0.4,  0.6,  1.0]])
     self.mu = [100.0] * 3
     self.sigma = [10.0] * 3
     self.cov = rewards.cor2cov(self.R, self.sigma)
     self.maze = grid.make_multimaze(4, 4, 3)
     self.goals = grid.maze_goal_states(self.maze, 3, self.mu, self.cov)
Пример #2
0
        args.stdev = np.ones(args.tasks)
    else:
        args.stdev = np.asarray(ast.literal_eval(args.stdev))
        
    # compute a covariance matrix from the correlation matrix and standard deviations
    cov = rwd.cor2cov(args.correlation, args.stdev)
    if not rwd.is_pos_def(cov):
        print('Error: covariance matrix must be positive definite', file=sys.stderr)
        sys.exit(1)


    # maze type instances
    if args.type == 'maze':
        # TODO: incorporate correlated rewards somehow
        maze = grd.make_multimaze(args.rows, args.cols, args.tasks)
        goals = grd.maze_goal_states(maze, args.tasks, args.rmeans, cov)
        io.write_maze_instance(maze, goals)
        print('# type={}, rows={}, cols={}, correlation={}, stdev={}'.
              format(args.type, args.rows, args.cols, args.correlation.tolist(), args.stdev.tolist()))


    # perturbation of existing instances
    elif args.type == 'perturbation':
        if not args.baseline:
            parser.print_help()
            sys.exit(1)
        else:
            # TODO: handle other kinds of models
            (net, trainset) = io.read_neural_net(args.baseline)
            net2 = net.fuzz_neural_net(net, args.fuzz_frac, args.fuzz_scale)
            io.write_neural_net(net2, trainset, 'fuzzed.net')