commit 9c515aba8eea511f49cead100af4f857375f395c Author: Sabic Date: Mon Jun 24 15:52:44 2024 +0200 first commit diff --git a/generate_dataset.py b/generate_dataset.py new file mode 100644 index 0000000..daa108f --- /dev/null +++ b/generate_dataset.py @@ -0,0 +1,29 @@ +import numpy as np +import matplotlib.pyplot as plt + +# Parameters +num_points = 1000 # Number of data points +radius = 5 # Radius to separate the classes + +# Generate random (x, y) coordinates +x = np.random.uniform(-10, 10, num_points) +y = np.random.uniform(-10, 10, num_points) + +# Calculate distance from the origin +distance = np.sqrt(x**2 + y**2) + +# Class labels: 0 for inside the radius, 1 for outside the radius +labels = (distance > radius).astype(int) + +# Plot the dataset +plt.figure(figsize=(8, 8)) +plt.scatter(x[labels == 0], y[labels == 0], color='blue', label='Class 0 (Inside radius)') +plt.scatter(x[labels == 1], y[labels == 1], color='red', label='Class 1 (Outside radius)') +plt.axhline(0, color='black',linewidth=0.5) +plt.axvline(0, color='black',linewidth=0.5) +plt.grid(color = 'gray', linestyle = '--', linewidth = 0.5) +plt.xlabel('X') +plt.ylabel('Y') +plt.title('Generated Dataset for Classification Task') +plt.legend() +plt.show() diff --git a/main.py b/main.py new file mode 100644 index 0000000..401f416 --- /dev/null +++ b/main.py @@ -0,0 +1,29 @@ +import numpy as np +from random import random + +neurons_per_layer = 4 +layers = 2 +inputs = 2 +outputs = 1 + +grid_min = -10 +grid_max = 10 + +biases = [[] for _ in range(layers)] + +for i in range(0, neurons_per_layer) + +weights = [[] for _ in range(layers+2)] + +# Input layer to first hidden layer weights +weights[0] = [random() for _ in range(inputs*neurons_per_layer)] + +for i in range(1, layers+1): + # Weights between hidden layers + weights[i] = [random() for _ in range(neurons_per_layer ** 2)] + +# Weights from last hidden layer to output layer +weights[-1] = [random() for _ in range(outputs*neurons_per_layer)] + +def sigmoid(x): + return np.exp(-np.logaddexp(0, -x))