Module circle_evolution.evolution
a target image.
Attributes:
- size (tuple): tuple containing height and width of target image (h, w).
+ size (tuple): tuple containing np.shape of target image.
target (np.ndarray): target image for evolution.
genes (int): the amount of circle to train the target image on.
generation (int): amount of generations Evolution class has trained.
specie (species.Specie): the Specie that is getting trained.
"""
- def __init__(self, size, target, genes=5):
+ def __init__(self, target, genes=100):
"""Initializes Evolution class.
Args:
- size (tuple): tuple containing height and width of target image (h, w).
target (np.ndarray): target image for evolution.
genes (int): the amount of circle to train the target image on.
"""
- self.size = size # Tuple (y, x)
+ self.size = target.shape
self.target = target # Target Image
self.generation = 1
self.genes = genes
@@ -78,16 +79,16 @@ Module circle_evolution.evolution
# Randomization for Evolution
y = random.randint(0, self.genes - 1)
- change = random.randint(0, 6)
+ change = random.randint(0, new_specie.genotype_width + 1)
- if change >= 6:
+ if change >= new_specie.genotype_width + 1:
change -= 1
i, j = y, random.randint(0, self.genes - 1)
i, j, s = (i, j, -1) if i < j else (j, i, 1)
new_specie.genotype[i : j + 1] = np.roll(new_specie.genotype[i : j + 1], shift=s, axis=0)
y = j
- selection = np.random.choice(5, size=change, replace=False)
+ selection = np.random.choice(new_specie.genotype_width, size=change, replace=False)
if random.random() < 0.25:
new_specie.genotype[y, selection] = np.random.rand(len(selection))
@@ -143,7 +144,7 @@ Classes
class Evolution -(size, target, genes=5) +(target, genes=100)
-
Logic for a Species Evolution.
@@ -152,7 +153,7 @@Classes
Attributes
size
:tuple
-- tuple containing height and width of target image (h, w). +
- tuple containing np.shape of target image.
target
:np.ndarray
- target image for evolution.
genes
:int
@@ -165,8 +166,6 @@ size
:tuple
-- tuple containing height and width of target image (h, w).
target
:np.ndarray
- target image for evolution.
genes
:int
@@ -183,22 +182,21 @@
Attributes
Initializes Evolution class.
Args
-
-
Args
a target image. Attributes: - size (tuple): tuple containing height and width of target image (h, w). + size (tuple): tuple containing np.shape of target image. target (np.ndarray): target image for evolution. genes (int): the amount of circle to train the target image on. generation (int): amount of generations Evolution class has trained. specie (species.Specie): the Specie that is getting trained. """ - def __init__(self, size, target, genes=5): + def __init__(self, target, genes=100): """Initializes Evolution class. Args: - size (tuple): tuple containing height and width of target image (h, w). target (np.ndarray): target image for evolution. genes (int): the amount of circle to train the target image on. """ - self.size = size # Tuple (y, x) + self.size = target.shape self.target = target # Target Image self.generation = 1 self.genes = genes @@ -218,16 +216,16 @@Args
# Randomization for Evolution y = random.randint(0, self.genes - 1) - change = random.randint(0, 6) + change = random.randint(0, new_specie.genotype_width + 1) - if change >= 6: + if change >= new_specie.genotype_width + 1: change -= 1 i, j = y, random.randint(0, self.genes - 1) i, j, s = (i, j, -1) if i < j else (j, i, 1) new_specie.genotype[i : j + 1] = np.roll(new_specie.genotype[i : j + 1], shift=s, axis=0) y = j - selection = np.random.choice(5, size=change, replace=False) + selection = np.random.choice(new_specie.genotype_width, size=change, replace=False) if random.random() < 0.25: new_specie.genotype[y, selection] = np.random.rand(len(selection)) @@ -346,16 +344,16 @@Returns
# Randomization for Evolution y = random.randint(0, self.genes - 1) - change = random.randint(0, 6) + change = random.randint(0, new_specie.genotype_width + 1) - if change >= 6: + if change >= new_specie.genotype_width + 1: change -= 1 i, j = y, random.randint(0, self.genes - 1) i, j, s = (i, j, -1) if i < j else (j, i, 1) new_specie.genotype[i : j + 1] = np.roll(new_specie.genotype[i : j + 1], shift=s, axis=0) y = j - selection = np.random.choice(5, size=change, replace=False) + selection = np.random.choice(new_specie.genotype_width, size=change, replace=False) if random.random() < 0.25: new_specie.genotype[y, selection] = np.random.rand(len(selection)) @@ -421,9 +419,7 @@-
Generated by pdoc 0.8.1.
+Generated by pdoc 0.9.1.
- -