executable-engineering 0.1.44__tar.gz → 0.1.46__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/PKG-INFO +1 -1
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/neuralnet_module.py +14 -18
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering.egg-info/PKG-INFO +1 -1
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/setup.py +1 -1
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/LICENSE +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/README.md +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/__init__.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/closedoptimization_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/closedrootfinder_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/constrainedoptimization_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/functions_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/gradientoptimization_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/linearsystems_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/numerical_error_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/openoptimization_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/openrootfinder_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/optimization_module.py +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering.egg-info/SOURCES.txt +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering.egg-info/dependency_links.txt +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering.egg-info/requires.txt +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering.egg-info/top_level.txt +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/pyproject.toml +0 -0
- {executable_engineering-0.1.44 → executable_engineering-0.1.46}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: executable_engineering
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.46
|
|
4
4
|
Summary: Demonstrative tools for the Executable Engineering textbook
|
|
5
5
|
Home-page: https://github.com/themintlab/ExecutableEngineering/tree/main/executable_engineering
|
|
6
6
|
Author: Michael Welland
|
|
@@ -138,7 +138,7 @@ def forward_pass(x):
|
|
|
138
138
|
activations.append(z) # no activation on final output
|
|
139
139
|
return zs, activations
|
|
140
140
|
|
|
141
|
-
def backward_pass(zs, activations, y_true, lr=0.
|
|
141
|
+
def backward_pass(zs, activations, y_true, lr=0.02):
|
|
142
142
|
global weights, biases, weight_history, bias_history
|
|
143
143
|
grads_w = [None] * len(weights)
|
|
144
144
|
grads_b = [None] * len(biases)
|
|
@@ -208,8 +208,8 @@ def change_width(d, output_plot, metrics_plot, network_plot, status_label):
|
|
|
208
208
|
reset_model(output_plot, metrics_plot, network_plot, status_label)
|
|
209
209
|
|
|
210
210
|
|
|
211
|
-
def train_until_convergence(output_plot, metrics_plot, network_plot, status_label, target_loss=
|
|
212
|
-
"""Trains the neural network iteratively until a target loss or convergence plateau is reached."""
|
|
211
|
+
def train_until_convergence(output_plot, metrics_plot, network_plot, status_label, target_loss=1e-4, max_steps=50000, window=5000, min_rel_improvement=0.005):
|
|
212
|
+
"""Trains the neural network iteratively until a high-precision target loss or convergence plateau is reached."""
|
|
213
213
|
global losses
|
|
214
214
|
if true_function is None:
|
|
215
215
|
status_label.value = "Please save a function first."
|
|
@@ -218,36 +218,32 @@ def train_until_convergence(output_plot, metrics_plot, network_plot, status_labe
|
|
|
218
218
|
y_true = true_function(X)
|
|
219
219
|
status_label.value = "Training to convergence..."
|
|
220
220
|
|
|
221
|
-
batch_size =
|
|
221
|
+
batch_size = 500
|
|
222
222
|
step_count = 0
|
|
223
|
-
best_loss = float('inf')
|
|
224
|
-
stagnant_count = 0
|
|
225
223
|
stop_reason = ""
|
|
224
|
+
window_start_loss = float('inf')
|
|
226
225
|
current_loss = float('inf')
|
|
227
226
|
|
|
228
227
|
while step_count < max_steps:
|
|
229
228
|
for _ in range(batch_size):
|
|
230
229
|
zs, activations = forward_pass(X)
|
|
231
|
-
current_loss = backward_pass(zs, activations, y_true)
|
|
230
|
+
current_loss = backward_pass(zs, activations, y_true, lr=0.02)
|
|
232
231
|
losses.append(current_loss)
|
|
233
232
|
step_count += batch_size
|
|
234
233
|
|
|
235
234
|
if current_loss <= target_loss:
|
|
236
|
-
stop_reason = f"Target loss
|
|
235
|
+
stop_reason = f"Target loss reached ({current_loss:.4e} <= {target_loss}) in {step_count} steps. Total: {len(losses)}"
|
|
237
236
|
break
|
|
238
237
|
|
|
239
|
-
if
|
|
240
|
-
|
|
241
|
-
if
|
|
242
|
-
stop_reason = f"Converged (
|
|
238
|
+
if step_count % window == 0:
|
|
239
|
+
rel_improvement = (window_start_loss - current_loss) / max(window_start_loss, 1e-8)
|
|
240
|
+
if step_count > window and rel_improvement < min_rel_improvement:
|
|
241
|
+
stop_reason = f"Converged to plateau (rel. change < {min_rel_improvement:.1%} over {window} steps) at loss {current_loss:.4e}. Total steps: {len(losses)}"
|
|
243
242
|
break
|
|
244
|
-
|
|
245
|
-
stagnant_count = 0
|
|
246
|
-
if current_loss < best_loss:
|
|
247
|
-
best_loss = current_loss
|
|
243
|
+
window_start_loss = current_loss
|
|
248
244
|
|
|
249
245
|
if not stop_reason:
|
|
250
|
-
stop_reason = f"
|
|
246
|
+
stop_reason = f"Completed {step_count} steps. Total steps: {len(losses)} | Loss: {current_loss:.4e} (Click again to train further)"
|
|
251
247
|
|
|
252
248
|
status_label.value = stop_reason
|
|
253
249
|
update_plots(output_plot, metrics_plot, network_plot)
|
|
@@ -373,7 +369,7 @@ def interactive_neural_network():
|
|
|
373
369
|
step_100 = Button(description='100')
|
|
374
370
|
step_1000 = Button(description='1000')
|
|
375
371
|
step_10000 = Button(description='10000')
|
|
376
|
-
train_converge_btn = Button(description='Train to Convergence', button_style='primary', tooltip='Trains iteratively until
|
|
372
|
+
train_converge_btn = Button(description='Train to Convergence', button_style='primary', tooltip='Trains iteratively until a plateau or high-precision convergence (<1e-4) is reached')
|
|
377
373
|
|
|
378
374
|
depth_label = Label(value="Change Depth (layers):")
|
|
379
375
|
depth_add = Button(description='+1')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: executable_engineering
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.46
|
|
4
4
|
Summary: Demonstrative tools for the Executable Engineering textbook
|
|
5
5
|
Home-page: https://github.com/themintlab/ExecutableEngineering/tree/main/executable_engineering
|
|
6
6
|
Author: Michael Welland
|
|
@@ -6,7 +6,7 @@ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="executable_engineering",
|
|
9
|
-
version="0.1.
|
|
9
|
+
version="0.1.46",
|
|
10
10
|
description="Demonstrative tools for the Executable Engineering textbook",
|
|
11
11
|
long_description=long_description,
|
|
12
12
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
{executable_engineering-0.1.44 → executable_engineering-0.1.46}/executable_engineering/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|