@@ -81,6 +81,8 @@ def _compute_rbf_outputs(self, input_data: np.ndarray) -> np.ndarray:
81
81
array([[1. , 0.60653066],
82
82
[0.60653066, 1. ]])
83
83
"""
84
+ assert self .centers is not None , "Centers initialized before computing outputs."
85
+
84
86
rbf_outputs = np .zeros ((input_data .shape [0 ], self .num_centers ))
85
87
for i , center in enumerate (self .centers ):
86
88
for j in range (input_data .shape [0 ]):
@@ -96,7 +98,7 @@ def fit(self, input_data: np.ndarray, target_values: np.ndarray) -> None:
96
98
target_values (np.ndarray): Target values (num_samples x output_dim).
97
99
98
100
Raises:
99
- ValueError: If number of samples in input_data and target_values do not match.
101
+ ValueError: If number of samples in input_data and target_values not match.
100
102
101
103
Examples:
102
104
>>> rbf_nn = RadialBasisFunctionNeuralNetwork(num_centers=2, spread=1.0)
@@ -135,7 +137,7 @@ def predict(self, input_data: np.ndarray) -> np.ndarray:
135
137
np.ndarray: Predicted values (num_samples x output_dim).
136
138
137
139
Examples:
138
- >>> rbf_nn = RadialBasisFunctionNeuralNetwork(num_centers=2, spread=1.0)
140
+ >>> rbf_nn = RadialBasisFunctionNeuralNetwork(num_centers=2,spread=1.0)
139
141
>>> rbf_nn.centers = np.array([[0, 0], [1, 1]])
140
142
>>> rbf_nn.weights = np.array([[0.5], [0.5]])
141
143
>>> rbf_nn.predict(np.array([[0, 0], [1, 1]]))
@@ -159,3 +161,4 @@ def predict(self, input_data: np.ndarray) -> np.ndarray:
159
161
# Predict using the trained model
160
162
predictions = rbf_nn .predict (X )
161
163
print ("Predictions:\n " , predictions )
164
+
0 commit comments