NeuralEngine 0.2.3__tar.gz → 0.2.4__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.
- {neuralengine-0.2.3 → neuralengine-0.2.4/NeuralEngine.egg-info}/PKG-INFO +2 -1
- {neuralengine-0.2.3/NeuralEngine.egg-info → neuralengine-0.2.4}/PKG-INFO +2 -1
- {neuralengine-0.2.3 → neuralengine-0.2.4}/README.md +1 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/nn/layers.py +18 -3
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/tensor.py +10 -10
- {neuralengine-0.2.3 → neuralengine-0.2.4}/pyproject.toml +1 -1
- {neuralengine-0.2.3 → neuralengine-0.2.4}/setup.py +1 -1
- {neuralengine-0.2.3 → neuralengine-0.2.4}/LICENSE +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/MANIFEST.in +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/NeuralEngine.egg-info/SOURCES.txt +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/NeuralEngine.egg-info/dependency_links.txt +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/NeuralEngine.egg-info/requires.txt +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/NeuralEngine.egg-info/top_level.txt +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/__init__.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/config.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/nn/__init__.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/nn/loss.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/nn/metrics.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/nn/model.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/nn/optim.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/neuralengine/utils.py +0 -0
- {neuralengine-0.2.3 → neuralengine-0.2.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: NeuralEngine
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: A framework/library for building and training neural networks.
|
|
5
5
|
Home-page: https://github.com/Prajjwal2404/NeuralEngine
|
|
6
6
|
Author: Prajjwal Pratap Shah
|
|
@@ -202,6 +202,7 @@ NeuralEngine offers the following core capabilities:
|
|
|
202
202
|
- `ne.Embedding(embed_size, vocab_size, timesteps=None)`: Embedding layer for mapping indices to dense vectors, with optional positional encoding.
|
|
203
203
|
- `ne.LayerNorm(num_feat, eps=1e-7)`: Layer normalization for stabilizing training.
|
|
204
204
|
- `ne.Dropout(prob=0.5)`: Dropout regularization for reducing overfitting.
|
|
205
|
+
- `ne.Layer.freezed = True/False`: Freeze or unfreeze layer parameters during training.
|
|
205
206
|
- All layers inherit from a common base and support extensibility for custom architectures.
|
|
206
207
|
|
|
207
208
|
### Activations
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: NeuralEngine
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: A framework/library for building and training neural networks.
|
|
5
5
|
Home-page: https://github.com/Prajjwal2404/NeuralEngine
|
|
6
6
|
Author: Prajjwal Pratap Shah
|
|
@@ -202,6 +202,7 @@ NeuralEngine offers the following core capabilities:
|
|
|
202
202
|
- `ne.Embedding(embed_size, vocab_size, timesteps=None)`: Embedding layer for mapping indices to dense vectors, with optional positional encoding.
|
|
203
203
|
- `ne.LayerNorm(num_feat, eps=1e-7)`: Layer normalization for stabilizing training.
|
|
204
204
|
- `ne.Dropout(prob=0.5)`: Dropout regularization for reducing overfitting.
|
|
205
|
+
- `ne.Layer.freezed = True/False`: Freeze or unfreeze layer parameters during training.
|
|
205
206
|
- All layers inherit from a common base and support extensibility for custom architectures.
|
|
206
207
|
|
|
207
208
|
### Activations
|
|
@@ -154,6 +154,7 @@ NeuralEngine offers the following core capabilities:
|
|
|
154
154
|
- `ne.Embedding(embed_size, vocab_size, timesteps=None)`: Embedding layer for mapping indices to dense vectors, with optional positional encoding.
|
|
155
155
|
- `ne.LayerNorm(num_feat, eps=1e-7)`: Layer normalization for stabilizing training.
|
|
156
156
|
- `ne.Dropout(prob=0.5)`: Dropout regularization for reducing overfitting.
|
|
157
|
+
- `ne.Layer.freezed = True/False`: Freeze or unfreeze layer parameters during training.
|
|
157
158
|
- All layers inherit from a common base and support extensibility for custom architectures.
|
|
158
159
|
|
|
159
160
|
### Activations
|
|
@@ -14,6 +14,7 @@ class Layer:
|
|
|
14
14
|
def __init__(self):
|
|
15
15
|
self._mode: Mode = Mode.TRAIN
|
|
16
16
|
self._in_size: tuple | None = None
|
|
17
|
+
self._freezed: bool = False
|
|
17
18
|
|
|
18
19
|
def __call__(self, x, *args, **kwargs) -> Tensor:
|
|
19
20
|
"""
|
|
@@ -61,6 +62,20 @@ class Layer:
|
|
|
61
62
|
"""Performs the forward pass of the layer. To be implemented by subclasses."""
|
|
62
63
|
raise NotImplementedError("forward() must be implemented in subclasses")
|
|
63
64
|
|
|
65
|
+
@property
|
|
66
|
+
def freezed(self) -> bool:
|
|
67
|
+
"""Whether the layer's parameters are frozen (not trainable)."""
|
|
68
|
+
return self._freezed
|
|
69
|
+
|
|
70
|
+
@freezed.setter
|
|
71
|
+
def freezed(self, freeze: bool) -> None:
|
|
72
|
+
self._freezed = freeze
|
|
73
|
+
for _, attr in self.__dict__.items():
|
|
74
|
+
if isinstance(attr, Layer):
|
|
75
|
+
attr.freezed = freeze
|
|
76
|
+
elif isinstance(attr, Tensor):
|
|
77
|
+
attr.requires_grad = not freeze
|
|
78
|
+
|
|
64
79
|
def parameters(self):
|
|
65
80
|
"""Yields all trainable parameters for the layer."""
|
|
66
81
|
for _, attr in self.__dict__.items():
|
|
@@ -156,7 +171,7 @@ class LSTM(Layer):
|
|
|
156
171
|
if self.attention:
|
|
157
172
|
self.attention.in_size = self.enc_size if self.enc_size else self.out_size
|
|
158
173
|
|
|
159
|
-
def forward(self, x: Tensor, c: Tensor = None, h: Tensor = None, enc_seq: Tensor = None):
|
|
174
|
+
def forward(self, x: Tensor, c: Tensor = None, h: Tensor = None, enc_seq: Tensor = None) -> list[Tensor]:
|
|
160
175
|
# LSTM forward pass
|
|
161
176
|
c = c if c else zeros((x.shape[0], self.out_size))
|
|
162
177
|
h = h if h else zeros((x.shape[0], self.out_size + self.ctx_size))
|
|
@@ -310,8 +325,8 @@ class LayerNorm(Layer):
|
|
|
310
325
|
super().__init__()
|
|
311
326
|
self.eps = eps
|
|
312
327
|
if num_feat:
|
|
313
|
-
self.gamma = ones(
|
|
314
|
-
self.beta = zeros(
|
|
328
|
+
self.gamma = ones(num_feat, requires_grad=True)
|
|
329
|
+
self.beta = zeros(num_feat, requires_grad=True)
|
|
315
330
|
|
|
316
331
|
def forward(self, x: Tensor) -> Tensor:
|
|
317
332
|
# z = (x - μ) / (σ + ε)
|
|
@@ -2,7 +2,7 @@ import neuralengine.config as cf
|
|
|
2
2
|
from itertools import accumulate
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
autograd_enabled: bool = True
|
|
6
6
|
|
|
7
7
|
class Tensor:
|
|
8
8
|
"""Core Tensor class for autograd and computation."""
|
|
@@ -12,11 +12,11 @@ class Tensor:
|
|
|
12
12
|
@param requires_grad: Whether to track gradients for this tensor.
|
|
13
13
|
@param dtype: Data type of the tensor.
|
|
14
14
|
"""
|
|
15
|
-
global
|
|
15
|
+
global autograd_enabled
|
|
16
16
|
self.data = array(data, dtype=dtype)
|
|
17
|
-
self.requires_grad = requires_grad if
|
|
17
|
+
self.requires_grad = requires_grad if autograd_enabled else False
|
|
18
18
|
self.shape = self.data.shape
|
|
19
|
-
self.dtype = dtype
|
|
19
|
+
self.dtype = dtype
|
|
20
20
|
self._operation = _operation
|
|
21
21
|
if self.requires_grad:
|
|
22
22
|
self.grad = cf.nu.zeros_like(self.data)
|
|
@@ -33,7 +33,7 @@ class Tensor:
|
|
|
33
33
|
|
|
34
34
|
def __repr__(self) -> str:
|
|
35
35
|
"""String representation of the tensor."""
|
|
36
|
-
return f"Tensor(data={self.data}, dtype={self.dtype}, requires_grad={self.requires_grad})"
|
|
36
|
+
return f"Tensor(data={self.data}, dtype={self.dtype.__name__}, requires_grad={self.requires_grad})"
|
|
37
37
|
|
|
38
38
|
def __add__(self, other):
|
|
39
39
|
"""New = A + B"""
|
|
@@ -742,13 +742,13 @@ class SetSlice:
|
|
|
742
742
|
class NoGrad:
|
|
743
743
|
"""Context manager to disable gradient tracking."""
|
|
744
744
|
def __enter__(self):
|
|
745
|
-
global
|
|
746
|
-
self.prev =
|
|
747
|
-
|
|
745
|
+
global autograd_enabled
|
|
746
|
+
self.prev = autograd_enabled
|
|
747
|
+
autograd_enabled = False
|
|
748
748
|
|
|
749
749
|
def __exit__(self, *_):
|
|
750
|
-
global
|
|
751
|
-
|
|
750
|
+
global autograd_enabled
|
|
751
|
+
autograd_enabled = self.prev
|
|
752
752
|
|
|
753
753
|
|
|
754
754
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "NeuralEngine"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.4"
|
|
8
8
|
description = "A framework/library for building and training neural networks."
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Prajjwal Pratap Shah", email = "prajjwalpratapshah@outlook.com" }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|