Build neurons as proper OOP objects on GPU and see what emerges. Not trying to rediscover matrix multiplication — exploring what the object paradigm reveals about neural computation.
Links: AI History — Personal Arc, ELIZA, Cyborg Model, Cognitive vs. Motor Skills, PyTorch Learning
Chris coded ELIZA as an early project. Later, realized neurons map perfectly to OOP objects — encapsulated state, defined behavior, uniform interface, natural composition. But never explored what happens when you actually BUILD a network this way on modern hardware.
This is NOT about recreating TensorFlow. Matrix multiplication is the efficient way to compute neural networks. The question is: what does the OOP representation reveal that the matrix representation hides?
class Neuron:
def __init__(self, activation='relu'):
self.weights = {} # {input_neuron: weight}
self.bias = 0.0
self.activation = activation
self.output = 0.0
self.history = [] # for inspection/debugging
def forward(self, inputs: dict) -> float:
total = sum(self.weights[n] * inputs[n] for n in self.weights) + self.bias
self.output = activate(total, self.activation)
self.history.append(self.output)
return self.output
def connect(self, source_neuron, weight=None):
self.weights[source_neuron] = weight or random()
def hebbian_update(self, learning_rate=0.01):
# "Neurons that fire together wire together"
for source, weight in self.weights.items():
self.weights[source] += learning_rate * source.output * self.output
OOP on GPU is the hard part. Options:
The hybrid approach is probably realistic for exploration — keep the object graph on CPU, vectorize the forward pass, but maintain per-neuron state and history for inspection.