summaryrefslogtreecommitdiff
path: root/experiments/conv_local_smoke.py
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/conv_local_smoke.py')
-rw-r--r--experiments/conv_local_smoke.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/experiments/conv_local_smoke.py b/experiments/conv_local_smoke.py
index dbae759..cdf1ad0 100644
--- a/experiments/conv_local_smoke.py
+++ b/experiments/conv_local_smoke.py
@@ -1003,6 +1003,26 @@ def kp_mixed_traffic_checks():
assert stable_fit["min_residual_soma_slope"] < -9e-4
assert stable_fit["max_applied_stability_margin"] >= 1e-3
+ # A deliberately inaccurate slow predictor leaves an affine neutral mode.
+ # The fast controller must remove that mode using only paired neutral
+ # soma/traffic observations, without changing the predictor parameters or
+ # reading the task instruction during its coefficient fit.
+ frozen_before_projection = [value.clone() for value in
+ net.P_traffic + net.P_traffic_bias]
+ projected = net.mixed_apical_components(
+ instruction, forward["hiddens"], "innovation",
+ neutral_projection=True)
+ projection = projected["neutral_projection"]
+ projected_instruction_error = max(float((left - right).abs().max())
+ for left, right in zip(
+ projected["innovation"], instruction))
+ assert projected_instruction_error < 1e-14
+ assert projection["post_projection_traffic_rms_ratio"] < 1e-14
+ assert projection["max_absolute_post_projection_soma_slope"] < 1e-14
+ assert projection["instruction_observations"] == 0
+ assert all(torch.equal(before, after) for before, after in zip(
+ frozen_before_projection, net.P_traffic + net.P_traffic_bias))
+
for slope, bias in zip(net.P_traffic, net.P_traffic_bias):
slope.zero_()
bias.zero_()
@@ -1098,6 +1118,14 @@ def kp_mixed_traffic_checks():
assert all(not value.requires_grad for value in
net.W + net.Q + net.P_traffic + net.P_traffic_bias
+ [net.W_out, net.R_out, net.b_out])
+ projected_result = conv_kp_mixed_traffic_step(
+ net, x, y, ConvSDILConfig(
+ eta=1e-4, eta_output=1e-4, eta_P=0.1, momentum=0.0,
+ weight_decay=0.0, learn_A=False, learn_P=True),
+ step=2, rule="innovation", predictor_every=0,
+ neutral_projection=True)
+ assert math.isfinite(projected_result["loss"])
+ assert projected_result["neutral_projection"] is not None
assert net.mixed_elementwise_ops_per_example("matched") > (
net.mixed_elementwise_ops_per_example("raw"))
return {
@@ -1109,6 +1137,11 @@ def kp_mixed_traffic_checks():
"residual_traffic_rms_ratio"],
"kp_traffic_closed_form_residual_slope": closed_form[
"max_absolute_residual_soma_slope"],
+ "kp_traffic_projected_instruction_error": projected_instruction_error,
+ "kp_traffic_projected_residual_ratio": projection[
+ "post_projection_traffic_rms_ratio"],
+ "kp_traffic_projected_residual_slope": projection[
+ "max_absolute_post_projection_soma_slope"],
"kp_traffic_matched_norm_error": max(norm_errors),
"kp_traffic_matched_direction_error": max(direction_errors),
"kp_traffic_reciprocal_correlation_error": max(correlation_errors),