netlite 0.0.4__tar.gz → 0.0.5__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.
- {netlite-0.0.4 → netlite-0.0.5}/PKG-INFO +1 -1
- {netlite-0.0.4 → netlite-0.0.5}/pyproject.toml +1 -1
- {netlite-0.0.4 → netlite-0.0.5}/src/netlite/__init__.py +1 -4
- {netlite-0.0.4 → netlite-0.0.5}/src/netlite/layers.py +1 -0
- {netlite-0.0.4 → netlite-0.0.5}/src/netlite/neural_network.py +16 -1
- {netlite-0.0.4 → netlite-0.0.5}/.gitignore +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/LICENSE +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/README.md +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/examples/netlite_example_fit_regression_line.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/examples/netlite_example_lenet_cifar10.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/examples/netlite_example_lenet_mnist.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/examples/netlite_example_xor_classifier.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/images/lenet_mnist_acc_curves.svg +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/package_build.sh +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/package_upload.sh +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/requirements.txt +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/src/netlite/dataloader_cifar10.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/src/netlite/dataloader_mnist.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/src/netlite/loss_functions.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/src/netlite/optimizer.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/tests/netlite_test.py +0 -0
- {netlite-0.0.4 → netlite-0.0.5}/tests/netlite_test_convolution.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: netlite
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: A small white-box training framework for neural networks for education.
|
|
5
5
|
Project-URL: Homepage, https://github.com/haho12/netlite
|
|
6
6
|
Project-URL: Issues, https://github.com/haho12/netlite/issues
|
|
@@ -12,10 +12,7 @@ from .dataloader_mnist import *
|
|
|
12
12
|
from .dataloader_cifar10 import *
|
|
13
13
|
|
|
14
14
|
# set nl.__version__
|
|
15
|
-
|
|
16
|
-
from importlib.metadata import version, PackageNotFoundError
|
|
17
|
-
except ImportError: # for Python < 3.8
|
|
18
|
-
from importlib_metadata import version, PackageNotFoundError
|
|
15
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
19
16
|
try:
|
|
20
17
|
__version__ = version("netlite") # get version from pyproject.toml
|
|
21
18
|
except PackageNotFoundError:
|
|
@@ -271,6 +271,7 @@ class BatchNorm(Layer):
|
|
|
271
271
|
x_out = (X - self.running_mean) / np.sqrt(self.running_var + self.eps)
|
|
272
272
|
else:
|
|
273
273
|
# Use running averages at inference
|
|
274
|
+
assert hasattr(self, 'running_var'), 'BatchNorm must be called in training-mode first.'
|
|
274
275
|
x_out = (X - self.running_mean) / np.sqrt(self.running_var + self.eps)
|
|
275
276
|
|
|
276
277
|
return x_out
|
|
@@ -44,4 +44,19 @@ class NeuralNetwork():
|
|
|
44
44
|
Xin = np.zeros(input_shape, dtype='f')
|
|
45
45
|
for layer in self.layers:
|
|
46
46
|
Xin = layer.print(Xin)
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
def save(self, filename):
|
|
49
|
+
model = {}
|
|
50
|
+
for i, layer in enumerate(self.layers):
|
|
51
|
+
weights = layer.get_weights()
|
|
52
|
+
model[i] = weights
|
|
53
|
+
np.save(filename, model)
|
|
54
|
+
|
|
55
|
+
def load(self, filename):
|
|
56
|
+
loaded_params = np.load(filename, allow_pickle=True).item()
|
|
57
|
+
assert len(loaded_params) == len(self.layers), f'Error: Unexpected number of layers in file {filename}.'
|
|
58
|
+
for i, layer in enumerate(self.layers):
|
|
59
|
+
weights = layer.get_weights()
|
|
60
|
+
for key in weights:
|
|
61
|
+
assert key in loaded_params[i].keys(), f'Error: Key {key} no found in layer {i} of file {filename}.'
|
|
62
|
+
weights[key] = loaded_params[i][key]
|
|
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
|
|
File without changes
|
|
File without changes
|