I am trying to make a classifier.
I am new to AI (even if I know the definition and all such a bit) , and also I have no idea of how to implement it properly by myself even if I know a bit of Python coding (in fact, I am fifteen years old !🙄🙄), but my passion for this has made me ask this (silly, probably) question.
Are there neural networks where nodes are randomly selected from among a set of nodes (in random orders and a random number of times)? I know this is from ML (or maybe deep learning, I suppose), but I have no idea how to recognize such a thing from the presently available algorithms. It will be great if you all could help me, because I am preparing to release an API for programming a model which I call the 'Insane Mind' on GitHub, and I want some help to know if my effort was fruitless.
And for reference, here's the code :
from math import *
from random import *
class MachineError(Exception):
'''standard exception in the API'''
def __init__(self, stmt):
self.stmt = stmt
def sig(x):
'''Sigmoid function'''
return (exp(x) + 1)/exp(x)
class Graviton:
def __init__(self, weight, marker):
'''Basic unit in 'Insane Mind' algorithm
-------------------------------------
Graviton simply refers to a node in the algorithm.
I call it graviton because of the fact that it applies a weight
on the input to transform it, besides using the logistic function '''
self.weight = weight # Weight factor of the graviton
self.marker = marker # Marker to help in sorting
self.input = 0 # Input to the graviton
self.output = 0 # Output of the graviton
self.derivative = 0 # Derivative of the output
def process(self, input_to_machine):
'''processes the input (a bit of this is copied from the backprop algorithm'''
self.input = input_to_machine
self.output = (sig(self.weight * self.input) - 1)/(self.marker + 1)
self.derivative = (sig(self.input * self.weight) - 1) * self.input *self.output * (1- self.output)
return self.output
def get_derivative_at_input(self):
'''returns the derivative of the output'''
return self.derivative
def correct_self(self, learning_rate, error):
'''edits the weight'''
self.weight += -1 * error * learning_rate * self.get_derivative_at_input() * self.weight
class Insane_Mind:
def __init__(self, number_of_nodes):
'''initialiser for Insane_Mind class.
arguments : number_of_nodes : the number of nodes you want in the model'''
self.system = [Graviton(random(),i) for i in range(number_of_nodes)] # the actual system
self.system_size = number_of_nodes # number of nodes , or 'system size'
def output_sys(self, input_to_sys):
'''system output'''
self.output = input_to_sys
for i in range(self.system_size):
self.output = self.system[randint(0,self.system_size - 1 )].process(self.output)
return self.output
def train(self, learning_rate, wanted):
'''trains the system'''
self.cloned = [] # an array to keep the sorted elements during the sorting process below
order = [] # the array to make out the order of arranging the nodes
temp = {} # a temporary dictionary to pick the nodes from
for graviton in self.system:
temp.update({str(graviton.derivative): graviton.marker})
order = sorted(temp)
i = 0
error = wanted - self.output
for value in order:
self.cloned.append(self.system[temp[value]])
self.cloned[i].correct_self(learning_rate, error)
error *= self.cloned[i].derivative
i += 1
self.system = self.cloned
Sorry for not using that MachineError
exception anywhere in my code (I will use it when I am able to deploy this API).
To tell more about this algorithm, this gives randomized outputs (as if guessing). The number of guesses vary from 1 (for a system with one node), 2 (for two nodes) and so on to an infinite number of guesses for an infinite number of nodes.
Also, I wanna try and find how much it can be of use (if this is something that has never been discovered, if it is something that can find a good place in the world of ML or Deep Learning) and where it can be used.
Thanks in advance.
Criticisms (with a clear reason) are also accepted.