MicroTensorGrad 1.0.2__tar.gz → 1.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MicroTensorGrad
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: A Tensor Based autograd engine used to train neural network based models
5
5
  Author-email: Guettara Mohamed Amine <guettaraamine2@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "MicroTensorGrad"
7
- version = "1.0.2"
7
+ version = "1.0.4"
8
8
  description = "A Tensor Based autograd engine used to train neural network based models"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -64,15 +64,15 @@ class MicroTensor:
64
64
  return out
65
65
 
66
66
  def Softmax(self):
67
- epsilon = 1e-8
68
67
  e_x = np.exp(self.array - np.max(self.array, axis=1, keepdims=True))
69
- return e_x / (np.sum(e_x, axis=1, keepdims=True) + epsilon)
68
+ return e_x / (np.sum(e_x, axis=1, keepdims=True))
70
69
 
71
70
  def CrossEntopyLoss(self, Y : np.ndarray):
72
- out = MicroTensor(np.mean(-np.sum(Y*np.log(self.Softmax()), axis=1), axis=0))
71
+ out = MicroTensor(np.mean(-np.sum(Y*np.log(self.Softmax().clip(1e-15, 1)), axis=1), axis=0))
73
72
 
74
73
  def backward():
75
- self.grad += self.Softmax() - Y
74
+ batch_size = Y.shape[0]
75
+ self.grad += (self.Softmax() - Y)/batch_size
76
76
 
77
77
  out.backward_ = backward
78
78
 
@@ -1,7 +1,7 @@
1
1
  import numpy as np
2
- from .Engine import MicroTensor
2
+ from Engine import MicroTensor
3
3
  from typing import Literal
4
- from .Optimizers import Optimizer
4
+ from Optimizers import Optimizer
5
5
 
6
6
  def HE_Initialization(in_ : int, out_ : int):
7
7
  return np.random.normal(loc=0, scale=np.sqrt(2/in_), size=(in_, out_))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MicroTensorGrad
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: A Tensor Based autograd engine used to train neural network based models
5
5
  Author-email: Guettara Mohamed Amine <guettaraamine2@gmail.com>
6
6
  License: MIT
File without changes