Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenomeHandler with max_pooling set to False returns error #38

Open
cordeirojoao opened this issue May 4, 2020 · 1 comment
Open

GenomeHandler with max_pooling set to False returns error #38

cordeirojoao opened this issue May 4, 2020 · 1 comment

Comments

@cordeirojoao
Copy link

Hello,
I was trying to implement the "hello world" example and exploring the GenomeHandler function parameters.
I was able to put the example running but once I set the max_pooling=False I get the error 'a' must be greater than 0 unless no samples are taken on the devol.run function

Can someone help me on that?

Code

(x_train, y_train), (x_test, y_test) = mnist.load_data()

x_train = x_train.reshape(x_train.shape[0],x_train.shape[1], x_train.shape[2], 1).astype('float32') / 255
x_test = x_test.reshape(x_test.shape[0], x_test.shape[1], x_test.shape[2], 1).astype('float32') / 255
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)
dataset = ((x_train, y_train), (x_test, y_test))

genome_handler = GenomeHandler(max_conv_layers=6 ,max_dense_layers=2,max_filters=256,max_dense_nodes=1024,input_shape=x_train.shape[1:],n_classes=10, batch_normalization=True, dropout=True, max_pooling=False)
devol = DEvol(genome_handler)
model = devol.run(dataset=dataset, num_generations=1,pop_size=1,epochs=1)

Error

ValueError                                Traceback (most recent call last)
<ipython-input-36-9cc5827c046e> in <module>
      2                   num_generations=1,
      3                   pop_size=1,
----> 4                   epochs=1)

c:\users\joao\documents\devol\devollib\devol\devol.py in run(self, dataset, num_generations, pop_size, epochs, fitness, metric)
    120 
    121         # generate and evaluate initial population
--> 122         members = self._generate_random_population(pop_size)
    123         pop = self._evaluate_population(members,
    124                                         epochs,

c:\users\joao\documents\devol\devollib\devol\devol.py in _generate_random_population(self, size)
    233 
    234     def _generate_random_population(self, size):
--> 235         return [self.genome_handler.generate() for _ in range(size)]
    236 
    237     def _print_result(self, fitness, generation):

c:\users\joao\documents\devol\devollib\devol\devol.py in <listcomp>(.0)
    233 
    234     def _generate_random_population(self, size):
--> 235         return [self.genome_handler.generate() for _ in range(size)]
    236 
    237     def _print_result(self, fitness, generation):

c:\users\joao\documents\devol\devollib\devol\genome_handler.py in generate(self)
    208             for key in self.convolutional_layer_shape:
    209                 param = self.layer_params[key]
--> 210                 genome.append(np.random.choice(param))
    211         for i in range(self.dense_layers):
    212             for key in self.dense_layer_shape:

mtrand.pyx in mtrand.RandomState.choice()

ValueError: 'a' must be greater than 0 unless no samples are taken
@cordeirojoao
Copy link
Author

@joeddav
Hello Joe.
I´m "stuck" on this step. I really would appreciate your help on this issue.
Thank you very much for your attention :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant