Ejemplo n.º 1
0
    def generate_statistics(self, filename=TRAINING_DATA_FILENAME):
        """
        Run the module. Play 2048 50 times using random player, then 50 times using the neural network. Report results.

        :return: Results from all 100 playings, in two lists. One list for random, and one for intelligent
        """

        results = []

        try:
            for _ in range(50):
                # Training the neural network
                self.ann = Ann(self.hidden_layer_sizes,
                               self.activation_functions, 16, 4,
                               self.learning_rate, self.error_limit,
                               self.batch_size, self.max_epochs)
                self.train(filename)

                # Playing using the neural network
                results.append(self.play_intelligently())
        except KeyboardInterrupt:
            pass

        logging.info(
            'Completed playing the intelligent games. Mean highest value: %f' %
            numpy.mean(results))

        return results
Ejemplo n.º 2
0
    def __init__(self,
                 hidden_layer_sizes,
                 activation_functions,
                 max_epochs,
                 learning_rate,
                 error_limit,
                 batch_size=100):
        self.hidden_layer_sizes = hidden_layer_sizes
        self.activation_functions = activation_functions
        self.max_epochs = max_epochs
        self.learning_rate = learning_rate
        self.error_limit = error_limit
        self.batch_size = batch_size

        self.ann = Ann(hidden_layer_sizes, activation_functions, 16, 4,
                       learning_rate, error_limit, batch_size, max_epochs)
Ejemplo n.º 3
0
 def __init__(self, hidden_layer_sizes, activation_functions, learning_rate=0.1, error_limit=1e-4, max_epochs=50):
     self.ann = Ann(hidden_layer_sizes, activation_functions, learning_rate=learning_rate,
                    error_limit=error_limit, max_epochs=max_epochs)