Skip to content

Instantly share code, notes, and snippets.

View ahmedfgad's full-sized avatar

Ahmed Gad ahmedfgad

View GitHub Profile
import socket
import pickle
import threading
import time
import numpy
import nn
import gann
import kivy.app
import socket
import pickle
import time
import numpy
import nn
import gann
class SocketThread(threading.Thread):
import threading
class ListenThread(threading.Thread):
def __init__(self, kivy_app):
threading.Thread.__init__(self)
self.kivy_app = kivy_app
def run(self):
while True:
import kivy.app
import kivy.uix.button
import kivy.uix.label
import kivy.uix.textinput
import kivy.uix.boxlayout
class ServerApp(kivy.app.App):
def __init__(self):
super().__init__()
import kivy.app
import kivy.uix.button
import kivy.uix.label
import kivy.uix.textinput
import kivy.uix.boxlayout
class ServerApp(kivy.app.App):
def build(self):
self.create_socket_btn = kivy.uix.button.Button(text="Create Socket", disabled=False)
import socket
import pickle
import threading
import time
import pygad
import pygad.nn
import pygad.gann
import numpy
def model_averaging(self, model, other_model):
model_weights = pygad.nn.layers_weights(last_layer=model, initial=False)
other_model_weights = pygad.nn.layers_weights(last_layer=other_model, initial=False)
new_weights = numpy.array(model_weights + other_model_weights)/2
pygad.nn.update_layers_trained_weights(last_layer=model, final_weights=new_weights)
# Preparing the NumPy array of the inputs.
data_inputs = numpy.array([[1, 1],
[1, 0],
[0, 1],
[0, 0]])
# Preparing the NumPy array of the outputs.
data_outputs = numpy.array([0,
1,
1,
import socket
import pickle
import numpy
import pygad
import pygad.nn
import pygad.gann
def fitness_func(solution, sol_idx):
global GANN_instance, data_inputs, data_outputs
import pygad
import pygad.nn
import pygad.gann
# Preparing the NumPy array of the inputs.
data_inputs = numpy.array([[0, 1],
[0, 0]])
# Preparing the NumPy array of the outputs.
data_outputs = numpy.array([1,