Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bigbird

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bigbird

Genetic Algorithms in Python

  • 0.1.2
  • PyPI
  • Socket score

Maintainers
1

Big Bird

Big Bird is a (hopefully useful) package designed to facilitate the quick and convenient creation of basic genetic algorithms in python.

Examples

import bigbird

# Config Parameters for Big Bird
pop_size = 2000             # Size of each generation's population
layer_counts = [8, 5, 5, 3] # No. of nodes in each layer
m_r8 = 0.3                  # Chance of weight mutation
step_ratio = 1/3.6          # Size of weight perturbation
reinit_r = 0.015            # Chance of weight reinitialization on mutation
immune = 20                 # No. of non-mutated from top of previous generation

# When to automatically stop training
max_generation = 300

# Create a population with configuration parameters
population = bigbird.SimplePopulation(pop_size, layer_counts)

for generation in range(max_generation):
    for bird in population.birds:
        # Evaluates a bird's fitness based on a given input
        bird_inp = your_input_generation_fn()
        bird_out = bird.eval(bird_inp)
        decision = output.tolist().index(max(output))
        bird.fitness = your_fitness_fn(decision)

    # Saves the best performing bird's weight matrices
    champ = sorted(population.birds, key=lambda x: x.fitness)[-1]
    champ.save(fname='./hall-of-fame/champ-' + str(generation) + '.json')

    # Iniitializes next generation
    population.store(immune)
    population.breed()
    population.mutate(m_r8, step_ratio, reinit=reinit_r)
    population.retrieve()

Find more examples here

License

MIT

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc