Skip to content

Commit 61bf1c0

Browse files
refactor(demo): modify example edge python script.
1 parent ce94ae3 commit 61bf1c0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

demo/example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, seed: float = 42.0) -> None:
99
self.bias: float = 0.0
1010
self.seed = seed
1111

12-
def train(self, labeled_data: dict[tuple[float | int, ...], int], epochs: int = 30, learning_rate: float = 0.001) -> None:
12+
def train(self, labeled_data: dict[tuple[float | int, ...], int], epochs: int = 30, learning_rate: float = 0.1) -> None:
1313
input_dim = len(list(labeled_data.keys())[0])
1414
self.weights = [self._lcg() for _ in range(input_dim)]
1515
self.bias = self._lcg()
@@ -28,12 +28,12 @@ def train(self, labeled_data: dict[tuple[float | int, ...], int], epochs: int =
2828
for i in range(len(self.weights)): self.weights[i] += update * inputs[i]
2929
self.bias += update
3030

31+
print(f"For epoch {e}, the accuracy for actual model is {(len(labeled_data) - error_count) / len(labeled_data) * 100} percent.")
32+
3133
if error_count == 0: # Simple early stopping mechanism to use less resources.
3234
print(f"The model stopped converging at epoch {e}.")
3335
return
34-
35-
print(f"For epoch {e}, the accuracy for actual model is {(len(labeled_data) - error_count) / len(labeled_data) * 100} percent.")
36-
36+
3737
def inference(self, values: tuple[float | int, ...]) -> int:
3838
return self._binary_step(self._net_input(values))
3939

0 commit comments

Comments
 (0)