Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 31, 2024
1 parent fa6233a commit 2a8b201
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions neural_network/radial_basis_function_neural_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import numpy as np # For numerical operations


class RBFNN:
def __init__(self, input_size, hidden_size, output_size):
"""
Expand All @@ -32,17 +33,21 @@ def __init__(self, input_size, hidden_size, output_size):
self.spread = np.random.rand(hidden_size) # Spread for each RBF

Check failure on line 33 in neural_network/radial_basis_function_neural_network.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (NPY002)

neural_network/radial_basis_function_neural_network.py:33:23: NPY002 Replace legacy `np.random.rand` call with `np.random.Generator`

# Initialize weights for the output layer
self.weights = np.random.rand(hidden_size, output_size) # Weights for output layer
self.weights = np.random.rand(

Check failure on line 36 in neural_network/radial_basis_function_neural_network.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (NPY002)

neural_network/radial_basis_function_neural_network.py:36:24: NPY002 Replace legacy `np.random.rand` call with `np.random.Generator`
hidden_size, output_size
) # Weights for output layer

def rbf(self, x, center, spread):
""" Radial Basis Function (Gaussian). """
return np.exp(-np.linalg.norm(x - center) ** 2 / (2 * spread ** 2))
"""Radial Basis Function (Gaussian)."""
return np.exp(-(np.linalg.norm(x - center) ** 2) / (2 * spread**2))

def forward(self, x):
""" Forward pass through the network. """
"""Forward pass through the network."""
hidden_outputs = np.zeros(self.hidden_size) # Outputs of hidden layer
for i in range(self.hidden_size):
hidden_outputs[i] = self.rbf(x, self.centers[i], self.spread[i]) # Compute RBF outputs
hidden_outputs[i] = self.rbf(
x, self.centers[i], self.spread[i]
) # Compute RBF outputs

output = np.dot(hidden_outputs, self.weights) # Compute final output
return output
Expand Down

0 comments on commit 2a8b201

Please sign in to comment.