harvitronix / neural-network-genetic-algorithm

Evolving a neural network with a genetic algorithm.
https://medium.com/@harvitronix/lets-evolve-a-neural-network-with-a-genetic-algorithm-code-included-8809bece164
MIT License
693 stars 237 forks source link

How to run? #7

Open nullFoo opened 6 years ago

nullFoo commented 6 years ago

So you have the defined functions but how do you run it? I don't know what to put as the "self" parameter of all the functions

de-sh commented 5 years ago

'self' is supposed to be not interfaced with by the programmer. It is for the program/interpreter to understand that the method works on the instance/object for which it is defined.

As for running the program, read this part of the README.md

xWuWux commented 9 months ago

Understanding the "self" Parameter: In Python, when defining methods within a class, the first parameter is conventionally named self. This parameter represents the instance of the class and allows methods to access and modify the attributes of the instance. However, when calling these methods, you don't explicitly pass a value for self– Python automatically handles it.

How to Run the Program: Command Line:

Open a terminal or command prompt. Navigate to the directory where the Python scripts (brute.py, network.py, train.py) are located. Run brute.py:

Execute the following command: python3 brute.py

This will initiate the brute force testing of every network. Understanding self in the Context of the Program:

When you run brute.py, it creates instances of the Network class and calls methods on those instances. For example, network_obj.create_random() creates a random network for network_obj, and network_obj.train(dataset) trains the network. You don't need to explicitly pass a value for self – Python takes care of that. Viewing Results:

The program will print information about the trained networks, including their parameters and accuracy. The top 5 networks with the highest accuracy will be displayed.