muooon commited on
Commit
77a3be8
·
verified ·
1 Parent(s): 0f1ff44

Upload 3 files

Browse files
2Gv37_AutoLR/emoairy.py CHANGED
@@ -4,9 +4,10 @@ import math
4
  from collections import deque
5
 
6
  """
7
- EmoAiry v3.7.1 (260105) shadow-system v3.1 -moment v3.1 emoPulse v3.7
8
- EmoLynx v3.6 継承 emoDrive 機構を emoPulse へ統合し簡略化(循環器的機構)
9
- emoPulse 機構により完全自動化を目指す(emoScope 微調整可/改善度反映率)
 
10
  """
11
 
12
  class EmoAiry(Optimizer):
@@ -25,8 +26,10 @@ class EmoAiry(Optimizer):
25
  self.use_shadow = use_shadow # 🔸shadow 使用フラグを保存
26
  self.writer = writer # 動的学習率や感情スカラー等を渡す(研究向け)
27
  self.emoScope = lr # 動的学習率の調和とリズム
28
- self.noise_est = 0.1 # emoPulse nest 初期化
29
- self.d_est = 0.1 # emoPulse dest 初期化
 
 
30
 
31
  # 感情EMA更新(緊張と安静)
32
  def _update_ema(self, state, loss_val):
@@ -86,6 +89,31 @@ class EmoAiry(Optimizer):
86
  ratio = self._decide_ratio(scalar)
87
  trust = math.copysign((1.0 - abs(scalar)), scalar)
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  for group in self.param_groups:
90
  for p in group['params']:
91
  if p.grad is None:
@@ -108,15 +136,6 @@ class EmoAiry(Optimizer):
108
  leap_ratio = 0.1 * abs(trust)
109
  state['shadow'].lerp_(p, leap_ratio)
110
 
111
- # emoPulse (loss 時系列から D / noise を推定し完全自動LRを生成)
112
- # noise_estimate: loss の揺れ(不安定性)のEMA
113
- self.noise_est = 0.7 * self.noise_est + 0.3 * abs(scalar)
114
- noise = max(self.noise_est, 1e-8) # 下限 eps
115
- # distance_estimate: loss の改善傾向の EMA(距離 D の代理)
116
- # emoScope:基準値1.0
117
- self.d_est = 0.95 * self.d_est + 0.05 * abs(trust)
118
- d = self.d_est * self.emoScope
119
-
120
  # --- Start Gradient Update Logic ---
121
  # 行列の形状が2次元以上の場合、分散情報ベースのAB近似を使用
122
  if grad.dim() >= 2:
@@ -148,9 +167,7 @@ class EmoAiry(Optimizer):
148
  update_term = torch.sign(grad / denom)
149
 
150
  # 最終的なパラメータ更新 (decoupled weight decayも適用)
151
- # 完全自動LR / 安全クリップ (emoPulse = step_size)
152
  #step_size = group['lr']
153
- emoPulse = max(min((((d / noise)**2) * 5e-5), 1e-3), 1e-6)
154
  p.add_(p, alpha=-group['weight_decay'] * emoPulse)
155
  p.add_(update_term, alpha=-emoPulse)
156
  # --- End Gradient Update Logic ---
@@ -169,11 +186,12 @@ class EmoAiry(Optimizer):
169
  if avg_abs < 0.05 and var < 0.005:
170
  self.should_stop = True # 💡 外部からこれを見て判断可
171
 
172
- # TensorBoardへの記録(step関数の末尾に追加)
173
  if hasattr(self, 'writer') and self.writer is not None:
174
  self._step_count = getattr(self, "_step_count", 0) + 1
175
- self.writer.add_scalar("emoLR/base", emoPulse, self._step_count)
176
  self.writer.add_scalar("emostate/scalar", scalar, self._step_count)
 
177
 
178
  return
179
 
 
4
  from collections import deque
5
 
6
  """
7
+ EmoAiry v3.7.6 (260109) shadow-system v3.1 -moment v3.1 emoPulse v3.7
8
+ EmoFact v3.6 継承 emoDrive 機構を emoPulse へ統合し簡略化(循環器的機構)
9
+ emoPulse 機構により完全自動化を目指す(ユーザーによる emoScope 調整可/改善度反映率)
10
+ dNR係数により emoPulse に履歴を混ぜて安定させた(d / N 履歴 による信頼度の維持)
11
  """
12
 
13
  class EmoAiry(Optimizer):
 
26
  self.use_shadow = use_shadow # 🔸shadow 使用フラグを保存
27
  self.writer = writer # 動的学習率や感情スカラー等を渡す(研究向け)
28
  self.emoScope = lr # 動的学習率の調和とリズム
29
+ self.noise_est = 1.0 # emoPulse nest 初期化
30
+ self.d_est = 0.02 # emoPulse dest 初期化
31
+ self.dNR_hist = None # emoPulse hist 初期化
32
+ #self.warmup = 0.01 # emoPulse warmup 初期化
33
 
34
  # 感情EMA更新(緊張と安静)
35
  def _update_ema(self, state, loss_val):
 
89
  ratio = self._decide_ratio(scalar)
90
  trust = math.copysign((1.0 - abs(scalar)), scalar)
91
 
92
+ # emoPulse (loss 時系列から D / noise を推定し完全自動LRを生成)
93
+ #self.warmup = 0.97 * (getattr(self, 'warmup', 0.01) or 0.01) + 0.03 * 1.0
94
+ # d / N 履歴 (時間的D推定)
95
+ self.noise_est = 0.97 * self.noise_est + 0.03 * abs(scalar)
96
+ self.d_est = 0.97 * self.d_est + 0.03 * abs(trust)
97
+ noise = max(self.noise_est, 1e-3)
98
+ d = self.d_est
99
+ # scalar、trust、の差分(瞬間的D推定)と各時間軸の確度推定(疑念と信頼の綱引き)
100
+ noise_base = abs(scalar - trust) + 0.1
101
+ d_base = abs(noise - d) + 0.1
102
+ # SNRにより異なる時間的確度比率から更新力を導出し2乗で出力最大化
103
+ dNR_now_val = (d_base / noise_base) ** 2
104
+ # d / N (SNR) の履歴化と最大値の成長率の増減
105
+ if self.dNR_hist is None:
106
+ self.dNR_hist = 1.0
107
+ else:
108
+ if dNR_now_val >= self.dNR_hist and trust >= 0.5:
109
+ # 加速:どんなに SNR が高くても、1.05倍という「歩幅」の成長制限
110
+ self.dNR_hist = min(dNR_now_val, self.dNR_hist * 1.05)
111
+ elif -0.5 <= trust <= 0.5:
112
+ # 減速:怪しい時は即座に比率を下げる(確実に信頼できない場合に下げ圧力を溜める)
113
+ self.dNR_hist = dNR_now_val * 0.98
114
+ # emoPulse 最終決定: emoScorp によるユーザー意思の反映と安全値による制限
115
+ emoPulse = max(min(self.dNR_hist * (self.emoScope * 1e-4), 3e-3), 1e-6)
116
+
117
  for group in self.param_groups:
118
  for p in group['params']:
119
  if p.grad is None:
 
136
  leap_ratio = 0.1 * abs(trust)
137
  state['shadow'].lerp_(p, leap_ratio)
138
 
 
 
 
 
 
 
 
 
 
139
  # --- Start Gradient Update Logic ---
140
  # 行列の形状が2次元以上の場合、分散情報ベースのAB近似を使用
141
  if grad.dim() >= 2:
 
167
  update_term = torch.sign(grad / denom)
168
 
169
  # 最終的なパラメータ更新 (decoupled weight decayも適用)
 
170
  #step_size = group['lr']
 
171
  p.add_(p, alpha=-group['weight_decay'] * emoPulse)
172
  p.add_(update_term, alpha=-emoPulse)
173
  # --- End Gradient Update Logic ---
 
186
  if avg_abs < 0.05 and var < 0.005:
187
  self.should_stop = True # 💡 外部からこれを見て判断可
188
 
189
+ # TensorBoardへの記録 (研究者向けデバッグ用) 要:外部記録コード
190
  if hasattr(self, 'writer') and self.writer is not None:
191
  self._step_count = getattr(self, "_step_count", 0) + 1
192
+ self.writer.add_scalar("emostate/emoLR", emoPulse, self._step_count)
193
  self.writer.add_scalar("emostate/scalar", scalar, self._step_count)
194
+ self.writer.add_scalar("emostate/trust", trust, self._step_count)
195
 
196
  return
197
 
2Gv37_AutoLR/emocats.py CHANGED
@@ -5,9 +5,10 @@ from typing import Tuple, Callable, Union
5
  from collections import deque
6
 
7
  """
8
- EmoCats v3.7.1 (260105) shadow-system v3.1 -moment v3.1 emoPulse v3.7
9
  EmoLynx v3.6 継承 emoDrive 機構を emoPulse へ統合し簡略化(循環器的機構)
10
- emoPulse 機構により完全自動化を目指す(emoScope 微調整可/改善度反映率)
 
11
  """
12
 
13
  # Helper function (Lynx)
@@ -31,8 +32,10 @@ class EmoCats(Optimizer):
31
  self.use_shadow = use_shadow # 🔸shadow 使用フラグを保存
32
  self.writer = writer # 動的学習率や感情スカラー等を渡す(研究向け)
33
  self.emoScope = lr # 動的学習率の調和とリズム
34
- self.noise_est = 0.1 # emoPulse nest 初期化
35
- self.d_est = 0.1 # emoPulse dest 初期化
 
 
36
 
37
  # 感情EMA更新(緊張と安静)
38
  def _update_ema(self, state, loss_val):
@@ -95,6 +98,31 @@ class EmoCats(Optimizer):
95
  ratio = self._decide_ratio(scalar)
96
  trust = math.copysign((1.0 - abs(scalar)), scalar)
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  for group in self.param_groups:
99
  # リンクス共通パラメータ抽出
100
  lr, wd, beta1, beta2 = group['lr'], group['weight_decay'], *group['betas']
@@ -121,15 +149,6 @@ class EmoCats(Optimizer):
121
  leap_ratio = 0.1 * abs(trust)
122
  state['shadow'].lerp_(p, leap_ratio)
123
 
124
- # emoPulse (loss 時系列から D / noise を推定し完全自動LRを生成)
125
- # noise_estimate: loss の揺れ(不安定性)のEMA
126
- self.noise_est = 0.7 * self.noise_est + 0.3 * abs(scalar)
127
- noise = max(self.noise_est, 1e-8) # 下限 eps
128
- # distance_estimate: loss の改善傾向の EMA(距離 D の代理)
129
- # emoScope:基準値1.0
130
- self.d_est = 0.95 * self.d_est + 0.05 * abs(trust)
131
- d = self.d_est * self.emoScope
132
-
133
  # --- Start Gradient Update Logic ---
134
  # lynx初期化(exp_avg_sq)
135
  if 'exp_avg' not in state:
@@ -138,7 +157,6 @@ class EmoCats(Optimizer):
138
 
139
  # Stepweight decay (from lynx): p = p * (1 - lr * wd)
140
  # decoupled_wd 考慮 _wd_actual 使用(EmoNaviのwdは最後に適用)
141
- emoPulse = max(min((((d / noise)**2) * 5e-5), 1e-3), 1e-6)
142
  p.mul_(1 - emoPulse * _wd_actual)
143
  beta1, beta2 = group['betas']
144
 
@@ -167,11 +185,12 @@ class EmoCats(Optimizer):
167
  if avg_abs < 0.05 and var < 0.005:
168
  self.should_stop = True # 💡 外部からこれを見て判断可
169
 
170
- # TensorBoardへの記録(step関数の末尾に追加)
171
  if hasattr(self, 'writer') and self.writer is not None:
172
  self._step_count = getattr(self, "_step_count", 0) + 1
173
- self.writer.add_scalar("emoLR/base", emoPulse, self._step_count)
174
  self.writer.add_scalar("emostate/scalar", scalar, self._step_count)
 
175
 
176
  return
177
 
 
5
  from collections import deque
6
 
7
  """
8
+ EmoCats v3.7.6 (260109) shadow-system v3.1 -moment v3.1 emoPulse v3.7
9
  EmoLynx v3.6 継承 emoDrive 機構を emoPulse へ統合し簡略化(循環器的機構)
10
+ emoPulse 機構により完全自動化を目指す(ユーザーによる emoScope 調整可/改善度反映率)
11
+ dNR係数により emoPulse に履歴を混ぜて安定させた(d / N 履歴 による信頼度の維持)
12
  """
13
 
14
  # Helper function (Lynx)
 
32
  self.use_shadow = use_shadow # 🔸shadow 使用フラグを保存
33
  self.writer = writer # 動的学習率や感情スカラー等を渡す(研究向け)
34
  self.emoScope = lr # 動的学習率の調和とリズム
35
+ self.noise_est = 1.0 # emoPulse nest 初期化
36
+ self.d_est = 0.02 # emoPulse dest 初期化
37
+ self.dNR_hist = None # emoPulse hist 初期化
38
+ #self.warmup = 0.01 # emoPulse warmup 初期化
39
 
40
  # 感情EMA更新(緊張と安静)
41
  def _update_ema(self, state, loss_val):
 
98
  ratio = self._decide_ratio(scalar)
99
  trust = math.copysign((1.0 - abs(scalar)), scalar)
100
 
101
+ # emoPulse (loss 時系列から D / noise を推定し完全自動LRを生成)
102
+ #self.warmup = 0.97 * (getattr(self, 'warmup', 0.01) or 0.01) + 0.03 * 1.0
103
+ # d / N 履歴 (時間的D推定)
104
+ self.noise_est = 0.97 * self.noise_est + 0.03 * abs(scalar)
105
+ self.d_est = 0.97 * self.d_est + 0.03 * abs(trust)
106
+ noise = max(self.noise_est, 1e-3)
107
+ d = self.d_est
108
+ # scalar、trust、の差分(瞬間的D推定)と各時間軸の確度推定(疑念と信頼の綱引き)
109
+ noise_base = abs(scalar - trust) + 0.1
110
+ d_base = abs(noise - d) + 0.1
111
+ # SNRにより異なる時間的確度比率から更新力を導出し2乗で出力最大化
112
+ dNR_now_val = (d_base / noise_base) ** 2
113
+ # d / N (SNR) の履歴化と最大値の成長率の増減
114
+ if self.dNR_hist is None:
115
+ self.dNR_hist = 1.0
116
+ else:
117
+ if dNR_now_val >= self.dNR_hist and trust >= 0.5:
118
+ # 加速:どんなに SNR が高くても、1.05倍という「歩幅」の成長制限
119
+ self.dNR_hist = min(dNR_now_val, self.dNR_hist * 1.05)
120
+ elif -0.5 <= trust <= 0.5:
121
+ # 減速:怪しい時は即座に比率を下げる(確実に信頼できない場合に下げ圧力を溜める)
122
+ self.dNR_hist = dNR_now_val * 0.98
123
+ # emoPulse 最終決定: emoScorp によるユーザー意思の反映と安全値による制限
124
+ emoPulse = max(min(self.dNR_hist * (self.emoScope * 1e-4), 3e-3), 1e-6)
125
+
126
  for group in self.param_groups:
127
  # リンクス共通パラメータ抽出
128
  lr, wd, beta1, beta2 = group['lr'], group['weight_decay'], *group['betas']
 
149
  leap_ratio = 0.1 * abs(trust)
150
  state['shadow'].lerp_(p, leap_ratio)
151
 
 
 
 
 
 
 
 
 
 
152
  # --- Start Gradient Update Logic ---
153
  # lynx初期化(exp_avg_sq)
154
  if 'exp_avg' not in state:
 
157
 
158
  # Stepweight decay (from lynx): p = p * (1 - lr * wd)
159
  # decoupled_wd 考慮 _wd_actual 使用(EmoNaviのwdは最後に適用)
 
160
  p.mul_(1 - emoPulse * _wd_actual)
161
  beta1, beta2 = group['betas']
162
 
 
185
  if avg_abs < 0.05 and var < 0.005:
186
  self.should_stop = True # 💡 外部からこれを見て判断可
187
 
188
+ # TensorBoardへの記録 (研究者向けデバッグ用) 要:外部記録コード
189
  if hasattr(self, 'writer') and self.writer is not None:
190
  self._step_count = getattr(self, "_step_count", 0) + 1
191
+ self.writer.add_scalar("emostate/emoLR", emoPulse, self._step_count)
192
  self.writer.add_scalar("emostate/scalar", scalar, self._step_count)
193
+ self.writer.add_scalar("emostate/trust", trust, self._step_count)
194
 
195
  return
196
 
2Gv37_AutoLR/emosens.py CHANGED
@@ -4,14 +4,15 @@ import math
4
  from collections import deque
5
 
6
  """
7
- EmoSens v3.7.1 (260105) shadow-system v3.1 -moment v3.1 emoPulse v3.7
8
- EmoLynx v3.6 継承 emoDrive 機構を emoPulse へ統合し簡略化(循環器的機構)
9
- emoPulse 機構により完全自動化を目指す(emoScope 微調整可/改善度反映率)
 
10
  """
11
 
12
  class EmoSens(Optimizer):
13
  # クラス定義&初期化
14
- def __init__(self, params,
15
  lr=1.0,
16
  eps=1e-8,
17
  betas=(0.9, 0.995),
@@ -25,8 +26,10 @@ class EmoSens(Optimizer):
25
  self.use_shadow = use_shadow # 🔸shadow 使用フラグを保存
26
  self.writer = writer # 動的学習率や感情スカラー等を渡す(研究向け)
27
  self.emoScope = lr # 動的学習率の調和とリズム
28
- self.noise_est = 0.1 # emoPulse nest 初期化
29
- self.d_est = 0.1 # emoPulse dest 初期化
 
 
30
 
31
  # 感情EMA更新(緊張と安静)
32
  def _update_ema(self, state, loss_val):
@@ -86,6 +89,31 @@ class EmoSens(Optimizer):
86
  ratio = self._decide_ratio(scalar)
87
  trust = math.copysign((1.0 - abs(scalar)), scalar)
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  for group in self.param_groups:
90
  for p in group['params']:
91
  if p.grad is None:
@@ -108,15 +136,6 @@ class EmoSens(Optimizer):
108
  leap_ratio = 0.1 * abs(trust)
109
  state['shadow'].lerp_(p, leap_ratio)
110
 
111
- # emoPulse (loss 時系列から D / noise を推定し完全自動LRを生成)
112
- # noise_estimate: loss の揺れ(不安定性)のEMA
113
- self.noise_est = 0.7 * self.noise_est + 0.3 * abs(scalar)
114
- noise = max(self.noise_est, 1e-8) # 下限 eps
115
- # distance_estimate: loss の改善傾向の EMA(距離 D の代理)
116
- # emoScope:基準値1.0
117
- self.d_est = 0.95 * self.d_est + 0.05 * abs(trust)
118
- d = self.d_est * self.emoScope
119
-
120
  # --- Start Gradient Update Logic ---
121
  # 1次・2次モーメントを使った勾配補正(decoupled weight decay 構造に近い)
122
  exp_avg = state.setdefault('exp_avg', torch.zeros_like(p))
@@ -128,8 +147,8 @@ class EmoSens(Optimizer):
128
  denom = exp_avg_sq.sqrt().add_(group['eps'])
129
 
130
  #step_size = group['lr']
131
- # 完全自動LR / 安全クリップ (emoPulse = step_size)
132
- emoPulse = max(min((((d / noise)**2) * 5e-5), 1e-3), 1e-6)
133
 
134
  if group['weight_decay']:
135
  p.add_(p, alpha=-group['weight_decay'] * emoPulse)
@@ -150,11 +169,12 @@ class EmoSens(Optimizer):
150
  if avg_abs < 0.05 and var < 0.005:
151
  self.should_stop = True # 💡 外部からこれを見て判断可
152
 
153
- # TensorBoardへの記録(step関数の末尾に追加)
154
  if hasattr(self, 'writer') and self.writer is not None:
155
  self._step_count = getattr(self, "_step_count", 0) + 1
156
- self.writer.add_scalar("emoLR/base", emoPulse, self._step_count)
157
  self.writer.add_scalar("emostate/scalar", scalar, self._step_count)
 
158
 
159
  return
160
 
 
4
  from collections import deque
5
 
6
  """
7
+ EmoSens v3.7.6 (260109) shadow-system v3.1 -moment v3.1 emoPulse v3.7
8
+ EmoNavi v3.6 継承 emoDrive 機構を emoPulse へ統合し簡略化(循環器的機構)
9
+ emoPulse 機構により完全自動化を目指す(ユーザーによる emoScope 調整可/改善度反映率)
10
+ dNR係数により emoPulse に履歴を混ぜて安定させた(d / N 履歴 による信頼度の維持)
11
  """
12
 
13
  class EmoSens(Optimizer):
14
  # クラス定義&初期化
15
+ def __init__(self, params,
16
  lr=1.0,
17
  eps=1e-8,
18
  betas=(0.9, 0.995),
 
26
  self.use_shadow = use_shadow # 🔸shadow 使用フラグを保存
27
  self.writer = writer # 動的学習率や感情スカラー等を渡す(研究向け)
28
  self.emoScope = lr # 動的学習率の調和とリズム
29
+ self.noise_est = 1.0 # emoPulse nest 初期化
30
+ self.d_est = 0.02 # emoPulse dest 初期化
31
+ self.dNR_hist = None # emoPulse hist 初期化
32
+ #self.warmup = 0.01 # emoPulse warmup 初期化
33
 
34
  # 感情EMA更新(緊張と安静)
35
  def _update_ema(self, state, loss_val):
 
89
  ratio = self._decide_ratio(scalar)
90
  trust = math.copysign((1.0 - abs(scalar)), scalar)
91
 
92
+ # emoPulse (loss 時系列から D / noise を推定し完全自動LRを生成)
93
+ #self.warmup = 0.97 * (getattr(self, 'warmup', 0.01) or 0.01) + 0.03 * 1.0
94
+ # d / N 履歴 (時間的D推定)
95
+ self.noise_est = 0.97 * self.noise_est + 0.03 * abs(scalar)
96
+ self.d_est = 0.97 * self.d_est + 0.03 * abs(trust)
97
+ noise = max(self.noise_est, 1e-3)
98
+ d = self.d_est
99
+ # scalar、trust、の差分(瞬間的D推定)と各時間軸の確度推定(疑念と信頼の綱引き)
100
+ noise_base = abs(scalar - trust) + 0.1
101
+ d_base = abs(noise - d) + 0.1
102
+ # SNRにより異なる時間的確度比率から更新力を導出し2乗で出力最大化
103
+ dNR_now_val = (d_base / noise_base) ** 2
104
+ # d / N (SNR) の履歴化と最大値の成長率の増減
105
+ if self.dNR_hist is None:
106
+ self.dNR_hist = 1.0
107
+ else:
108
+ if dNR_now_val >= self.dNR_hist and trust >= 0.5:
109
+ # 加速:どんなに SNR が高くても、1.05倍という「歩幅」の成長制限
110
+ self.dNR_hist = min(dNR_now_val, self.dNR_hist * 1.05)
111
+ elif -0.5 <= trust <= 0.5:
112
+ # 減速:怪しい時は即座に比率を下げる(確実に信頼できない場合に下げ圧力を溜める)
113
+ self.dNR_hist = dNR_now_val * 0.98
114
+ # emoPulse 最終決定: emoScorp によるユーザー意思の反映と安全値による制限
115
+ emoPulse = max(min(self.dNR_hist * (self.emoScope * 1e-4), 3e-3), 1e-6)
116
+
117
  for group in self.param_groups:
118
  for p in group['params']:
119
  if p.grad is None:
 
136
  leap_ratio = 0.1 * abs(trust)
137
  state['shadow'].lerp_(p, leap_ratio)
138
 
 
 
 
 
 
 
 
 
 
139
  # --- Start Gradient Update Logic ---
140
  # 1次・2次モーメントを使った勾配補正(decoupled weight decay 構造に近い)
141
  exp_avg = state.setdefault('exp_avg', torch.zeros_like(p))
 
147
  denom = exp_avg_sq.sqrt().add_(group['eps'])
148
 
149
  #step_size = group['lr']
150
+ # 完全自動LR / 安全クリップ (emoPulse = step_size) # emoScope:基準値1.0
151
+ #emoPulse = max(min(((emobase * self.emoScope) * 5e-5), 1e-3), 1e-6)
152
 
153
  if group['weight_decay']:
154
  p.add_(p, alpha=-group['weight_decay'] * emoPulse)
 
169
  if avg_abs < 0.05 and var < 0.005:
170
  self.should_stop = True # 💡 外部からこれを見て判断可
171
 
172
+ # TensorBoardへの記録 (研究者向けデバッグ用) 要:外部記録コード
173
  if hasattr(self, 'writer') and self.writer is not None:
174
  self._step_count = getattr(self, "_step_count", 0) + 1
175
+ self.writer.add_scalar("emostate/emoLR", emoPulse, self._step_count)
176
  self.writer.add_scalar("emostate/scalar", scalar, self._step_count)
177
+ self.writer.add_scalar("emostate/trust", trust, self._step_count)
178
 
179
  return
180