AbstractIntegratedModule 1.1.0__tar.gz → 1.1.1__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.1.0 → abstractintegratedmodule-1.1.1}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractIntegratedModule.py +64 -29
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractOptimizedModules.c +391 -348
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/PKG-INFO +1 -1
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/README.md +5 -4
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/pyproject.toml +1 -1
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/setup.py +1 -1
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractOptimizedModules.pyx +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/MANIFEST.in +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/Cargo.toml +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/src/lib.rs +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/setup.cfg +0 -0
{abstractintegratedmodule-1.1.0 → abstractintegratedmodule-1.1.1}/AbstractIntegratedModule.py
RENAMED
|
@@ -2155,6 +2155,7 @@ class MLP:
|
|
|
2155
2155
|
X = self._sanitize_string_chars(X)
|
|
2156
2156
|
y = self._sanitize_string_chars(y)
|
|
2157
2157
|
focused_fit_condition = False
|
|
2158
|
+
parameters = sum(w.size for w in self.layers[0].W) + sum(b.size for b in self.layers[0].b)
|
|
2158
2159
|
|
|
2159
2160
|
AME = self.AME_Encoder(X)
|
|
2160
2161
|
AMR = 1.0 / (1.0 + np.exp(-float(AME)))
|
|
@@ -2167,7 +2168,7 @@ class MLP:
|
|
|
2167
2168
|
if training_not_allowed:
|
|
2168
2169
|
print(f'[!] MLP Training not allowed due to unsuitable data characteristics. Anisotropy: {anisotropy:.4f}, AME: {AME:.4f}')
|
|
2169
2170
|
else:
|
|
2170
|
-
print('[+] MLP Training started
|
|
2171
|
+
print(f'[+] MLP Training started with: {parameters} Parameters.')
|
|
2171
2172
|
for epoch in range(epochs):
|
|
2172
2173
|
if not focused_fit_condition:
|
|
2173
2174
|
y_pred = self.forward(X, AME=AME, anisotropy=anisotropy)
|
|
@@ -13110,41 +13111,65 @@ class IntegratedPipeline:
|
|
|
13110
13111
|
return unsuitable_training
|
|
13111
13112
|
|
|
13112
13113
|
def sequence_encoding(self, datasets=None, label_map=None, max_len=32):
|
|
13114
|
+
if not datasets:
|
|
13115
|
+
raise Warning('[!] Dataset is None or empty! Make sure you provide a dataset or create it automatically.')
|
|
13116
|
+
|
|
13117
|
+
if not self.model2:
|
|
13118
|
+
intents = [d[1] for d in datasets]
|
|
13119
|
+
intent_to_id = {intent: i for i, intent in enumerate(sorted(set(intents)))}
|
|
13120
|
+
num_classes = self._get_num_classes(label_map=label_map)
|
|
13121
|
+
self.model2 = Transformer(
|
|
13122
|
+
vocab_size=len(self.vocab),
|
|
13123
|
+
d_model=self.transformer_d_model,
|
|
13124
|
+
n_heads=self.transformer_heads,
|
|
13125
|
+
num_classes=num_classes
|
|
13126
|
+
)
|
|
13127
|
+
|
|
13128
|
+
self._sync_vocab_to_embedding() # once, not per-item
|
|
13129
|
+
|
|
13130
|
+
vocab_size = self.model2.token_embedding.shape[0] # for bounds guard
|
|
13131
|
+
|
|
13113
13132
|
input_sequences = []
|
|
13133
|
+
for item in datasets:
|
|
13134
|
+
text = item[0] if isinstance(item, tuple) else item
|
|
13114
13135
|
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
if not self.model2:
|
|
13118
|
-
intents = [d[1] for d in datasets]
|
|
13119
|
-
intent_to_id = {intent:i for i, intent in enumerate(sorted(set(intents)))}
|
|
13120
|
-
num_classes = self._get_num_classes(label_map=label_map)
|
|
13121
|
-
self.model2 = Transformer(
|
|
13122
|
-
vocab_size=len(self.vocab),
|
|
13123
|
-
d_model=self.transformer_d_model,
|
|
13124
|
-
n_heads=self.transformer_heads,
|
|
13125
|
-
num_classes=num_classes
|
|
13126
|
-
)
|
|
13127
|
-
|
|
13128
|
-
self._sync_vocab_to_embedding()
|
|
13129
|
-
text = item[0] if isinstance(item, tuple) else item
|
|
13136
|
+
token_ids = self.encode(text, self.vocab, max_len=max_len)
|
|
13137
|
+
token_ids = np.asarray(token_ids)
|
|
13130
13138
|
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13139
|
+
# bounds guard before indexing, with informative context
|
|
13140
|
+
out_of_bounds = (token_ids < 0) | (token_ids >= vocab_size)
|
|
13141
|
+
if out_of_bounds.any():
|
|
13142
|
+
n_bad = out_of_bounds.sum()
|
|
13143
|
+
print(f'[⚠️] sequence_encoding: {n_bad} token id(s) out of '
|
|
13144
|
+
f'range [0, {vocab_size}) for text="{str(text)[:50]}" '
|
|
13145
|
+
f'— clamping to valid range. This usually means vocab '
|
|
13146
|
+
f'grew after model2 was constructed; consider rebuilding '
|
|
13147
|
+
f'model2 or resizing token_embedding.')
|
|
13148
|
+
token_ids = np.clip(token_ids, 0, vocab_size - 1)
|
|
13149
|
+
|
|
13150
|
+
token_embs = self.model2.token_embedding[token_ids]
|
|
13151
|
+
pos_embs = self.model2.pos_embedding[:max_len]
|
|
13152
|
+
|
|
13153
|
+
sequence_input = token_embs + pos_embs
|
|
13154
|
+
input_sequences.append(sequence_input)
|
|
13155
|
+
|
|
13156
|
+
return np.stack(input_sequences)
|
|
13134
13157
|
|
|
13135
|
-
sequence_input = token_embs + pos_embs
|
|
13136
|
-
input_sequences.append(sequence_input)
|
|
13137
|
-
return np.stack(input_sequences) # shape: (batch, max_len, d_model)
|
|
13138
|
-
else:
|
|
13139
|
-
raise Warning('[!] Dataset is None! make sure you provide a dataset or create it Automatically!')
|
|
13140
|
-
|
|
13141
|
-
return None
|
|
13142
13158
|
|
|
13143
13159
|
def transformer_pooled_features(self, sequence_inputs):
|
|
13144
|
-
|
|
13160
|
+
"""Mean/max/std pooling over the sequence dimension."""
|
|
13161
|
+
sequence_inputs = np.asarray(sequence_inputs)
|
|
13162
|
+
|
|
13163
|
+
# guard degenerate single-timestep input, where std=0
|
|
13164
|
+
# everywhere is mathematically correct.
|
|
13165
|
+
if sequence_inputs.shape[1] == 1:
|
|
13166
|
+
print('[=] transformer_pooled_features: single-timestep input, '
|
|
13167
|
+
'std_pool will be all zeros (no variance across T=1)')
|
|
13168
|
+
|
|
13145
13169
|
mean_pool = np.mean(sequence_inputs, axis=1)
|
|
13146
|
-
max_pool
|
|
13147
|
-
std_pool
|
|
13170
|
+
max_pool = np.max(sequence_inputs, axis=1)
|
|
13171
|
+
std_pool = np.std(sequence_inputs, axis=1)
|
|
13172
|
+
|
|
13148
13173
|
return np.concatenate([mean_pool, max_pool, std_pool], axis=-1)
|
|
13149
13174
|
|
|
13150
13175
|
def _features_to_sequence(self, X_provided, d_model=None, min_seq_len=2):
|
|
@@ -13462,6 +13487,16 @@ class IntegratedPipeline:
|
|
|
13462
13487
|
else:
|
|
13463
13488
|
self.vocab_size = 1
|
|
13464
13489
|
|
|
13490
|
+
onehot_validation = self._validate_onehot(y)
|
|
13491
|
+
if onehot_validation:
|
|
13492
|
+
if n_classes != len(label_map):
|
|
13493
|
+
n_classes = len(label_map)
|
|
13494
|
+
if n_classes > np.max(y):
|
|
13495
|
+
y = np.eye(n_classes)[np.asarray(y)]
|
|
13496
|
+
else:
|
|
13497
|
+
print('[⚠️] Warning: Y onehot encoding fails, Returning Y samples as is, This may cause Exploding Gradient in MLP Training!')
|
|
13498
|
+
y = y.copy()
|
|
13499
|
+
|
|
13465
13500
|
if self.model2 is None:
|
|
13466
13501
|
self.model2 = Transformer(
|
|
13467
13502
|
vocab_size=self.vocab_size,
|