AbstractIntegratedModule 1.1.8__tar.gz → 1.1.9__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.
Files changed (23) hide show
  1. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
  2. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractIntegratedModule.py +104 -46
  3. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractOptimizedModules.c +200 -200
  4. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/PKG-INFO +1 -1
  5. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/README.md +4 -9
  6. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/pyproject.toml +1 -1
  7. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/setup.py +1 -1
  8. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  9. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  10. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  11. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  12. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/AbstractOptimizedModules.pyx +0 -0
  13. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/MANIFEST.in +0 -0
  14. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/Cargo.toml +0 -0
  15. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/pyproject.toml +0 -0
  16. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/src/lib.rs +0 -0
  17. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
  18. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
  19. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
  20. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
  21. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
  22. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
  23. {abstractintegratedmodule-1.1.8 → abstractintegratedmodule-1.1.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 1.1.8
3
+ Version: 1.1.9
4
4
  Summary: Integrated Pipeline with Specialized Non-LLM AI Agent Framework for ARM64 architecture
5
5
  Author: Micro-Novelty
6
6
  Author-email: Micro-Novelty <hernikpuspita5@gmail.com>
@@ -1757,11 +1757,19 @@ class Transformer:
1757
1757
 
1758
1758
  class Dense:
1759
1759
  def __init__(self, x, input_size, output_size, activation=None):
1760
-
1761
1760
  self.special_weight = GeometricWeightShaping(input_size, output_size)
1762
1761
  self.W = self.special_weight.weight_shaping(x)
1763
-
1764
1762
  self.b = np.zeros((1, output_size))
1763
+
1764
+ self.params_shape = {
1765
+ 'W1': self.W.shape,
1766
+ 'b1': self.b.shape
1767
+ }
1768
+ self.params = {
1769
+ 'W1': self.W,
1770
+ 'b1': self.b
1771
+ }
1772
+ self.opt = AdamOptimizer(self.params_shape, lr=0.001, weight_decay=1e-4)
1765
1773
  self.activation_name = activation
1766
1774
 
1767
1775
 
@@ -1872,8 +1880,9 @@ class Dense:
1872
1880
 
1873
1881
  self.W -= (lr * dW)
1874
1882
  self.b -= (lr * db) + (1.0 + perf_score) * 1e-5 # small bias regularization
1875
-
1876
- return dx
1883
+
1884
+ key_grads = {'W1': dW, 'b1': db}
1885
+ return dx, key_grads
1877
1886
 
1878
1887
 
1879
1888
 
@@ -1889,6 +1898,85 @@ class SoftmaxOutput:
1889
1898
  return dL_dZ
1890
1899
 
1891
1900
 
1901
+
1902
+
1903
+ class AdamOptimizer:
1904
+ def __init__(self, params_shapes, lr=0.001, beta1=0.9, beta2=0.999,
1905
+ eps=1e-8, weight_decay=0.0, amsgrad=False):
1906
+ """
1907
+ params_shapes: dict of {param_name: shape} for every trainable param
1908
+ e.g. {'W1': (20,64), 'b1': (64,), 'W2': (64,3), 'b2': (3,)}
1909
+ weight_decay: decoupled weight decay coefficient (AdamW-style, 0 = off)
1910
+ amsgrad: if True, use the AMSGrad variant (max of v_hat history)
1911
+ """
1912
+ self.lr = lr
1913
+ self.beta1 = beta1
1914
+ self.beta2 = beta2
1915
+ self.eps = eps
1916
+ self.weight_decay = weight_decay
1917
+ self.amsgrad = amsgrad
1918
+ self.t = 0
1919
+
1920
+ self.m = {k: np.zeros(shape) for k, shape in params_shapes.items()}
1921
+ self.v = {k: np.zeros(shape) for k, shape in params_shapes.items()}
1922
+ if self.amsgrad:
1923
+ self.v_max = {k: np.zeros(shape) for k, shape in params_shapes.items()}
1924
+
1925
+ def step(self, params, grads, lr=None, clip_norm=None):
1926
+ self.t += 1
1927
+ lr = self.lr if lr is None else lr
1928
+ bc1 = 1 - self.beta1 ** self.t
1929
+ bc2 = 1 - self.beta2 ** self.t
1930
+
1931
+ for key in grads:
1932
+ g = grads[key]
1933
+ g_shape = np.asarray(g).shape
1934
+
1935
+ # reinitialize any moment buffer whose shape has
1936
+ # drifted from the current gradient,
1937
+ for buf_name, buf_dict in (('m', self.m), ('v', self.v)):
1938
+ if key not in buf_dict or np.asarray(buf_dict[key]).shape != g_shape:
1939
+ if key in buf_dict:
1940
+ print(f'[⚠️] Adam: "{buf_name}" buffer for "{key}" stale '
1941
+ f'shape {np.asarray(buf_dict[key]).shape} != '
1942
+ f'expected {g_shape} — reinitializing to zeros')
1943
+ buf_dict[key] = np.zeros(g_shape)
1944
+
1945
+ if self.amsgrad and (key not in self.v_max or
1946
+ np.asarray(self.v_max[key]).shape != g_shape):
1947
+ self.v_max[key] = np.zeros(g_shape)
1948
+
1949
+ if clip_norm is not None:
1950
+ norm = np.linalg.norm(g)
1951
+ if norm > clip_norm:
1952
+ g = g * (clip_norm / norm)
1953
+
1954
+ if self.weight_decay > 0:
1955
+ params[key] -= lr * self.weight_decay * params[key]
1956
+
1957
+ self.m[key] = self.beta1 * self.m[key] + (1 - self.beta1) * g
1958
+ self.v[key] = self.beta2 * self.v[key] + (1 - self.beta2) * (g ** 2)
1959
+ m_hat = self.m[key] / bc1
1960
+
1961
+ if self.amsgrad:
1962
+ self.v_max[key] = np.maximum(self.v_max[key], self.v[key])
1963
+ v_hat = self.v_max[key] / bc2
1964
+ else:
1965
+ v_hat = self.v[key] / bc2
1966
+
1967
+ # distinguish "params also disagree" (a real backward()
1968
+ # bug) from the moment-buffer case.
1969
+ if np.asarray(params[key]).shape != g_shape:
1970
+ raise ValueError(
1971
+ f'[!] params["{key}"] shape {np.asarray(params[key]).shape} '
1972
+ f'!= grads["{key}"] shape {g_shape} — trace backward() '
1973
+ f'for key "{key}", this is not a stale-buffer issue.'
1974
+ )
1975
+
1976
+ params[key] -= lr * m_hat / (np.sqrt(v_hat) + self.eps)
1977
+
1978
+ return params
1979
+
1892
1980
  # enhanced MLP with focused forward and backward for better handling of data with varying geometric complexity,
1893
1981
  # allowing it to complement the transformer module in the ensemble method.
1894
1982
  # providing robust performance across a wider range of data complexities by dynamically adjusting its learning focus based on the data's geometric properties.
@@ -1901,7 +1989,6 @@ class MLP:
1901
1989
  self.layers = []
1902
1990
  self.layers2 = []
1903
1991
  self.lr = 0.1
1904
- self.feed_layers = []
1905
1992
 
1906
1993
  self.error_counts = None
1907
1994
  self.pred_counts = None
@@ -1911,22 +1998,11 @@ class MLP:
1911
1998
  self.temp_anisotropy_sample = 0
1912
1999
 
1913
2000
  self.softmax = SoftmaxOutput()
1914
-
1915
-
1916
- def feed_add(self, layer):
1917
- self.feed_layers.append(layer)
1918
2001
 
2002
+
1919
2003
  def add(self, layer):
1920
2004
  self.layers.append(layer)
1921
2005
 
1922
- def focused_forward(self, x, AME=None, anisotropy=None):
1923
- performance_score = self.performance_calculation(x, AME=AME, anisotropy=anisotropy)
1924
-
1925
- for layer in self.feed_layers:
1926
- x = layer.forward(np.asarray(x, dtype=np.float64), performance_score)
1927
-
1928
- return self.softmax.forward(x)
1929
-
1930
2006
  def k_fold_split(self, X, y, k=5, seed=42, min_fold_size=2):
1931
2007
  X = np.asarray(X)
1932
2008
  y = np.asarray(y)
@@ -2092,21 +2168,13 @@ class MLP:
2092
2168
  return prob
2093
2169
 
2094
2170
 
2095
- def focused_backward(self, grad, lr, AME, anisotropy):
2096
- grad = self.softmax.backward(grad)
2097
- perf_score = self.performance_calculation(grad, AME=AME, anisotropy=anisotropy)
2098
-
2099
- for layer in reversed(self.feed_layers):
2100
- grad = layer.backward(grad, lr, perf_score)
2101
- return grad
2102
-
2103
2171
  def backward(self, grad, lr):
2104
2172
  grad = self.softmax.backward(grad)
2105
2173
  perf_score = self.performance_calculation(grad, AME=self.temp_AME_sample, anisotropy=self.temp_anisotropy_sample)
2106
2174
 
2107
2175
  for layer in reversed(self.layers):
2108
- grad = layer.backward(grad, lr, perf_score)
2109
- return grad
2176
+ grad, key_grads = layer.backward(grad, lr, perf_score)
2177
+ return grad, key_grads
2110
2178
 
2111
2179
  def predict(self, X, y, epochs=1000, verbose=True):
2112
2180
  for epoch in range(epochs):
@@ -2204,7 +2272,6 @@ class MLP:
2204
2272
  def train(self, X, y, epochs=1000, lr=0.01, verbose=True, max_samples_for_focused_fit=500):
2205
2273
  X = self._sanitize_string_chars(X)
2206
2274
  y = self._sanitize_string_chars(y)
2207
- focused_fit_condition = False
2208
2275
  parameters = sum(w.size for w in self.layers[0].W) + sum(b.size for b in self.layers[0].b)
2209
2276
 
2210
2277
  AME = self.AME_Encoder(X)
@@ -2214,28 +2281,24 @@ class MLP:
2214
2281
  self.temp_AMR_sample = AMR
2215
2282
  self.temp_anisotropy_sample = anisotropy
2216
2283
 
2217
- focused_fit_condition = len(self.feed_layers) > 0 and anisotropy > 0.25 and AMR > 0.25 and len(X) < max_samples_for_focused_fit
2218
- print(f'[+] Focused fit condition: {focused_fit_condition} || Anisotropy: {self.anisotropy_measurement(X):.4f} || AME: {self.AME_Encoder(X):.4f}')
2219
-
2220
2284
  training_not_allowed = np.isnan(anisotropy) or np.isinf(anisotropy) or np.isnan(AME) or np.isinf(AME) or AME < 0.1
2221
2285
  if training_not_allowed:
2222
2286
  print(f'[!] MLP Training not allowed due to unsuitable data characteristics. Anisotropy: {anisotropy:.4f}, AME: {AME:.4f}')
2223
2287
  else:
2224
2288
  print(f'[+] MLP Training started with: {parameters} Parameters.')
2225
2289
  for epoch in range(epochs):
2226
- if not focused_fit_condition:
2227
- y_pred = self.forward(X, y=y, AME=AME, anisotropy=anisotropy, condition='training')
2228
- else:
2229
- y_pred = self.focused_forward(X, AME=AME, anisotropy=anisotropy)
2230
-
2290
+ y_pred = self.forward(X, y=y, AME=AME, anisotropy=anisotropy, condition='training')
2231
2291
  y_pred, y_true = self.adapt_predict_shape(y_pred, y)
2232
2292
 
2233
2293
  loss = Loss.categorical_crossentropy(y_true, y_pred)
2234
2294
  grad = Loss.softmax_crossentropy_derivative(y_true, y_pred)
2235
- if focused_fit_condition:
2236
- _ = self.focused_backward(grad, self.lr, AME, anisotropy)
2237
- else:
2238
- _ = self.backward(grad, self.lr)
2295
+ grad, key_grads = self.backward(grad, self.lr)
2296
+ try:
2297
+ params = self.layers[0].opt.step(self.layers[0].params, key_grads, clip_norm=5.0)
2298
+ except Exception as e:
2299
+ print(f'[>] AdamOptimizer failed: {e}')
2300
+ continue
2301
+
2239
2302
  if np.isnan(loss) or np.isinf(loss):
2240
2303
  if focused_fit_condition:
2241
2304
  focused_fit_condition = False
@@ -10267,8 +10330,6 @@ class IntegratedPipeline:
10267
10330
  model.add(layer1)
10268
10331
  model.add(layer2)
10269
10332
 
10270
- model.feed_add(layer1)
10271
- model.feed_add(layer2)
10272
10333
 
10273
10334
  return y_onehot
10274
10335
 
@@ -10289,10 +10350,7 @@ class IntegratedPipeline:
10289
10350
  self.model3 = MLP()
10290
10351
 
10291
10352
  self.model3.add(layer1)
10292
- self.model3.add(layer2)
10293
-
10294
- self.model3.feed_add(first_feed_layer)
10295
- self.model3.feed_add(sec_feed_layer)
10353
+ self.model3.add(layer2)
10296
10354
 
10297
10355
 
10298
10356
  def automatic_parameterization(self, input_size, num_classes):