@@ -81,6 +81,8 @@ def _compute_rbf_outputs(self, input_data: np.ndarray) -> np.ndarray:
8181 array([[1. , 0.60653066],
8282 [0.60653066, 1. ]])
8383 """
84+ assert self .centers is not None , "Centers initialized before computing outputs."
85+
8486 rbf_outputs = np .zeros ((input_data .shape [0 ], self .num_centers ))
8587 for i , center in enumerate (self .centers ):
8688 for j in range (input_data .shape [0 ]):
@@ -96,7 +98,7 @@ def fit(self, input_data: np.ndarray, target_values: np.ndarray) -> None:
9698 target_values (np.ndarray): Target values (num_samples x output_dim).
9799
98100 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.
100102
101103 Examples:
102104 >>> rbf_nn = RadialBasisFunctionNeuralNetwork(num_centers=2, spread=1.0)
@@ -135,7 +137,7 @@ def predict(self, input_data: np.ndarray) -> np.ndarray:
135137 np.ndarray: Predicted values (num_samples x output_dim).
136138
137139 Examples:
138- >>> rbf_nn = RadialBasisFunctionNeuralNetwork(num_centers=2, spread=1.0)
140+ >>> rbf_nn = RadialBasisFunctionNeuralNetwork(num_centers=2,spread=1.0)
139141 >>> rbf_nn.centers = np.array([[0, 0], [1, 1]])
140142 >>> rbf_nn.weights = np.array([[0.5], [0.5]])
141143 >>> rbf_nn.predict(np.array([[0, 0], [1, 1]]))
@@ -159,3 +161,4 @@ def predict(self, input_data: np.ndarray) -> np.ndarray:
159161 # Predict using the trained model
160162 predictions = rbf_nn .predict (X )
161163 print ("Predictions:\n " , predictions )
164+
0 commit comments