genetic/genetic_algo.py
def generate_initial_population(N, data, population_size = 20, depth = 5):
    """
    population size is the number of individuals in the population
    N refers to the number of nodes
    depth refers to then number of layers

    population_size: int
    N: int
    """
    genes = []
    while len(genes) < population_size:
        # we add a +1 to the circuit as use a |0> qubit for measurement
        genes.append(np.random.uniform(-np.pi, np.pi, [depth, N*2 + 1]))

    fitness, acc = get_fitness(genes, data)

    return PopulationPool(genes, fitness, acc)

    population size is the number of individuals in the population
    N refers to the number of nodes
    depth refers to then number of layers

    population_size: int
    N: int
    
population size is the number of individuals in the population
N refers to the number of nodes
depth refers to then number of layers

int
N: int
population size is the number of individuals in the population N refers to the number of nodes depth refers to then number of layers int N : int
def generate_initial_population(N, data, population_size = 20, depth = 5):
    genes = []
    while len(genes) < population_size:
        genes.append(np.random.uniform(-np.pi, np.pi, [depth, N*2 + 1]))
    fitness, acc = get_fitness(genes, data)
    return PopulationPool(genes, fitness, acc)
def generate_initial_population ( N , data , population_size = 20 , depth = 5 ) : genes = [ ] while len ( genes ) < population_size : genes . append ( np . random . uniform ( - np . pi , np . pi , [ depth , N * 2 + 1 ] ) ) fitness , acc = get_fitness ( genes , data ) return PopulationPool ( genes , fitness , acc )
population size is the number of individuals in the population
N refers to the number of nodes
depth refers to then number of layers
population size is the number of individuals in the population N refers to the number of nodes depth refers to then number of layers
"""
    population size is the number of individuals in the population
    N refers to the number of nodes
    depth refers to then number of layers

    population_size: int
    N: int
    """ # we add a +1 to the circuit as use a |0> qubit for measurement
N
data
population_size
depth