PowerMachine commited on
Commit
8efcaa2
·
verified ·
1 Parent(s): 092e242

V6.5-V2-dynamic: FASE 2 PUNIÇÃO upload (3 files)

Browse files
train_v6_5_v2_punicão_only.py ADDED
@@ -0,0 +1,556 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """train_v6_5_v2_punicão_only.py — V6.5-V2-dynamic FASE 2 only.
2
+
3
+ Carrega o estado salvo da FASE 1 (CONHECIMENTO) e executa apenas a FASE 2
4
+ (TREINAMENTO COM PUNIÇÃO) sobre BrunoN-Dev/corpus-ptbr-v1.
5
+
6
+ User requirement: "FASE2 TREINAMENTO (meta mínima 1000 samples ou mais)
7
+ COM PUNIÇÃO ATIVA para 'BrunoN-Dev/corpus-ptbr-v1' de 100 em 100 samples"
8
+
9
+ Este script permite continuar o treinamento a partir do estado salvo sem
10
+ precisar re-executar a FASE 1.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import gc
15
+ import json
16
+ import logging
17
+ import os
18
+ import re
19
+ import shutil
20
+ import sys
21
+ import time
22
+ import traceback
23
+ from datetime import datetime
24
+ from pathlib import Path
25
+ from typing import Any, Dict, List, Optional
26
+
27
+ # ============================================================================
28
+ # 0. Paths e logging
29
+ # ============================================================================
30
+ PROJECT_ROOT = Path("/home/z/my-project")
31
+ BIGRU_ROOT = PROJECT_ROOT / "BiGRU_T_version"
32
+ SRC_ROOT = BIGRU_ROOT / "src"
33
+ DOWNLOAD_DIR = PROJECT_ROOT / "download"
34
+ DOWNLOAD_DIR.mkdir(parents=True, exist_ok=True)
35
+
36
+ PUNICAO_REPORT_PATH = BIGRU_ROOT / "v6_5_v2_punicão_report.json"
37
+ PUNICAO_STATES_PATH = BIGRU_ROOT / "v6_5_v2_punicão_model_states.pt"
38
+ PUNICAO_UPLOAD_REPORT_PATH = BIGRU_ROOT / "v6_5_v2_punicão_upload_report.json"
39
+
40
+ # Estado salvo da FASE 1
41
+ FASE1_STATES_PATH = BIGRU_ROOT / "v6_5_v2_model_states.pt"
42
+
43
+ logging.basicConfig(
44
+ level=logging.INFO,
45
+ format="[%(asctime)s] [%(levelname)s] %(message)s",
46
+ datefmt="%H:%M:%S",
47
+ )
48
+ logger = logging.getLogger("train_v6_5_v2_punicão")
49
+
50
+ # ============================================================================
51
+ # 1. ATIVAR xeon_runtime.py
52
+ # ============================================================================
53
+ os.environ["V65_ENABLE_STREAMING"] = "1"
54
+ sys.path.insert(0, str(SRC_ROOT))
55
+
56
+ from bigru_t.utils.xeon_runtime import ( # noqa: E402
57
+ optimize_xeon_environment,
58
+ benchmark_fp16_matmul,
59
+ )
60
+ N_CORES = optimize_xeon_environment(verbose=False)
61
+ logger.info(f"[V6.5-V2-punicão] Xeon cores: {N_CORES}")
62
+
63
+ # ============================================================================
64
+ # 2. Configurações (mesmas do FASE 1, para compatibilidade de estado)
65
+ # ============================================================================
66
+ BATCH_SIZE = 16
67
+ MAX_SEQ_LEN = 8
68
+ HIDDEN_DIM = 256
69
+ VOCAB_SIZE = 4096
70
+ SOM_GRID = (6, 6, 6, 4)
71
+ T_MAX = 10000
72
+ N_START = 10
73
+ LAMBDA_EWC = 0.02
74
+ ALPHA0 = 0.1
75
+ SIGMA0 = 1.5
76
+ DIM_CHOICE = "y"
77
+
78
+ N_HYPOTHESES = 8
79
+ MAX_N_HYPOTHESES = 16
80
+ MIN_N_HYPOTHESES = 4
81
+ N_TRIALS = 3
82
+ MIN_N_TRIALS = 1
83
+ MAX_N_TRIALS = 6
84
+ HYP_TRAIN_STEPS = 20
85
+ MIN_HYP_TRAIN_STEPS = 5
86
+ MAX_HYP_TRAIN_STEPS = 60
87
+ HYP_LR = 1e-4
88
+ HYP_HIDDEN_DIM = 128
89
+ LOSS_HISTORY_WINDOW = 8
90
+ PUNISHMENT_WINDOW = 12
91
+
92
+ STREAM_BATCH_SIZE = 100
93
+ META_MINIMA_PUNICAO = 1000
94
+ MAX_SAMPLES_PUNICAO = 1000
95
+ MAX_BUFFER_SIZE = 256
96
+
97
+ INTER_BATCH_PAUSE_S = 0.3
98
+ INTER_STREAM_BATCH_PAUSE_S = 0.5
99
+
100
+ PUNICAO_DATASET = "BrunoN-Dev/corpus-ptbr-v1"
101
+
102
+ DATASET_LABEL_STRINGS: Dict[str, Dict[int, str]] = {
103
+ "BrunoN-Dev/corpus-ptbr-v1": {0: "short_text", 1: "long_text"},
104
+ }
105
+
106
+ # ============================================================================
107
+ # 3. Import KLS V2
108
+ # ============================================================================
109
+ from bigru_t.model.kohonen_learning_system import ( # noqa: E402
110
+ KohonenLearningSystemV2,
111
+ )
112
+
113
+
114
+ def get_process_rss_mb() -> float:
115
+ try:
116
+ import resource
117
+ return float(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) / 1024.0
118
+ except Exception:
119
+ return 0.0
120
+
121
+
122
+ def get_cgroup_memory_limit_mb() -> Optional[float]:
123
+ try:
124
+ with open("/sys/fs/cgroup/memory.max", "r") as f:
125
+ return float(int(f.read().strip())) / 1e6
126
+ except Exception:
127
+ return None
128
+
129
+
130
+ def aggressive_memory_cleanup() -> None:
131
+ gc.collect()
132
+ gc.collect()
133
+
134
+
135
+ def make_label(text: str, dataset_name: Optional[str] = None) -> int:
136
+ if dataset_name == "BrunoN-Dev/corpus-ptbr-v1":
137
+ return len(text.split()) % 2
138
+ return 1 if len(text.split()) % 2 == 0 else 0
139
+
140
+
141
+ def stream_dataset_in_chunks(dataset_name, chunk_size, max_total, hf_token, timeout_per_chunk=120):
142
+ from bigru_t.data.streaming_datasets import stream_dataset
143
+ yielded_total = 0
144
+ chunk_idx = 0
145
+ while yielded_total < max_total:
146
+ remaining = max_total - yielded_total
147
+ this_chunk_target = min(chunk_size, remaining)
148
+ seed_offset = yielded_total
149
+ chunk: List[str] = []
150
+ t_start = time.time()
151
+ try:
152
+ for sample in stream_dataset(
153
+ dataset_name,
154
+ max_samples=this_chunk_target + seed_offset + 5,
155
+ hf_token=hf_token,
156
+ ):
157
+ if time.time() - t_start > timeout_per_chunk:
158
+ break
159
+ if sample.raw_text and len(sample.raw_text.strip()) > 0:
160
+ if seed_offset > 0:
161
+ seed_offset -= 1
162
+ continue
163
+ chunk.append(sample.raw_text.strip()[:200])
164
+ if len(chunk) >= this_chunk_target:
165
+ break
166
+ except Exception as e:
167
+ logger.warning(f"Stream error: {e}")
168
+ if chunk:
169
+ yield chunk
170
+ yielded_total += len(chunk)
171
+ chunk_idx += 1
172
+ break
173
+ if not chunk:
174
+ break
175
+ yield chunk
176
+ yielded_total += len(chunk)
177
+ chunk_idx += 1
178
+ logger.info(f"[PUNICAO] {dataset_name} chunk {chunk_idx}: {len(chunk)} (total: {yielded_total}/{max_total})")
179
+
180
+
181
+ def save_punicão_states(kls, reason, step, total_samples):
182
+ import torch
183
+ try:
184
+ state = {
185
+ "_meta": {
186
+ "reason": str(reason),
187
+ "step": int(step),
188
+ "total_samples": int(total_samples),
189
+ "timestamp": datetime.now().isoformat(),
190
+ "version": "V6.5-V2-dynamic-punicão",
191
+ "loaded_from_fase1": str(FASE1_STATES_PATH),
192
+ },
193
+ "som_weights": kls.som.weights.detach().clone().cpu(),
194
+ "som_old_weights_w": (
195
+ kls.som.old_weights_w.detach().clone().cpu()
196
+ if kls.som.old_weights_w is not None else None
197
+ ),
198
+ "som_fisher_w": (
199
+ kls.som.fisher_w.detach().clone().cpu()
200
+ if kls.som.fisher_w is not None else None
201
+ ),
202
+ "embedding_state": {"weight": kls.embedding.weight.detach().clone().cpu()},
203
+ "classifier_state": (
204
+ kls.classifier.state_dict() if kls.classifier is not None else None
205
+ ),
206
+ "hypothesis_ensemble_state": kls.hypothesis_ensemble.state_dict(),
207
+ "delta_scale": kls.delta_scale.detach().clone().cpu(),
208
+ "v2_metrics": kls.get_v2_metrics(),
209
+ "label_registry": kls.label_registry,
210
+ "adaptation_log": kls.get_adaptation_log(),
211
+ }
212
+ torch.save(state, PUNICAO_STATES_PATH)
213
+ size_mb = PUNICAO_STATES_PATH.stat().st_size / 1e6
214
+ logger.info(f"[PUNICAO] States saved: {PUNICAO_STATES_PATH} ({size_mb:.1f}MB)")
215
+ return {"saved": True, "path": str(PUNICAO_STATES_PATH), "size_mb": float(size_mb)}
216
+ except Exception as e:
217
+ logger.error(f"[PUNICAO] Save failed: {e}")
218
+ return {"saved": False, "error": str(e)}
219
+
220
+
221
+ HF_REPO_ID = "PowerMachine/BiGRU_T_version"
222
+
223
+
224
+ def upload_punicão_to_hf(hf_token, files_to_upload):
225
+ if not hf_token:
226
+ return {"uploaded": False, "reason": "no_hf_token"}
227
+ try:
228
+ from huggingface_hub import HfApi, whoami, CommitOperationAdd
229
+ except ImportError as e:
230
+ return {"uploaded": False, "reason": f"import_error: {e}"}
231
+ api = HfApi(token=hf_token)
232
+ try:
233
+ whoami(token=hf_token)
234
+ except Exception as e:
235
+ return {"uploaded": False, "reason": f"auth_failed: {e}"}
236
+ operations = []
237
+ for src in files_to_upload:
238
+ if not src.exists():
239
+ continue
240
+ operations.append(CommitOperationAdd(
241
+ path_in_repo=src.name,
242
+ path_or_fileobj=str(src),
243
+ ))
244
+ if not operations:
245
+ return {"uploaded": False, "reason": "no_files"}
246
+ try:
247
+ commit_info = api.create_commit(
248
+ repo_id=HF_REPO_ID,
249
+ repo_type="model",
250
+ operations=operations,
251
+ commit_message=f"V6.5-V2-dynamic: FASE 2 PUNIÇÃO upload ({len(operations)} files)",
252
+ )
253
+ return {
254
+ "uploaded": True,
255
+ "n_files": len(operations),
256
+ "commit_url": str(commit_info.commit_url) if hasattr(commit_info, "commit_url") else str(commit_info),
257
+ }
258
+ except Exception as e:
259
+ logger.error(f"[PUNICAO] HF upload failed: {e}")
260
+ return {"uploaded": False, "reason": str(e)}
261
+
262
+
263
+ def main() -> int:
264
+ import torch
265
+
266
+ if not FASE1_STATES_PATH.exists():
267
+ logger.error(f"[PUNICAO] FASE 1 states not found: {FASE1_STATES_PATH}")
268
+ return 1
269
+
270
+ logger.info(f"[PUNICAO] Loading FASE 1 states from: {FASE1_STATES_PATH}")
271
+ fase1_state = torch.load(FASE1_STATES_PATH, map_location="cpu", weights_only=False)
272
+ logger.info(f"[PUNICAO] FASE 1 state loaded. Reason: {fase1_state['_meta']['reason']}")
273
+ logger.info(f"[PUNICAO] FASE 1 total_samples: {fase1_state['_meta']['total_samples']}")
274
+
275
+ # Construct KLS V2 with same config as FASE 1
276
+ kls = KohonenLearningSystemV2(
277
+ vocab_size=VOCAB_SIZE, hidden_dim=HIDDEN_DIM, seq_len=MAX_SEQ_LEN,
278
+ som_grid=SOM_GRID, alpha0=ALPHA0, sigma0=SIGMA0,
279
+ lambda_ewc=LAMBDA_EWC, N_start=N_START, dim_choice=DIM_CHOICE,
280
+ hypothesis_hidden=[512, 256, 128, 64, 32, 16, 8], T_max=T_MAX,
281
+ enable_vqvae2=False, enable_reasoning=True, enable_w8a8=False,
282
+ enable_attention=True, attention_n_heads=8,
283
+ n_hypotheses=N_HYPOTHESES, max_n_hypotheses=MAX_N_HYPOTHESES,
284
+ min_n_hypotheses=MIN_N_HYPOTHESES, n_trials=N_TRIALS,
285
+ min_n_trials=MIN_N_TRIALS, max_n_trials=MAX_N_TRIALS,
286
+ hyp_train_steps=HYP_TRAIN_STEPS, min_hyp_train_steps=MIN_HYP_TRAIN_STEPS,
287
+ max_hyp_train_steps=MAX_HYP_TRAIN_STEPS, hyp_lr=HYP_LR,
288
+ hyp_hidden_dim=HYP_HIDDEN_DIM,
289
+ loss_history_window=LOSS_HISTORY_WINDOW,
290
+ punishment_window=PUNISHMENT_WINDOW,
291
+ )
292
+ logger.info(f"[PUNICAO] KLS V2 initialized (fresh)")
293
+
294
+ # Load FASE 1 state into KLS
295
+ try:
296
+ # SOM weights
297
+ kls.som.weights = nn.Parameter(fase1_state["som_weights"].clone())
298
+ if fase1_state.get("som_old_weights_w") is not None:
299
+ kls.som.old_weights_w = fase1_state["som_old_weights_w"].clone()
300
+ if fase1_state.get("som_fisher_w") is not None:
301
+ kls.som.fisher_w = fase1_state["som_fisher_w"].clone()
302
+ # Embedding
303
+ if "embedding_state" in fase1_state:
304
+ kls.embedding.weight.data = fase1_state["embedding_state"]["weight"].clone()
305
+ # Classifier
306
+ if fase1_state.get("classifier_state") and kls.classifier is not None:
307
+ kls.classifier.load_state_dict(fase1_state["classifier_state"])
308
+ kls.classifier_trained = True
309
+ # Hypothesis ensemble
310
+ if "hypothesis_ensemble_state" in fase1_state:
311
+ kls.hypothesis_ensemble.load_state_dict(fase1_state["hypothesis_ensemble_state"])
312
+ # Delta scale
313
+ if "delta_scale" in fase1_state:
314
+ kls.delta_scale.data = fase1_state["delta_scale"].clone()
315
+ # Label registry
316
+ if "label_registry" in fase1_state:
317
+ kls.label_registry = fase1_state["label_registry"]
318
+ # Mark training as ready (FASE 1 already trained the SOM)
319
+ kls.training_ready = True
320
+ logger.info(f"[PUNICAO] FASE 1 state loaded into KLS successfully")
321
+ except Exception as e:
322
+ logger.error(f"[PUNICAO] Failed to load FASE 1 state: {e}")
323
+ traceback.print_exc()
324
+ return 1
325
+
326
+ # Fit tokenizer with PT-BR corpus
327
+ corpus_inicial = [
328
+ "o gato dorme na cama", "a casa eh azul", "ele corre rapido",
329
+ "luva de pedreiro tavila", "lula reserva valor",
330
+ "amazonas forca tarefa vitimas",
331
+ "texto curto", "texto longo com muitas palavras para teste",
332
+ ]
333
+ kls.tokenizer.fit(corpus_inicial)
334
+ logger.info(f"[PUNICAO] Tokenizer fitted")
335
+
336
+ hf_token = os.environ.get("HF_TOKEN")
337
+ if not hf_token:
338
+ logger.warning("[PUNICAO] HF_TOKEN not set")
339
+ else:
340
+ logger.info(f"[PUNICAO] HF_TOKEN set: {hf_token[:8]}...")
341
+
342
+ # ========================================================================
343
+ # FASE 2 — TREINAMENTO COM PUNIÇÃO
344
+ # ========================================================================
345
+ logger.info("\n" + "=" * 80)
346
+ logger.info("[PUNICAO] FASE 2 — TREINAMENTO COM PUNIÇÃO ATIVA")
347
+ logger.info("=" * 80)
348
+ logger.info(f" Dataset: {PUNICAO_DATASET}")
349
+ logger.info(f" Meta mínima: {META_MINIMA_PUNICAO}")
350
+ logger.info(f" Stream batch: {STREAM_BATCH_SIZE}")
351
+ logger.info(f" n_hypotheses: {kls.n_hypotheses} (max {kls.max_n_hypotheses})")
352
+ logger.info(f" n_trials: {kls.n_trials}")
353
+ logger.info(f" hyp_train_steps: {kls.hyp_train_steps}")
354
+ logger.info("=" * 80 + "\n")
355
+
356
+ step = 0
357
+ t_start = time.time()
358
+ samples_processed = 0
359
+ chunk_idx_global = 0
360
+ punishment_log: List[Dict[str, Any]] = []
361
+ hypotheses_log: List[Dict[str, Any]] = []
362
+ delta_applications_log: List[Dict[str, Any]] = []
363
+ accuracies_log: List[Dict[str, Any]] = []
364
+ mem_critical_stopped = False
365
+ cg_limit = get_cgroup_memory_limit_mb()
366
+
367
+ try:
368
+ chunk_iter = stream_dataset_in_chunks(
369
+ dataset_name=PUNICAO_DATASET,
370
+ chunk_size=STREAM_BATCH_SIZE,
371
+ max_total=MAX_SAMPLES_PUNICAO,
372
+ hf_token=hf_token,
373
+ timeout_per_chunk=120,
374
+ )
375
+ for chunk_samples in chunk_iter:
376
+ if mem_critical_stopped:
377
+ break
378
+ if samples_processed >= META_MINIMA_PUNICAO:
379
+ logger.info(f"[PUNICAO] Meta atingida: {samples_processed}")
380
+ break
381
+ chunk_idx_global += 1
382
+ if not chunk_samples:
383
+ continue
384
+ samples_processed += len(chunk_samples)
385
+ labels = [make_label(s, PUNICAO_DATASET) for s in chunk_samples]
386
+ logger.info(f"[PUNICAO] Chunk {chunk_idx_global}: {len(chunk_samples)} samples (total: {samples_processed})")
387
+
388
+ for batch_start in range(0, len(chunk_samples), BATCH_SIZE):
389
+ try:
390
+ # Memory check
391
+ if step > 0 and step % 5 == 0 and cg_limit is not None:
392
+ rss = get_process_rss_mb()
393
+ mem_pct = (rss / cg_limit) * 100.0
394
+ logger.info(f"[PUNICAO] MEM: RSS={rss:.0f}MB ({mem_pct:.1f}%)")
395
+ if mem_pct > 80:
396
+ logger.error(f"[PUNICAO] MEM CRITICAL ({mem_pct:.1f}%). Stopping.")
397
+ save_punicão_states(kls, f"mem_critical_{mem_pct:.1f}pct", step, samples_processed)
398
+ mem_critical_stopped = True
399
+ break
400
+
401
+ batch_sents = chunk_samples[batch_start: batch_start + BATCH_SIZE]
402
+ batch_labels = labels[batch_start: batch_start + BATCH_SIZE]
403
+ try:
404
+ result = kls.process_batch_v2(
405
+ batch_sents, batch_labels,
406
+ label_strings=DATASET_LABEL_STRINGS.get(PUNICAO_DATASET),
407
+ dataset_name=PUNICAO_DATASET,
408
+ enable_punishment=True,
409
+ )
410
+ except Exception as e:
411
+ logger.error(f"[PUNICAO] process_batch_v2 error: {e}")
412
+ continue
413
+
414
+ action = result.get("action", "none")
415
+ if action != "none" and action != "success":
416
+ punishment_log.append({
417
+ "step": step,
418
+ "action": action,
419
+ "accuracy": float(result.get("accuracy", 0.0)),
420
+ "punishment_count": int(kls.punishment_count),
421
+ "cycle_completed": bool(result.get("cycle_completed", False)),
422
+ })
423
+ if "hypotheses_training" in result:
424
+ hyp_info = result["hypotheses_training"]
425
+ hypotheses_log.append({
426
+ "step": step,
427
+ "loss_initial": float(hyp_info.get("loss_initial", 0.0)),
428
+ "loss_final": float(hyp_info.get("loss_final", 0.0)),
429
+ "delta_scale": float(hyp_info.get("delta_scale_final", 0.0)),
430
+ })
431
+ if "delta_application" in result:
432
+ apply_info = result["delta_application"]
433
+ delta_applications_log.append({
434
+ "step": step,
435
+ "acc_before": float(apply_info.get("acc_before", 0.0)),
436
+ "acc_after": float(apply_info.get("acc_after", 0.0)),
437
+ "delta_norm": float(apply_info.get("delta_norm", 0.0)),
438
+ "ewc_reference_set": bool(apply_info.get("ewc_reference_set", False)),
439
+ })
440
+
441
+ acc = kls.evaluate_classification()
442
+ accuracies_log.append({
443
+ "step": step,
444
+ "accuracy": float(acc),
445
+ "action": action,
446
+ "punishment_count": int(kls.punishment_count),
447
+ "buffer_size": int(len(kls.buffer_4d)),
448
+ })
449
+ step += 1
450
+ time.sleep(INTER_BATCH_PAUSE_S)
451
+ except Exception as e:
452
+ logger.error(f"[PUNICAO] Batch error: {e}")
453
+ continue
454
+
455
+ time.sleep(INTER_STREAM_BATCH_PAUSE_S)
456
+ # Buffer sliding window
457
+ if len(kls.buffer_4d) > MAX_BUFFER_SIZE:
458
+ overflow = len(kls.buffer_4d) - MAX_BUFFER_SIZE
459
+ del kls.buffer_4d[:overflow]
460
+ del kls.buffer_labels[:overflow]
461
+ logger.info(f"[PUNICAO] Buffer trimmed: -{overflow} → {len(kls.buffer_4d)}")
462
+ if chunk_idx_global % 2 == 0:
463
+ aggressive_memory_cleanup()
464
+ except Exception as e:
465
+ logger.error(f"[PUNICAO] FASE 2 failed: {e}")
466
+ traceback.print_exc()
467
+
468
+ t_elapsed = time.time() - t_start
469
+ logger.info(f"\n[PUNICAO] FASE 2 concluída:")
470
+ logger.info(f" Total samples: {samples_processed}")
471
+ logger.info(f" Meta atingida: {samples_processed >= META_MINIMA_PUNICAO}")
472
+ logger.info(f" Punishment events: {len(punishment_log)}")
473
+ logger.info(f" Delta applications: {len(delta_applications_log)}")
474
+ logger.info(f" Tempo: {t_elapsed:.1f}s")
475
+
476
+ # Save final states
477
+ save_punicão_states(kls, "end_of_punicão", step, samples_processed)
478
+
479
+ # Final report
480
+ final_report = {
481
+ "version": "V6.5-V2-dynamic-punicão",
482
+ "timestamp": datetime.now().isoformat(),
483
+ "loaded_from_fase1": str(FASE1_STATES_PATH),
484
+ "fase1_total_samples": int(fase1_state["_meta"]["total_samples"]),
485
+ "fase2_total_samples": int(samples_processed),
486
+ "fase2_meta_atingida": bool(samples_processed >= META_MINIMA_PUNICAO),
487
+ "fase2_elapsed_s": float(t_elapsed),
488
+ "punishment_events": punishment_log,
489
+ "hypotheses_trainings": hypotheses_log,
490
+ "delta_applications": delta_applications_log,
491
+ "accuracies_log": accuracies_log[-30:],
492
+ "final_v2_metrics": kls.get_v2_metrics(),
493
+ "n_adaptations": len(kls.get_adaptation_log()),
494
+ "mem_critical_stopped": bool(mem_critical_stopped),
495
+ }
496
+ PUNICAO_REPORT_PATH.write_text(json.dumps(final_report, indent=2, ensure_ascii=False))
497
+ logger.info(f"[PUNICAO] Report saved: {PUNICAO_REPORT_PATH}")
498
+
499
+ # Copy to download
500
+ try:
501
+ for src in [PUNICAO_REPORT_PATH, PUNICAO_STATES_PATH]:
502
+ if src.exists():
503
+ shutil.copy2(src, DOWNLOAD_DIR / src.name)
504
+ except Exception as e:
505
+ logger.warning(f"[PUNICAO] Copy to download failed: {e}")
506
+
507
+ # HF upload (batch)
508
+ hf_upload_result = {"uploaded": False, "reason": "no_hf_token"}
509
+ if hf_token:
510
+ files_to_upload = [
511
+ PUNICAO_REPORT_PATH,
512
+ PUNICAO_STATES_PATH,
513
+ BIGRU_ROOT / "scripts" / "train_v6_5_v2_punicão_only.py",
514
+ ]
515
+ # Scrub HF_TOKEN from scripts before upload
516
+ pattern = re.compile(r'hf_[A-Za-z0-9]{32,}')
517
+ for py_file in [BIGRU_ROOT / "scripts" / "train_v6_5_v2_punicão_only.py"]:
518
+ if py_file.exists():
519
+ content = py_file.read_text(encoding="utf-8")
520
+ if pattern.findall(content):
521
+ py_file.write_text(pattern.sub("<HF_TOKEN_REMOVED>", content), encoding="utf-8")
522
+
523
+ hf_upload_result = upload_punicão_to_hf(hf_token, files_to_upload)
524
+ PUNICAO_UPLOAD_REPORT_PATH.write_text(
525
+ json.dumps(hf_upload_result, indent=2, ensure_ascii=False)
526
+ )
527
+ logger.info(f"[PUNICAO] HF upload: {hf_upload_result}")
528
+
529
+ # Clean HF_TOKEN
530
+ if "HF_TOKEN" in os.environ:
531
+ del os.environ["HF_TOKEN"]
532
+ if "HUGGING_FACE_HUB_TOKEN" in os.environ:
533
+ del os.environ["HUGGING_FACE_HUB_TOKEN"]
534
+ logger.info("[PUNICAO] HF_TOKEN cleaned from environment")
535
+
536
+ print("\n" + "=" * 80)
537
+ print("V6.5-V2-dynamic FASE 2 PUNIÇÃO — CONCLUÍDO")
538
+ print("=" * 80)
539
+ print(f" Samples processados : {samples_processed}")
540
+ print(f" Meta atingida : {samples_processed >= META_MINIMA_PUNICAO}")
541
+ print(f" Punishment events : {len(punishment_log)}")
542
+ print(f" Delta applications : {len(delta_applications_log)}")
543
+ print(f" Hyp trainings : {len(hypotheses_log)}")
544
+ print(f" N adaptations : {len(kls.get_adaptation_log())}")
545
+ print(f" Final n_hypotheses : {kls.n_hypotheses}")
546
+ print(f" Final n_trials : {kls.n_trials}")
547
+ print(f" Final hyp_steps : {kls.hyp_train_steps}")
548
+ print(f" HF upload : {hf_upload_result.get('uploaded', False)}")
549
+ print(f" HF_TOKEN cleaned : True")
550
+ print("=" * 80)
551
+ return 0
552
+
553
+
554
+ if __name__ == "__main__":
555
+ import torch.nn as nn # needed for nn.Parameter in main
556
+ sys.exit(main())
v6_5_v2_punicão_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2dee50dc8d2407917195d7b76b11ceba69b82f5caf3dac649dfc055004b7bc51
3
+ size 43416469
v6_5_v2_punicão_report.json ADDED
@@ -0,0 +1,1199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "V6.5-V2-dynamic-punicão",
3
+ "timestamp": "2026-08-08T21:32:29.242618",
4
+ "loaded_from_fase1": "/home/z/my-project/BiGRU_T_version/v6_5_v2_model_states.pt",
5
+ "fase1_total_samples": 3300,
6
+ "fase2_total_samples": 1000,
7
+ "fase2_meta_atingida": true,
8
+ "fase2_elapsed_s": 135.41348695755005,
9
+ "punishment_events": [
10
+ {
11
+ "step": 0,
12
+ "action": "train_hypotheses_and_activate",
13
+ "accuracy": 0.5,
14
+ "punishment_count": 1,
15
+ "cycle_completed": false
16
+ },
17
+ {
18
+ "step": 1,
19
+ "action": "apply_best_delta_and_consolidate",
20
+ "accuracy": 0.625,
21
+ "punishment_count": 0,
22
+ "cycle_completed": true
23
+ },
24
+ {
25
+ "step": 2,
26
+ "action": "train_hypotheses_and_activate",
27
+ "accuracy": 0.5416666666666666,
28
+ "punishment_count": 1,
29
+ "cycle_completed": false
30
+ },
31
+ {
32
+ "step": 3,
33
+ "action": "apply_best_delta_and_consolidate",
34
+ "accuracy": 0.546875,
35
+ "punishment_count": 0,
36
+ "cycle_completed": true
37
+ },
38
+ {
39
+ "step": 4,
40
+ "action": "train_hypotheses_and_activate",
41
+ "accuracy": 0.5625,
42
+ "punishment_count": 1,
43
+ "cycle_completed": false
44
+ },
45
+ {
46
+ "step": 5,
47
+ "action": "apply_best_delta_and_consolidate",
48
+ "accuracy": 0.5520833333333334,
49
+ "punishment_count": 0,
50
+ "cycle_completed": true
51
+ },
52
+ {
53
+ "step": 7,
54
+ "action": "train_hypotheses_and_activate",
55
+ "accuracy": 0.5517241379310345,
56
+ "punishment_count": 1,
57
+ "cycle_completed": false
58
+ },
59
+ {
60
+ "step": 8,
61
+ "action": "apply_best_delta_and_consolidate",
62
+ "accuracy": 0.5454545454545454,
63
+ "punishment_count": 0,
64
+ "cycle_completed": true
65
+ },
66
+ {
67
+ "step": 9,
68
+ "action": "train_hypotheses_and_activate",
69
+ "accuracy": 0.5337837837837838,
70
+ "punishment_count": 1,
71
+ "cycle_completed": false
72
+ },
73
+ {
74
+ "step": 10,
75
+ "action": "apply_best_delta_and_consolidate",
76
+ "accuracy": 0.5426829268292683,
77
+ "punishment_count": 0,
78
+ "cycle_completed": true
79
+ },
80
+ {
81
+ "step": 11,
82
+ "action": "train_hypotheses_and_activate",
83
+ "accuracy": 0.5388888888888889,
84
+ "punishment_count": 1,
85
+ "cycle_completed": false
86
+ },
87
+ {
88
+ "step": 12,
89
+ "action": "apply_best_delta_and_consolidate",
90
+ "accuracy": 0.5204081632653061,
91
+ "punishment_count": 0,
92
+ "cycle_completed": true
93
+ },
94
+ {
95
+ "step": 14,
96
+ "action": "train_hypotheses_and_activate",
97
+ "accuracy": 0.5092592592592593,
98
+ "punishment_count": 1,
99
+ "cycle_completed": false
100
+ },
101
+ {
102
+ "step": 15,
103
+ "action": "apply_best_delta_and_consolidate",
104
+ "accuracy": 0.5043103448275862,
105
+ "punishment_count": 0,
106
+ "cycle_completed": true
107
+ },
108
+ {
109
+ "step": 16,
110
+ "action": "train_hypotheses_and_activate",
111
+ "accuracy": 0.5080645161290323,
112
+ "punishment_count": 1,
113
+ "cycle_completed": false
114
+ },
115
+ {
116
+ "step": 17,
117
+ "action": "apply_best_delta_and_consolidate",
118
+ "accuracy": 0.5,
119
+ "punishment_count": 0,
120
+ "cycle_completed": true
121
+ },
122
+ {
123
+ "step": 18,
124
+ "action": "train_hypotheses_and_activate",
125
+ "accuracy": 0.5183823529411765,
126
+ "punishment_count": 1,
127
+ "cycle_completed": false
128
+ },
129
+ {
130
+ "step": 19,
131
+ "action": "apply_best_delta_and_consolidate",
132
+ "accuracy": 0.5173611111111112,
133
+ "punishment_count": 0,
134
+ "cycle_completed": true
135
+ },
136
+ {
137
+ "step": 21,
138
+ "action": "train_hypotheses_and_activate",
139
+ "accuracy": 0.5110294117647058,
140
+ "punishment_count": 1,
141
+ "cycle_completed": false
142
+ },
143
+ {
144
+ "step": 22,
145
+ "action": "apply_best_delta_and_consolidate",
146
+ "accuracy": 0.5138888888888888,
147
+ "punishment_count": 0,
148
+ "cycle_completed": true
149
+ },
150
+ {
151
+ "step": 23,
152
+ "action": "train_hypotheses_and_activate",
153
+ "accuracy": 0.5036764705882353,
154
+ "punishment_count": 1,
155
+ "cycle_completed": false
156
+ },
157
+ {
158
+ "step": 24,
159
+ "action": "apply_best_delta_and_consolidate",
160
+ "accuracy": 0.4930555555555556,
161
+ "punishment_count": 0,
162
+ "cycle_completed": true
163
+ },
164
+ {
165
+ "step": 25,
166
+ "action": "train_hypotheses_and_activate",
167
+ "accuracy": 0.4889705882352941,
168
+ "punishment_count": 1,
169
+ "cycle_completed": false
170
+ },
171
+ {
172
+ "step": 26,
173
+ "action": "apply_best_delta_and_consolidate",
174
+ "accuracy": 0.4756944444444444,
175
+ "punishment_count": 0,
176
+ "cycle_completed": true
177
+ },
178
+ {
179
+ "step": 28,
180
+ "action": "train_hypotheses_and_activate",
181
+ "accuracy": 0.47794117647058826,
182
+ "punishment_count": 1,
183
+ "cycle_completed": false
184
+ },
185
+ {
186
+ "step": 29,
187
+ "action": "apply_best_delta_and_consolidate",
188
+ "accuracy": 0.4895833333333333,
189
+ "punishment_count": 0,
190
+ "cycle_completed": true
191
+ },
192
+ {
193
+ "step": 30,
194
+ "action": "train_hypotheses_and_activate",
195
+ "accuracy": 0.4742647058823529,
196
+ "punishment_count": 1,
197
+ "cycle_completed": false
198
+ },
199
+ {
200
+ "step": 31,
201
+ "action": "apply_best_delta_and_consolidate",
202
+ "accuracy": 0.4826388888888889,
203
+ "punishment_count": 0,
204
+ "cycle_completed": true
205
+ },
206
+ {
207
+ "step": 32,
208
+ "action": "train_hypotheses_and_activate",
209
+ "accuracy": 0.5073529411764706,
210
+ "punishment_count": 1,
211
+ "cycle_completed": false
212
+ },
213
+ {
214
+ "step": 33,
215
+ "action": "apply_best_delta_and_consolidate",
216
+ "accuracy": 0.5138888888888888,
217
+ "punishment_count": 0,
218
+ "cycle_completed": true
219
+ },
220
+ {
221
+ "step": 35,
222
+ "action": "train_hypotheses_and_activate",
223
+ "accuracy": 0.5110294117647058,
224
+ "punishment_count": 1,
225
+ "cycle_completed": false
226
+ },
227
+ {
228
+ "step": 36,
229
+ "action": "apply_best_delta_and_consolidate",
230
+ "accuracy": 0.5104166666666666,
231
+ "punishment_count": 0,
232
+ "cycle_completed": true
233
+ },
234
+ {
235
+ "step": 37,
236
+ "action": "train_hypotheses_and_activate",
237
+ "accuracy": 0.47794117647058826,
238
+ "punishment_count": 1,
239
+ "cycle_completed": false
240
+ },
241
+ {
242
+ "step": 38,
243
+ "action": "apply_best_delta_and_consolidate",
244
+ "accuracy": 0.4791666666666667,
245
+ "punishment_count": 0,
246
+ "cycle_completed": true
247
+ },
248
+ {
249
+ "step": 39,
250
+ "action": "train_hypotheses_and_activate",
251
+ "accuracy": 0.47058823529411764,
252
+ "punishment_count": 1,
253
+ "cycle_completed": false
254
+ },
255
+ {
256
+ "step": 40,
257
+ "action": "apply_best_delta_and_consolidate",
258
+ "accuracy": 0.4930555555555556,
259
+ "punishment_count": 0,
260
+ "cycle_completed": true
261
+ },
262
+ {
263
+ "step": 42,
264
+ "action": "train_hypotheses_and_activate",
265
+ "accuracy": 0.4889705882352941,
266
+ "punishment_count": 1,
267
+ "cycle_completed": false
268
+ },
269
+ {
270
+ "step": 43,
271
+ "action": "apply_best_delta_and_consolidate",
272
+ "accuracy": 0.4965277777777778,
273
+ "punishment_count": 0,
274
+ "cycle_completed": true
275
+ },
276
+ {
277
+ "step": 44,
278
+ "action": "train_hypotheses_and_activate",
279
+ "accuracy": 0.5110294117647058,
280
+ "punishment_count": 1,
281
+ "cycle_completed": false
282
+ },
283
+ {
284
+ "step": 45,
285
+ "action": "apply_best_delta_and_consolidate",
286
+ "accuracy": 0.5138888888888888,
287
+ "punishment_count": 0,
288
+ "cycle_completed": true
289
+ },
290
+ {
291
+ "step": 46,
292
+ "action": "train_hypotheses_and_activate",
293
+ "accuracy": 0.5367647058823529,
294
+ "punishment_count": 1,
295
+ "cycle_completed": false
296
+ },
297
+ {
298
+ "step": 47,
299
+ "action": "apply_best_delta_and_consolidate",
300
+ "accuracy": 0.5208333333333334,
301
+ "punishment_count": 0,
302
+ "cycle_completed": true
303
+ },
304
+ {
305
+ "step": 49,
306
+ "action": "train_hypotheses_and_activate",
307
+ "accuracy": 0.5110294117647058,
308
+ "punishment_count": 1,
309
+ "cycle_completed": false
310
+ },
311
+ {
312
+ "step": 50,
313
+ "action": "apply_best_delta_and_consolidate",
314
+ "accuracy": 0.5208333333333334,
315
+ "punishment_count": 0,
316
+ "cycle_completed": true
317
+ },
318
+ {
319
+ "step": 51,
320
+ "action": "train_hypotheses_and_activate",
321
+ "accuracy": 0.5183823529411765,
322
+ "punishment_count": 1,
323
+ "cycle_completed": false
324
+ },
325
+ {
326
+ "step": 52,
327
+ "action": "apply_best_delta_and_consolidate",
328
+ "accuracy": 0.5173611111111112,
329
+ "punishment_count": 0,
330
+ "cycle_completed": true
331
+ },
332
+ {
333
+ "step": 53,
334
+ "action": "train_hypotheses_and_activate",
335
+ "accuracy": 0.5073529411764706,
336
+ "punishment_count": 1,
337
+ "cycle_completed": false
338
+ },
339
+ {
340
+ "step": 54,
341
+ "action": "apply_best_delta_and_consolidate",
342
+ "accuracy": 0.5104166666666666,
343
+ "punishment_count": 0,
344
+ "cycle_completed": true
345
+ },
346
+ {
347
+ "step": 56,
348
+ "action": "train_hypotheses_and_activate",
349
+ "accuracy": 0.5110294117647058,
350
+ "punishment_count": 1,
351
+ "cycle_completed": false
352
+ },
353
+ {
354
+ "step": 57,
355
+ "action": "apply_best_delta_and_consolidate",
356
+ "accuracy": 0.4965277777777778,
357
+ "punishment_count": 0,
358
+ "cycle_completed": true
359
+ },
360
+ {
361
+ "step": 58,
362
+ "action": "train_hypotheses_and_activate",
363
+ "accuracy": 0.5147058823529411,
364
+ "punishment_count": 1,
365
+ "cycle_completed": false
366
+ },
367
+ {
368
+ "step": 59,
369
+ "action": "apply_best_delta_and_consolidate",
370
+ "accuracy": 0.5104166666666666,
371
+ "punishment_count": 0,
372
+ "cycle_completed": true
373
+ },
374
+ {
375
+ "step": 60,
376
+ "action": "train_hypotheses_and_activate",
377
+ "accuracy": 0.4963235294117647,
378
+ "punishment_count": 1,
379
+ "cycle_completed": false
380
+ },
381
+ {
382
+ "step": 61,
383
+ "action": "apply_best_delta_and_consolidate",
384
+ "accuracy": 0.4895833333333333,
385
+ "punishment_count": 0,
386
+ "cycle_completed": true
387
+ },
388
+ {
389
+ "step": 63,
390
+ "action": "train_hypotheses_and_activate",
391
+ "accuracy": 0.46691176470588236,
392
+ "punishment_count": 1,
393
+ "cycle_completed": false
394
+ },
395
+ {
396
+ "step": 64,
397
+ "action": "apply_best_delta_and_consolidate",
398
+ "accuracy": 0.4722222222222222,
399
+ "punishment_count": 0,
400
+ "cycle_completed": true
401
+ },
402
+ {
403
+ "step": 65,
404
+ "action": "train_hypotheses_and_activate",
405
+ "accuracy": 0.45588235294117646,
406
+ "punishment_count": 1,
407
+ "cycle_completed": false
408
+ },
409
+ {
410
+ "step": 66,
411
+ "action": "apply_best_delta_and_consolidate",
412
+ "accuracy": 0.4583333333333333,
413
+ "punishment_count": 0,
414
+ "cycle_completed": true
415
+ },
416
+ {
417
+ "step": 67,
418
+ "action": "train_hypotheses_and_activate",
419
+ "accuracy": 0.4632352941176471,
420
+ "punishment_count": 1,
421
+ "cycle_completed": false
422
+ },
423
+ {
424
+ "step": 68,
425
+ "action": "apply_best_delta_and_consolidate",
426
+ "accuracy": 0.4722222222222222,
427
+ "punishment_count": 0,
428
+ "cycle_completed": true
429
+ }
430
+ ],
431
+ "hypotheses_trainings": [
432
+ {
433
+ "step": 0,
434
+ "loss_initial": NaN,
435
+ "loss_final": NaN,
436
+ "delta_scale": 0.008179070428013802
437
+ },
438
+ {
439
+ "step": 2,
440
+ "loss_initial": NaN,
441
+ "loss_final": NaN,
442
+ "delta_scale": 0.00668971985578537
443
+ },
444
+ {
445
+ "step": 4,
446
+ "loss_initial": NaN,
447
+ "loss_final": NaN,
448
+ "delta_scale": 0.005471568554639816
449
+ },
450
+ {
451
+ "step": 7,
452
+ "loss_initial": NaN,
453
+ "loss_final": NaN,
454
+ "delta_scale": 0.00447523407638073
455
+ },
456
+ {
457
+ "step": 9,
458
+ "loss_initial": NaN,
459
+ "loss_final": NaN,
460
+ "delta_scale": 0.003660326125100255
461
+ },
462
+ {
463
+ "step": 11,
464
+ "loss_initial": NaN,
465
+ "loss_final": NaN,
466
+ "delta_scale": 0.0029938064981251955
467
+ },
468
+ {
469
+ "step": 14,
470
+ "loss_initial": NaN,
471
+ "loss_final": NaN,
472
+ "delta_scale": 0.002448655664920807
473
+ },
474
+ {
475
+ "step": 16,
476
+ "loss_initial": NaN,
477
+ "loss_final": NaN,
478
+ "delta_scale": 0.0020027728751301765
479
+ },
480
+ {
481
+ "step": 18,
482
+ "loss_initial": NaN,
483
+ "loss_final": NaN,
484
+ "delta_scale": 0.0016380823217332363
485
+ },
486
+ {
487
+ "step": 21,
488
+ "loss_initial": NaN,
489
+ "loss_final": NaN,
490
+ "delta_scale": 0.0013397991424426436
491
+ },
492
+ {
493
+ "step": 23,
494
+ "loss_initial": NaN,
495
+ "loss_final": NaN,
496
+ "delta_scale": 0.0010958312777802348
497
+ },
498
+ {
499
+ "step": 25,
500
+ "loss_initial": NaN,
501
+ "loss_final": NaN,
502
+ "delta_scale": 0.0010000000474974513
503
+ },
504
+ {
505
+ "step": 28,
506
+ "loss_initial": NaN,
507
+ "loss_final": NaN,
508
+ "delta_scale": 0.0010000000474974513
509
+ },
510
+ {
511
+ "step": 30,
512
+ "loss_initial": NaN,
513
+ "loss_final": NaN,
514
+ "delta_scale": 0.0010000000474974513
515
+ },
516
+ {
517
+ "step": 32,
518
+ "loss_initial": NaN,
519
+ "loss_final": NaN,
520
+ "delta_scale": 0.0010000000474974513
521
+ },
522
+ {
523
+ "step": 35,
524
+ "loss_initial": NaN,
525
+ "loss_final": NaN,
526
+ "delta_scale": 0.0010000000474974513
527
+ },
528
+ {
529
+ "step": 37,
530
+ "loss_initial": NaN,
531
+ "loss_final": NaN,
532
+ "delta_scale": 0.0010000000474974513
533
+ },
534
+ {
535
+ "step": 39,
536
+ "loss_initial": NaN,
537
+ "loss_final": NaN,
538
+ "delta_scale": 0.0010000000474974513
539
+ },
540
+ {
541
+ "step": 42,
542
+ "loss_initial": NaN,
543
+ "loss_final": NaN,
544
+ "delta_scale": 0.0010000000474974513
545
+ },
546
+ {
547
+ "step": 44,
548
+ "loss_initial": NaN,
549
+ "loss_final": NaN,
550
+ "delta_scale": 0.0010000000474974513
551
+ },
552
+ {
553
+ "step": 46,
554
+ "loss_initial": NaN,
555
+ "loss_final": NaN,
556
+ "delta_scale": 0.0010000000474974513
557
+ },
558
+ {
559
+ "step": 49,
560
+ "loss_initial": NaN,
561
+ "loss_final": NaN,
562
+ "delta_scale": 0.0010000000474974513
563
+ },
564
+ {
565
+ "step": 51,
566
+ "loss_initial": NaN,
567
+ "loss_final": NaN,
568
+ "delta_scale": 0.0010000000474974513
569
+ },
570
+ {
571
+ "step": 53,
572
+ "loss_initial": NaN,
573
+ "loss_final": NaN,
574
+ "delta_scale": 0.0010000000474974513
575
+ },
576
+ {
577
+ "step": 56,
578
+ "loss_initial": NaN,
579
+ "loss_final": NaN,
580
+ "delta_scale": 0.0010000000474974513
581
+ },
582
+ {
583
+ "step": 58,
584
+ "loss_initial": NaN,
585
+ "loss_final": NaN,
586
+ "delta_scale": 0.0010000000474974513
587
+ },
588
+ {
589
+ "step": 60,
590
+ "loss_initial": NaN,
591
+ "loss_final": NaN,
592
+ "delta_scale": 0.0010000000474974513
593
+ },
594
+ {
595
+ "step": 63,
596
+ "loss_initial": NaN,
597
+ "loss_final": NaN,
598
+ "delta_scale": 0.0010000000474974513
599
+ },
600
+ {
601
+ "step": 65,
602
+ "loss_initial": NaN,
603
+ "loss_final": NaN,
604
+ "delta_scale": 0.0010000000474974513
605
+ },
606
+ {
607
+ "step": 67,
608
+ "loss_initial": NaN,
609
+ "loss_final": NaN,
610
+ "delta_scale": 0.0010000000474974513
611
+ }
612
+ ],
613
+ "delta_applications": [
614
+ {
615
+ "step": 1,
616
+ "acc_before": 0.625,
617
+ "acc_after": 0.625,
618
+ "delta_norm": NaN,
619
+ "ewc_reference_set": true
620
+ },
621
+ {
622
+ "step": 3,
623
+ "acc_before": 0.546875,
624
+ "acc_after": 0.546875,
625
+ "delta_norm": NaN,
626
+ "ewc_reference_set": true
627
+ },
628
+ {
629
+ "step": 5,
630
+ "acc_before": 0.5520833333333334,
631
+ "acc_after": 0.5520833333333334,
632
+ "delta_norm": NaN,
633
+ "ewc_reference_set": true
634
+ },
635
+ {
636
+ "step": 8,
637
+ "acc_before": 0.5454545454545454,
638
+ "acc_after": 0.5454545454545454,
639
+ "delta_norm": NaN,
640
+ "ewc_reference_set": true
641
+ },
642
+ {
643
+ "step": 10,
644
+ "acc_before": 0.5426829268292683,
645
+ "acc_after": 0.5426829268292683,
646
+ "delta_norm": NaN,
647
+ "ewc_reference_set": true
648
+ },
649
+ {
650
+ "step": 12,
651
+ "acc_before": 0.5204081632653061,
652
+ "acc_after": 0.5204081632653061,
653
+ "delta_norm": NaN,
654
+ "ewc_reference_set": true
655
+ },
656
+ {
657
+ "step": 15,
658
+ "acc_before": 0.5043103448275862,
659
+ "acc_after": 0.5043103448275862,
660
+ "delta_norm": NaN,
661
+ "ewc_reference_set": true
662
+ },
663
+ {
664
+ "step": 17,
665
+ "acc_before": 0.5,
666
+ "acc_after": 0.5,
667
+ "delta_norm": NaN,
668
+ "ewc_reference_set": true
669
+ },
670
+ {
671
+ "step": 19,
672
+ "acc_before": 0.5173611111111112,
673
+ "acc_after": 0.5173611111111112,
674
+ "delta_norm": NaN,
675
+ "ewc_reference_set": true
676
+ },
677
+ {
678
+ "step": 22,
679
+ "acc_before": 0.5138888888888888,
680
+ "acc_after": 0.5138888888888888,
681
+ "delta_norm": NaN,
682
+ "ewc_reference_set": true
683
+ },
684
+ {
685
+ "step": 24,
686
+ "acc_before": 0.4930555555555556,
687
+ "acc_after": 0.4930555555555556,
688
+ "delta_norm": NaN,
689
+ "ewc_reference_set": true
690
+ },
691
+ {
692
+ "step": 26,
693
+ "acc_before": 0.4756944444444444,
694
+ "acc_after": 0.4756944444444444,
695
+ "delta_norm": NaN,
696
+ "ewc_reference_set": true
697
+ },
698
+ {
699
+ "step": 29,
700
+ "acc_before": 0.4895833333333333,
701
+ "acc_after": 0.4895833333333333,
702
+ "delta_norm": NaN,
703
+ "ewc_reference_set": true
704
+ },
705
+ {
706
+ "step": 31,
707
+ "acc_before": 0.4826388888888889,
708
+ "acc_after": 0.4826388888888889,
709
+ "delta_norm": NaN,
710
+ "ewc_reference_set": true
711
+ },
712
+ {
713
+ "step": 33,
714
+ "acc_before": 0.5138888888888888,
715
+ "acc_after": 0.5138888888888888,
716
+ "delta_norm": NaN,
717
+ "ewc_reference_set": true
718
+ },
719
+ {
720
+ "step": 36,
721
+ "acc_before": 0.5104166666666666,
722
+ "acc_after": 0.5104166666666666,
723
+ "delta_norm": NaN,
724
+ "ewc_reference_set": true
725
+ },
726
+ {
727
+ "step": 38,
728
+ "acc_before": 0.4791666666666667,
729
+ "acc_after": 0.4791666666666667,
730
+ "delta_norm": NaN,
731
+ "ewc_reference_set": true
732
+ },
733
+ {
734
+ "step": 40,
735
+ "acc_before": 0.4930555555555556,
736
+ "acc_after": 0.4930555555555556,
737
+ "delta_norm": NaN,
738
+ "ewc_reference_set": true
739
+ },
740
+ {
741
+ "step": 43,
742
+ "acc_before": 0.4965277777777778,
743
+ "acc_after": 0.4965277777777778,
744
+ "delta_norm": NaN,
745
+ "ewc_reference_set": true
746
+ },
747
+ {
748
+ "step": 45,
749
+ "acc_before": 0.5138888888888888,
750
+ "acc_after": 0.5138888888888888,
751
+ "delta_norm": NaN,
752
+ "ewc_reference_set": true
753
+ },
754
+ {
755
+ "step": 47,
756
+ "acc_before": 0.5208333333333334,
757
+ "acc_after": 0.5208333333333334,
758
+ "delta_norm": NaN,
759
+ "ewc_reference_set": true
760
+ },
761
+ {
762
+ "step": 50,
763
+ "acc_before": 0.5208333333333334,
764
+ "acc_after": 0.5208333333333334,
765
+ "delta_norm": NaN,
766
+ "ewc_reference_set": true
767
+ },
768
+ {
769
+ "step": 52,
770
+ "acc_before": 0.5173611111111112,
771
+ "acc_after": 0.5173611111111112,
772
+ "delta_norm": NaN,
773
+ "ewc_reference_set": true
774
+ },
775
+ {
776
+ "step": 54,
777
+ "acc_before": 0.5104166666666666,
778
+ "acc_after": 0.5104166666666666,
779
+ "delta_norm": NaN,
780
+ "ewc_reference_set": true
781
+ },
782
+ {
783
+ "step": 57,
784
+ "acc_before": 0.4965277777777778,
785
+ "acc_after": 0.4965277777777778,
786
+ "delta_norm": NaN,
787
+ "ewc_reference_set": true
788
+ },
789
+ {
790
+ "step": 59,
791
+ "acc_before": 0.5104166666666666,
792
+ "acc_after": 0.5104166666666666,
793
+ "delta_norm": NaN,
794
+ "ewc_reference_set": true
795
+ },
796
+ {
797
+ "step": 61,
798
+ "acc_before": 0.4895833333333333,
799
+ "acc_after": 0.4895833333333333,
800
+ "delta_norm": NaN,
801
+ "ewc_reference_set": true
802
+ },
803
+ {
804
+ "step": 64,
805
+ "acc_before": 0.4722222222222222,
806
+ "acc_after": 0.4722222222222222,
807
+ "delta_norm": NaN,
808
+ "ewc_reference_set": true
809
+ },
810
+ {
811
+ "step": 66,
812
+ "acc_before": 0.4583333333333333,
813
+ "acc_after": 0.4583333333333333,
814
+ "delta_norm": NaN,
815
+ "ewc_reference_set": true
816
+ },
817
+ {
818
+ "step": 68,
819
+ "acc_before": 0.4722222222222222,
820
+ "acc_after": 0.4722222222222222,
821
+ "delta_norm": NaN,
822
+ "ewc_reference_set": true
823
+ }
824
+ ],
825
+ "accuracies_log": [
826
+ {
827
+ "step": 40,
828
+ "accuracy": 0.48046875,
829
+ "action": "apply_best_delta_and_consolidate",
830
+ "punishment_count": 0,
831
+ "buffer_size": 256
832
+ },
833
+ {
834
+ "step": 41,
835
+ "accuracy": 0.4807692307692308,
836
+ "action": "none",
837
+ "punishment_count": 0,
838
+ "buffer_size": 260
839
+ },
840
+ {
841
+ "step": 42,
842
+ "accuracy": 0.4889705882352941,
843
+ "action": "train_hypotheses_and_activate",
844
+ "punishment_count": 1,
845
+ "buffer_size": 272
846
+ },
847
+ {
848
+ "step": 43,
849
+ "accuracy": 0.5,
850
+ "action": "apply_best_delta_and_consolidate",
851
+ "punishment_count": 0,
852
+ "buffer_size": 256
853
+ },
854
+ {
855
+ "step": 44,
856
+ "accuracy": 0.5110294117647058,
857
+ "action": "train_hypotheses_and_activate",
858
+ "punishment_count": 1,
859
+ "buffer_size": 272
860
+ },
861
+ {
862
+ "step": 45,
863
+ "accuracy": 0.53515625,
864
+ "action": "apply_best_delta_and_consolidate",
865
+ "punishment_count": 0,
866
+ "buffer_size": 256
867
+ },
868
+ {
869
+ "step": 46,
870
+ "accuracy": 0.5367647058823529,
871
+ "action": "train_hypotheses_and_activate",
872
+ "punishment_count": 1,
873
+ "buffer_size": 272
874
+ },
875
+ {
876
+ "step": 47,
877
+ "accuracy": 0.51171875,
878
+ "action": "apply_best_delta_and_consolidate",
879
+ "punishment_count": 0,
880
+ "buffer_size": 256
881
+ },
882
+ {
883
+ "step": 48,
884
+ "accuracy": 0.5076923076923077,
885
+ "action": "none",
886
+ "punishment_count": 0,
887
+ "buffer_size": 260
888
+ },
889
+ {
890
+ "step": 49,
891
+ "accuracy": 0.5110294117647058,
892
+ "action": "train_hypotheses_and_activate",
893
+ "punishment_count": 1,
894
+ "buffer_size": 272
895
+ },
896
+ {
897
+ "step": 50,
898
+ "accuracy": 0.515625,
899
+ "action": "apply_best_delta_and_consolidate",
900
+ "punishment_count": 0,
901
+ "buffer_size": 256
902
+ },
903
+ {
904
+ "step": 51,
905
+ "accuracy": 0.5183823529411765,
906
+ "action": "train_hypotheses_and_activate",
907
+ "punishment_count": 1,
908
+ "buffer_size": 272
909
+ },
910
+ {
911
+ "step": 52,
912
+ "accuracy": 0.51953125,
913
+ "action": "apply_best_delta_and_consolidate",
914
+ "punishment_count": 0,
915
+ "buffer_size": 256
916
+ },
917
+ {
918
+ "step": 53,
919
+ "accuracy": 0.5073529411764706,
920
+ "action": "train_hypotheses_and_activate",
921
+ "punishment_count": 1,
922
+ "buffer_size": 272
923
+ },
924
+ {
925
+ "step": 54,
926
+ "accuracy": 0.5234375,
927
+ "action": "apply_best_delta_and_consolidate",
928
+ "punishment_count": 0,
929
+ "buffer_size": 256
930
+ },
931
+ {
932
+ "step": 55,
933
+ "accuracy": 0.5230769230769231,
934
+ "action": "none",
935
+ "punishment_count": 0,
936
+ "buffer_size": 260
937
+ },
938
+ {
939
+ "step": 56,
940
+ "accuracy": 0.5110294117647058,
941
+ "action": "train_hypotheses_and_activate",
942
+ "punishment_count": 1,
943
+ "buffer_size": 272
944
+ },
945
+ {
946
+ "step": 57,
947
+ "accuracy": 0.51171875,
948
+ "action": "apply_best_delta_and_consolidate",
949
+ "punishment_count": 0,
950
+ "buffer_size": 256
951
+ },
952
+ {
953
+ "step": 58,
954
+ "accuracy": 0.5147058823529411,
955
+ "action": "train_hypotheses_and_activate",
956
+ "punishment_count": 1,
957
+ "buffer_size": 272
958
+ },
959
+ {
960
+ "step": 59,
961
+ "accuracy": 0.5,
962
+ "action": "apply_best_delta_and_consolidate",
963
+ "punishment_count": 0,
964
+ "buffer_size": 256
965
+ },
966
+ {
967
+ "step": 60,
968
+ "accuracy": 0.4963235294117647,
969
+ "action": "train_hypotheses_and_activate",
970
+ "punishment_count": 1,
971
+ "buffer_size": 272
972
+ },
973
+ {
974
+ "step": 61,
975
+ "accuracy": 0.45703125,
976
+ "action": "apply_best_delta_and_consolidate",
977
+ "punishment_count": 0,
978
+ "buffer_size": 256
979
+ },
980
+ {
981
+ "step": 62,
982
+ "accuracy": 0.4576923076923077,
983
+ "action": "none",
984
+ "punishment_count": 0,
985
+ "buffer_size": 260
986
+ },
987
+ {
988
+ "step": 63,
989
+ "accuracy": 0.46691176470588236,
990
+ "action": "train_hypotheses_and_activate",
991
+ "punishment_count": 1,
992
+ "buffer_size": 272
993
+ },
994
+ {
995
+ "step": 64,
996
+ "accuracy": 0.46484375,
997
+ "action": "apply_best_delta_and_consolidate",
998
+ "punishment_count": 0,
999
+ "buffer_size": 256
1000
+ },
1001
+ {
1002
+ "step": 65,
1003
+ "accuracy": 0.45588235294117646,
1004
+ "action": "train_hypotheses_and_activate",
1005
+ "punishment_count": 1,
1006
+ "buffer_size": 272
1007
+ },
1008
+ {
1009
+ "step": 66,
1010
+ "accuracy": 0.4609375,
1011
+ "action": "apply_best_delta_and_consolidate",
1012
+ "punishment_count": 0,
1013
+ "buffer_size": 256
1014
+ },
1015
+ {
1016
+ "step": 67,
1017
+ "accuracy": 0.4632352941176471,
1018
+ "action": "train_hypotheses_and_activate",
1019
+ "punishment_count": 1,
1020
+ "buffer_size": 272
1021
+ },
1022
+ {
1023
+ "step": 68,
1024
+ "accuracy": 0.46484375,
1025
+ "action": "apply_best_delta_and_consolidate",
1026
+ "punishment_count": 0,
1027
+ "buffer_size": 256
1028
+ },
1029
+ {
1030
+ "step": 69,
1031
+ "accuracy": 0.4653846153846154,
1032
+ "action": "none",
1033
+ "punishment_count": 0,
1034
+ "buffer_size": 260
1035
+ }
1036
+ ],
1037
+ "final_v2_metrics": {
1038
+ "version": "V2-dynamic",
1039
+ "n_hypotheses": 8,
1040
+ "n_hypotheses_active": 8,
1041
+ "max_n_hypotheses": 16,
1042
+ "n_trials": 6,
1043
+ "hyp_train_steps": 20,
1044
+ "hyp_lr": 0.0001,
1045
+ "delta_scale": 0.0010000000474974513,
1046
+ "n_generators": 16,
1047
+ "punishment_count": 0,
1048
+ "success_count": 0,
1049
+ "training_ready": false,
1050
+ "classifier_trained": true,
1051
+ "ewc_reference_set": true,
1052
+ "buffer_size": 256,
1053
+ "dynamic_adaptation": {
1054
+ "loss_history_len": 8,
1055
+ "loss_stats": {
1056
+ "slope": NaN,
1057
+ "volatility": NaN,
1058
+ "mean": NaN,
1059
+ "std": NaN,
1060
+ "n": 8
1061
+ },
1062
+ "punishment_rate": 1.0,
1063
+ "punishment_window_size": 12,
1064
+ "n_adaptations": 60,
1065
+ "limits": {
1066
+ "min_n_hypotheses": 4,
1067
+ "max_n_hypotheses": 16,
1068
+ "min_n_trials": 1,
1069
+ "max_n_trials": 6,
1070
+ "min_hyp_train_steps": 5,
1071
+ "max_hyp_train_steps": 60
1072
+ },
1073
+ "last_5_adaptations": [
1074
+ {
1075
+ "trigger": "punishment",
1076
+ "step": 55,
1077
+ "before": {
1078
+ "n_hypotheses": 8,
1079
+ "n_trials": 6,
1080
+ "hyp_train_steps": 20
1081
+ },
1082
+ "after": {
1083
+ "n_hypotheses": 8,
1084
+ "n_trials": 6,
1085
+ "hyp_train_steps": 20
1086
+ },
1087
+ "adapted": false,
1088
+ "rules_fired": [],
1089
+ "loss_stats": {
1090
+ "slope": NaN,
1091
+ "volatility": NaN,
1092
+ "mean": NaN,
1093
+ "std": NaN,
1094
+ "n": 8
1095
+ },
1096
+ "punishment_rate": 1.0
1097
+ },
1098
+ {
1099
+ "trigger": "auto",
1100
+ "step": 56,
1101
+ "before": {
1102
+ "n_hypotheses": 8,
1103
+ "n_trials": 6,
1104
+ "hyp_train_steps": 20
1105
+ },
1106
+ "after": {
1107
+ "n_hypotheses": 8,
1108
+ "n_trials": 6,
1109
+ "hyp_train_steps": 20
1110
+ },
1111
+ "adapted": false,
1112
+ "rules_fired": [],
1113
+ "loss_stats": {
1114
+ "slope": NaN,
1115
+ "volatility": NaN,
1116
+ "mean": NaN,
1117
+ "std": NaN,
1118
+ "n": 8
1119
+ },
1120
+ "punishment_rate": 1.0
1121
+ },
1122
+ {
1123
+ "trigger": "punishment",
1124
+ "step": 57,
1125
+ "before": {
1126
+ "n_hypotheses": 8,
1127
+ "n_trials": 6,
1128
+ "hyp_train_steps": 20
1129
+ },
1130
+ "after": {
1131
+ "n_hypotheses": 8,
1132
+ "n_trials": 6,
1133
+ "hyp_train_steps": 20
1134
+ },
1135
+ "adapted": false,
1136
+ "rules_fired": [],
1137
+ "loss_stats": {
1138
+ "slope": NaN,
1139
+ "volatility": NaN,
1140
+ "mean": NaN,
1141
+ "std": NaN,
1142
+ "n": 8
1143
+ },
1144
+ "punishment_rate": 1.0
1145
+ },
1146
+ {
1147
+ "trigger": "auto",
1148
+ "step": 58,
1149
+ "before": {
1150
+ "n_hypotheses": 8,
1151
+ "n_trials": 6,
1152
+ "hyp_train_steps": 20
1153
+ },
1154
+ "after": {
1155
+ "n_hypotheses": 8,
1156
+ "n_trials": 6,
1157
+ "hyp_train_steps": 20
1158
+ },
1159
+ "adapted": false,
1160
+ "rules_fired": [],
1161
+ "loss_stats": {
1162
+ "slope": NaN,
1163
+ "volatility": NaN,
1164
+ "mean": NaN,
1165
+ "std": NaN,
1166
+ "n": 8
1167
+ },
1168
+ "punishment_rate": 1.0
1169
+ },
1170
+ {
1171
+ "trigger": "punishment",
1172
+ "step": 59,
1173
+ "before": {
1174
+ "n_hypotheses": 8,
1175
+ "n_trials": 6,
1176
+ "hyp_train_steps": 20
1177
+ },
1178
+ "after": {
1179
+ "n_hypotheses": 8,
1180
+ "n_trials": 6,
1181
+ "hyp_train_steps": 20
1182
+ },
1183
+ "adapted": false,
1184
+ "rules_fired": [],
1185
+ "loss_stats": {
1186
+ "slope": NaN,
1187
+ "volatility": NaN,
1188
+ "mean": NaN,
1189
+ "std": NaN,
1190
+ "n": 8
1191
+ },
1192
+ "punishment_rate": 1.0
1193
+ }
1194
+ ]
1195
+ }
1196
+ },
1197
+ "n_adaptations": 60,
1198
+ "mem_critical_stopped": false
1199
+ }