AbstractIntegratedModule 1.0.5__tar.gz → 1.0.7__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.
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractIntegratedModule.py +37 -8
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractOptimizedModules.c +200 -200
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/PKG-INFO +1 -1
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/README.md +8 -5
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/pyproject.toml +1 -1
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/setup.py +1 -1
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractOptimizedModules.pyx +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/MANIFEST.in +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/Cargo.toml +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/src/lib.rs +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/setup.cfg +0 -0
{abstractintegratedmodule-1.0.5 → abstractintegratedmodule-1.0.7}/AbstractIntegratedModule.py
RENAMED
|
@@ -1868,7 +1868,7 @@ class MLP:
|
|
|
1868
1868
|
standard_low_error_mean + standard_pred_quality)
|
|
1869
1869
|
|
|
1870
1870
|
if np.isnan(performance_score) or np.isinf(performance_score):
|
|
1871
|
-
performance_score = 0.
|
|
1871
|
+
performance_score = 0.15
|
|
1872
1872
|
|
|
1873
1873
|
return performance_score
|
|
1874
1874
|
|
|
@@ -2122,12 +2122,13 @@ class LSTMCell:
|
|
|
2122
2122
|
scale = np.sqrt(2.0 / (input_size + hidden_size))
|
|
2123
2123
|
self.W = np.random.randn(4 * hidden_size, input_size + hidden_size) * scale
|
|
2124
2124
|
self.b = np.zeros((4 * hidden_size,))
|
|
2125
|
+
self.b[:hidden_size] = 1.0 # forget gate bias init to 1.0
|
|
2125
2126
|
|
|
2126
2127
|
# Output projection: hidden → output
|
|
2127
2128
|
self.Wy = np.random.randn(hidden_size, hidden_size) * scale
|
|
2128
2129
|
self.by = np.zeros((hidden_size,))
|
|
2129
2130
|
|
|
2130
|
-
# ── slicing helpers ──────────────────────
|
|
2131
|
+
# ── slicing helpers utility functions ──────────────────────
|
|
2131
2132
|
def _f(self, v): return v[:self.hidden_size]
|
|
2132
2133
|
def _i(self, v): return v[self.hidden_size:2*self.hidden_size]
|
|
2133
2134
|
def _g(self, v): return v[2*self.hidden_size:3*self.hidden_size]
|
|
@@ -2184,6 +2185,8 @@ class LSTMCell:
|
|
|
2184
2185
|
o = sigmoid(z[H3:])
|
|
2185
2186
|
|
|
2186
2187
|
c_new = f * c + i * g
|
|
2188
|
+
c_new = np.clip(c_new, -10.0, 10.0) # prevent overflow in tanh
|
|
2189
|
+
|
|
2187
2190
|
tanh_c = np.tanh(c_new)
|
|
2188
2191
|
h_new = o * tanh_c
|
|
2189
2192
|
|
|
@@ -2268,6 +2271,8 @@ class LSTMNetwork:
|
|
|
2268
2271
|
self.pipeline = pipeline
|
|
2269
2272
|
self._trained = False
|
|
2270
2273
|
|
|
2274
|
+
self._grad_norm_history = [] # for logging gradient health
|
|
2275
|
+
|
|
2271
2276
|
# forward method to calculate proper weight for prediction and training.
|
|
2272
2277
|
def forward(self, x_seq):
|
|
2273
2278
|
# also Wy init only here, removed from train_step
|
|
@@ -2296,7 +2301,7 @@ class LSTMNetwork:
|
|
|
2296
2301
|
|
|
2297
2302
|
diff = preds - targets
|
|
2298
2303
|
loss = (1.0 - AMR) * np.mean(diff ** 2)
|
|
2299
|
-
dloss = diff / (min_T * min_F) #
|
|
2304
|
+
dloss = diff / (min_T * min_F) # normalized by full element count
|
|
2300
2305
|
return loss, dloss
|
|
2301
2306
|
|
|
2302
2307
|
# backward method for the network to calculate proper weights with cell backward
|
|
@@ -2329,7 +2334,7 @@ class LSTMNetwork:
|
|
|
2329
2334
|
self.by -= lr * out_grads["dby"]
|
|
2330
2335
|
|
|
2331
2336
|
# train step for each LSTM fitting method
|
|
2332
|
-
def train_step(self, x_seq, targets, lr=1e-3, AMR=None):
|
|
2337
|
+
def train_step(self, x_seq, targets, lr=1e-3, AMR=None, log_grad_health=True):
|
|
2333
2338
|
# accept precomputed AMR
|
|
2334
2339
|
if AMR is None:
|
|
2335
2340
|
AME = self.pipeline.AME_Encoder(x_seq)
|
|
@@ -2338,6 +2343,23 @@ class LSTMNetwork:
|
|
|
2338
2343
|
preds, hs, cs, cache = self.forward(x_seq)
|
|
2339
2344
|
loss, dloss = self.loss_mse(preds, targets, AMR)
|
|
2340
2345
|
cell_grads, out_grads, _ = self.backward(dloss, hs, cache)
|
|
2346
|
+
|
|
2347
|
+
if log_grad_health:
|
|
2348
|
+
grad_norm = np.sqrt(sum(np.sum(g**2) for g in {**cell_grads, **out_grads}.values()))
|
|
2349
|
+
if not hasattr(self, '_grad_norm_history'):
|
|
2350
|
+
self._grad_norm_history = []
|
|
2351
|
+
self._grad_norm_history.append(float(grad_norm))
|
|
2352
|
+
|
|
2353
|
+
# flag genuinely pathological training, not just noise
|
|
2354
|
+
if len(self._grad_norm_history) >= 10:
|
|
2355
|
+
recent = self._grad_norm_history[-10:]
|
|
2356
|
+
if np.mean(recent) < 1e-6:
|
|
2357
|
+
print('[⚠️] LSTM gradient norm near-zero for 10 steps — '
|
|
2358
|
+
'possible vanishing gradient, training may have stalled!')
|
|
2359
|
+
elif np.mean(recent) > 100.0:
|
|
2360
|
+
print('[⚠️] LSTM gradient norm consistently large — '
|
|
2361
|
+
'clipping is doing heavy lifting, consider lowering learning rate!')
|
|
2362
|
+
|
|
2341
2363
|
self.update(cell_grads, out_grads, lr)
|
|
2342
2364
|
return loss, preds
|
|
2343
2365
|
|
|
@@ -5123,7 +5145,7 @@ class ModelStorage:
|
|
|
5123
5145
|
repaired = {}
|
|
5124
5146
|
for key, value in data.items():
|
|
5125
5147
|
|
|
5126
|
-
# dynamic corruption check
|
|
5148
|
+
# dynamic corruption check
|
|
5127
5149
|
if isinstance(value, list):
|
|
5128
5150
|
arr = np.asarray(value)
|
|
5129
5151
|
if arr.ndim > 2:
|
|
@@ -5137,7 +5159,7 @@ class ModelStorage:
|
|
|
5137
5159
|
f'{arr.shape}, expected {num_classes} — removing')
|
|
5138
5160
|
continue
|
|
5139
5161
|
|
|
5140
|
-
# None values —
|
|
5162
|
+
# None values — skipped silently
|
|
5141
5163
|
if value is None:
|
|
5142
5164
|
continue
|
|
5143
5165
|
|
|
@@ -9303,7 +9325,7 @@ class IntegratedPipeline:
|
|
|
9303
9325
|
self.transformer_d_model = 32
|
|
9304
9326
|
self.transformer_heads = 4
|
|
9305
9327
|
self.transformer_training_epochs = 100
|
|
9306
|
-
self.lstm_training_epochs =
|
|
9328
|
+
self.lstm_training_epochs = 100
|
|
9307
9329
|
self.lstm_lr = 5e-2
|
|
9308
9330
|
self.lstm_hidden_dim = 64
|
|
9309
9331
|
|
|
@@ -17007,8 +17029,15 @@ class PipelinePredictionManager:
|
|
|
17007
17029
|
trans_confidence = results[0].get('trans_confidence', 1e-8)
|
|
17008
17030
|
confidence = (confidence + trans_confidence / 2) + 1e-5
|
|
17009
17031
|
print(f'[=] Calibrating confidence around: {confidence:.1%} Due to disagreement between Transformer and MLP.')
|
|
17032
|
+
|
|
17033
|
+
if isinstance(chosen_label, str) and chosen_label.startswith("unknown") or float(confidence) < self.pipeline.confidence_threshold:
|
|
17034
|
+
if chosen_label is None or chosen_label.startswith('unknown'):
|
|
17035
|
+
chosen_label = 'Unknown'
|
|
17036
|
+
confidence = 1.0 - confidence #Invert confidence for unknown class
|
|
17037
|
+
print(f"\n[⚠️] Final prediction is {chosen_label} with uncertain confidence: {confidence:.1%}. Consider more consistent data for the model to learn from.")
|
|
17038
|
+
else:
|
|
17039
|
+
print(f"\n[🎯] Predicted label: {chosen_label} || With Certain Confidence: {confidence:.1%}")
|
|
17010
17040
|
|
|
17011
|
-
print(f"\n[🎯] Predicted label: {chosen_label} || With Certain Confidence: {confidence:.1%}")
|
|
17012
17041
|
payload = {
|
|
17013
17042
|
'X_samples': X,
|
|
17014
17043
|
'input_ids': input_ids
|