@@ -166,7 +166,7 @@ Release date: 1 June 2020
166
166
6. The name of the ``pygad.nn.train_network() `` function is changed to
167
167
``pygad.nn.train() ``.
168
168
169
- .. _header-n214 :
169
+ .. _header-n77 :
170
170
171
171
PyGAD 2.4.0
172
172
-----------
@@ -183,28 +183,124 @@ Release date: 5 July 2020
183
183
algorithm if it returns the string ``stop ``. This causes the
184
184
``run() `` method to stop.
185
185
186
- One important use case for that feature is to stop the genetic
187
- algorithm when a condition is met before passing though all the
188
- generations. The user may assigned a value of 100 to the
189
- ``num_generations `` parameter of the pygad.GA class constructor.
190
- Assuming that at generation 50, for example, a condition is met and
191
- the user wants to stop the execution before waiting the remaining 50
192
- generations. To do that, just make the function passed to the
193
- ``callback_generation `` parameter to return the string ``stop ``.
186
+ One important use case for that feature is to stop the genetic algorithm
187
+ when a condition is met before passing though all the generations. The
188
+ user may assigned a value of 100 to the ``num_generations `` parameter of
189
+ the pygad.GA class constructor. Assuming that at generation 50, for
190
+ example, a condition is met and the user wants to stop the execution
191
+ before waiting the remaining 50 generations. To do that, just make the
192
+ function passed to the ``callback_generation `` parameter to return the
193
+ string ``stop ``.
194
+
195
+ Here is an example of a function to be passed to the
196
+ ``callback_generation `` parameter which stops the execution if the
197
+ fitness value 70 is reached. The value 70 might be the best possible
198
+ fitness value. After being reached, then there is no need to pass
199
+ through more generations because no further improvement is possible.
194
200
195
- Here is an example of a function to be passed to the
196
- ``callback_generation `` parameter which stops the execution if the
197
- fitness value 70 is reached. The value 70 might be the best possible
198
- fitness value. After being reached, then there is no need to pass
199
- through more generations because no further improvement is possible.
200
-
201
- .. code :: python
201
+ .. code :: python
202
202
203
203
def func_generation (ga_instance ):
204
204
if ga_instance.best_solution()[1 ] >= 70 :
205
205
return " stop"
206
206
207
- .. _header-n219 :
207
+ .. _header-n225 :
208
+
209
+ PyGAD 2.5.0
210
+ -----------
211
+
212
+ Release date: 19 July 2020
213
+
214
+ 1. | 2 new optional parameters added to the constructor of the
215
+ ``pygad.GA `` class which are ``crossover_probability `` and
216
+ ``mutation_probability ``.
217
+ | While applying the crossover operation, each parent has a random
218
+ value generated between 0.0 and 1.0. If this random value is less
219
+ than or equal to the value assigned to the
220
+ ``crossover_probability`` parameter, then the parent is selected
221
+ for the crossover operation.
222
+ | For the mutation operation, a random value between 0.0 and 1.0 is
223
+ generated for each gene in the solution. If this value is less than
224
+ or equal to the value assigned to the ``mutation_probability``,
225
+ then this gene is selected for mutation.
226
+
227
+ 2. A new optional parameter named ``linewidth `` is added to the
228
+ ``plot_result() `` method to specify the width of the curve in the
229
+ plot. It defaults to 3.0.
230
+
231
+ 3. Previously, the indices of the genes selected for mutation was
232
+ randomly generated once for all solutions within the generation.
233
+ Currently, the genes' indices are randomly generated for each
234
+ solution in the population. If the population has 4 solutions, the
235
+ indices are randomly generated 4 times inside the single generation,
236
+ 1 time for each solution.
237
+
238
+ 4. Previously, the position of the point(s) for the single-point and
239
+ two-points crossover was(were) randomly selected once for all
240
+ solutions within the generation. Currently, the position(s) is(are)
241
+ randomly selected for each solution in the population. If the
242
+ population has 4 solutions, the position(s) is(are) randomly
243
+ generated 4 times inside the single generation, 1 time for each
244
+ solution.
245
+
246
+ 5. A new optional parameter named ``gene_space `` as added to the
247
+ ``pygad.GA `` class constructor. It is used to specify the possible
248
+ values for each gene in case the user wants to restrict the gene
249
+ values. It is useful if the gene space is restricted to a certain
250
+ range or to discrete values.
251
+
252
+ Assuming that all genes have the same global space which include the
253
+ values 0.3, 5.2, -4, and 8, then those values can be assigned to the
254
+ ``gene_space `` parameter as a list, tuple, or range. Here is a list
255
+ assigned to this parameter. By doing that, then the gene values are
256
+ restricted to those assigned to the ``gene_space `` parameter.
257
+
258
+ .. code :: python
259
+
260
+ gene_space = [0.3 , 5.2 , - 4 , 8 ]
261
+
262
+ If some genes have different spaces, then ``gene_space `` should accept a
263
+ nested list or tuple. In this case, its elements could be:
264
+
265
+ 1. List, tuple, or range: It holds the individual gene space.
266
+
267
+ 2. Number (int/float): A single value to be assigned to the gene. This
268
+ means this gene will have the same value across all generations.
269
+
270
+ 3. ``None ``: A gene with its space set to ``None `` is initialized
271
+ randomly from the range specified by the 2 parameters
272
+ ``init_range_low `` and ``init_range_high ``. For mutation, its value
273
+ is mutated based on a random value from the range specified by the 2
274
+ parameters ``random_mutation_min_val `` and
275
+ ``random_mutation_max_val ``. If all elements in the ``gene_space ``
276
+ parameter are ``None ``, the parameter will not have any effect.
277
+
278
+ Assuming that a chromosome has 2 genes and each gene has a different
279
+ value space. Then the ``gene_space `` could be assigned a nested
280
+ list/tuple where each element determines the space of a gene. According
281
+ to the next code, the space of the first gene is [0.4, -5] which has 2
282
+ values and the space for the second gene is [0.5, -3.2, 8.8, -9] which
283
+ has 4 values.
284
+
285
+ .. code :: python
286
+
287
+ gene_space = [[0.4 , - 5 ], [0.5 , - 3.2 , 8.2 , - 9 ]]
288
+
289
+ For a 2 gene chromosome, if the first gene space is restricted to the
290
+ discrete values from 0 to 4 and the second gene is restricted to the
291
+ values from 10 to 19, then it could be specified according to the next
292
+ code.
293
+
294
+ .. code :: python
295
+
296
+ gene_space = [range (5 ), range (10 , 20 )]
297
+
298
+ If the user did not assign the initial population to the
299
+ ``initial_population `` parameter, the the initial population is created
300
+ randomly based on the ``gene_space `` parameter. Moreover, the mutation
301
+ is applied based on this parameter.
302
+
303
+ .. _header-n224 :
208
304
209
305
PyGAD Projects at GitHub
210
306
========================
@@ -214,7 +310,7 @@ https://pypi.org/project/pygad. PyGAD is built out of a number of
214
310
open-source GitHub projects. A brief note about these projects is given
215
311
in the next subsections.
216
312
217
- .. _header-n79 :
313
+ .. _header-n89 :
218
314
219
315
`GeneticAlgorithmPython <https://github.com/ahmedfgad/GeneticAlgorithmPython >`__
220
316
--------------------------------------------------------------------------------
@@ -225,7 +321,7 @@ GitHub Link: https://github.com/ahmedfgad/GeneticAlgorithmPython
225
321
is the first project which is an open-source Python 3 project for
226
322
implementing the genetic algorithm based on NumPy.
227
323
228
- .. _header-n82 :
324
+ .. _header-n92 :
229
325
230
326
`NumPyANN <https://github.com/ahmedfgad/NumPyANN >`__
231
327
----------------------------------------------------
@@ -239,7 +335,7 @@ neural network without using a training algorithm. Currently, it only
239
335
supports classification and later regression will be also supported.
240
336
Moreover, only one class is supported per sample.
241
337
242
- .. _header-n85 :
338
+ .. _header-n95 :
243
339
244
340
`NeuralGenetic <https://github.com/ahmedfgad/NeuralGenetic >`__
245
341
--------------------------------------------------------------
@@ -252,7 +348,7 @@ projects
252
348
`GeneticAlgorithmPython <https://github.com/ahmedfgad/GeneticAlgorithmPython >`__
253
349
and `NumPyANN <https://github.com/ahmedfgad/NumPyANN >`__.
254
350
255
- .. _header-n88 :
351
+ .. _header-n98 :
256
352
257
353
`NumPyCNN <https://github.com/ahmedfgad/NumPyCNN >`__
258
354
----------------------------------------------------
@@ -264,7 +360,7 @@ convolutional neural networks using NumPy. The purpose of this project
264
360
is to only implement the **forward pass ** of a convolutional neural
265
361
network without using a training algorithm.
266
362
267
- .. _header-n91 :
363
+ .. _header-n101 :
268
364
269
365
`CNNGenetic <https://github.com/ahmedfgad/CNNGenetic >`__
270
366
--------------------------------------------------------
@@ -276,7 +372,7 @@ convolutional neural networks using the genetic algorithm. It uses the
276
372
`GeneticAlgorithmPython <https://github.com/ahmedfgad/GeneticAlgorithmPython >`__
277
373
project for building the genetic algorithm.
278
374
279
- .. _header-n94 :
375
+ .. _header-n104 :
280
376
281
377
Submitting Issues
282
378
=================
@@ -293,7 +389,7 @@ is not working properly or to ask for questions.
293
389
If this is not a proper option for you, then check the **Contact Us **
294
390
section for more contact details.
295
391
296
- .. _header-n98 :
392
+ .. _header-n108 :
297
393
298
394
Ask for Feature
299
395
===============
@@ -310,7 +406,7 @@ to ahmed.f.gad@gmail.com.
310
406
311
407
Also check the **Contact Us ** section for more contact details.
312
408
313
- .. _header-n102 :
409
+ .. _header-n112 :
314
410
315
411
Projects Built using PyGAD
316
412
==========================
@@ -329,15 +425,15 @@ Within your message, please send the following details:
329
425
330
426
- Preferably, a link that directs the readers to your project
331
427
332
- .. _header-n113 :
428
+ .. _header-n123 :
333
429
334
430
For More Information
335
431
====================
336
432
337
433
There are different resources that can be used to get started with the
338
434
genetic algorithm and building it in Python.
339
435
340
- .. _header-n115 :
436
+ .. _header-n125 :
341
437
342
438
Tutorial: Implementing Genetic Algorithm in Python
343
439
--------------------------------------------------
@@ -361,7 +457,7 @@ good resource to start with coding the genetic algorithm.
361
457
362
458
|image0 |
363
459
364
- .. _header-n126 :
460
+ .. _header-n136 :
365
461
366
462
Tutorial: Introduction to Genetic Algorithm
367
463
-------------------------------------------
@@ -380,7 +476,7 @@ which is available at these links:
380
476
381
477
|image1 |
382
478
383
- .. _header-n136 :
479
+ .. _header-n146 :
384
480
385
481
Tutorial: Build Neural Networks in Python
386
482
-----------------------------------------
@@ -400,7 +496,7 @@ available at these links:
400
496
401
497
|image2 |
402
498
403
- .. _header-n146 :
499
+ .. _header-n156 :
404
500
405
501
Tutorial: Optimize Neural Networks with Genetic Algorithm
406
502
---------------------------------------------------------
@@ -420,7 +516,7 @@ available at these links:
420
516
421
517
|image3 |
422
518
423
- .. _header-n156 :
519
+ .. _header-n166 :
424
520
425
521
Tutorial: Building CNN in Python
426
522
--------------------------------
@@ -446,7 +542,7 @@ good resource to start with coding CNNs.
446
542
447
543
|image4 |
448
544
449
- .. _header-n169 :
545
+ .. _header-n179 :
450
546
451
547
Tutorial: Derivation of CNN from FCNN
452
548
-------------------------------------
@@ -465,7 +561,7 @@ which is available at these links:
465
561
466
562
|image5 |
467
563
468
- .. _header-n179 :
564
+ .. _header-n189 :
469
565
470
566
Book: Practical Computer Vision Applications Using Deep Learning with CNNs
471
567
--------------------------------------------------------------------------
@@ -491,7 +587,7 @@ Find the book at these links:
491
587
.. figure :: https://user-images.githubusercontent.com/16560492/78830077-ae7c2800-79e7-11ea-980b-53b6bd879eeb.jpg
492
588
:alt:
493
589
494
- .. _header-n194 :
590
+ .. _header-n204 :
495
591
496
592
Contact Us
497
593
==========
0 commit comments