AiSc 11

Pasted Nov 4, 2026, 3:50 PM1 file26 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/ai11
untitled
import numpy as np

# Bipolar Input pattern and Output
X = np.array([1, -1, 1])
y = 1

learning_rate = 1.0
initial_weights = np.array([0.0, 0.0, 0.0])


def hebbian_update(weights, inputs, output, lr):
    # Delta W = learning_rate * input * output
    delta_w = lr * inputs * output

    new_weights = weights + delta_w

    return new_weights, delta_w


final_w, change = hebbian_update(
    initial_weights, X, y, learning_rate
)

print("Initial Weights: ", initial_weights)
print("Weight Delta:    ", change)
print("Updated Weights: ", final_w)

548 chars · codepastes.com