-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first commit * trigger CI * fix BatchNorm --------- Co-authored-by: wkcn <wkcn@live.cn>
- Loading branch information
1 parent
2ad17c2
commit 6fcef88
Showing
7 changed files
with
55 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
from .LossLayer import * | ||
import numpy as np | ||
|
||
class CrossEntropy(LossLayer): | ||
def __init__(self, model, *args, **kwargs): | ||
LossLayer.__init__(self, model, *args, **kwargs) | ||
super().__init__(model, *args, **kwargs) | ||
|
||
def reshape(self): | ||
self.Y = 0.0 | ||
|
||
def forward(self): | ||
self.Y = np.mean(- np.multiply(self.label, np.log(self.X)) - \ | ||
np.multiply(1.0 - self.label, np.log(1.0 - self.X))) | ||
self.Y = np.mean(- np.multiply(self.label, np.log(self.X + 1e-15)) - \ | ||
np.multiply(1.0 - self.label, np.log(1.0 - self.X + 1e-15))) | ||
|
||
def backward(self): | ||
self.dX = (-self.label / self.X + (1.0 - self.label) / (1.0 - self.X)) * self.dY | ||
self.dX = (-self.label / (self.X + 1e-15) + (1.0 - self.label) / (1.0 - self.X + 1e-15)) * self.dY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
from .LossLayer import * | ||
import numpy as np | ||
|
||
class MSE(LossLayer): | ||
def __init__(self, model, *args, **kwargs): | ||
LossLayer.__init__(self, model, *args, **kwargs) | ||
super().__init__(model, *args, **kwargs) | ||
|
||
def reshape(self): | ||
self.Y = 0.0 | ||
|
||
def forward(self): | ||
self.d = (self.X - self.label) | ||
self.Y = np.mean(np.square(self.d)) | ||
|
||
def backward(self): | ||
self.dX = (2 * self.d) * self.dY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
from .Layer import * | ||
import numpy as np | ||
|
||
class Tanh(Layer): | ||
def __init__(self, model, *args, **kwargs): | ||
Layer.__init__(self, model, *args, **kwargs) | ||
super().__init__(model, *args, **kwargs) | ||
|
||
def reshape(self): | ||
self.Y = np.zeros(self.X.shape) | ||
|
||
def forward(self): | ||
self.Y = 2.0 / (1.0 + np.exp(-2.0 * self.X)) - 1.0 | ||
|
||
def backward(self): | ||
self.dX = np.multiply(self.dY, 1.0 - np.square(self.Y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
numpy | ||
numpy_groupies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name = 'mobula', | ||
version = '1.0.1', | ||
description = 'A Lightweight & Flexible Deep Learning (Neural Network) Framework in Python', | ||
author = 'wkcn', | ||
author_email = 'wkcn@live.cn', | ||
url = 'https://github.com/wkcn/mobula', | ||
packages = find_packages(), | ||
package_data = { | ||
'' : ['*.md'], | ||
'docs' : ['docs/*.md'], | ||
'examples' : ['examples/*.py'] | ||
}, | ||
keywords = 'Deep Learning Framework in Python', | ||
license = 'MIT', | ||
classifiers = [ | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 3', | ||
'Topic :: Scientific/Engineering :: Mathematics', | ||
'License :: OSI Approved :: MIT License' | ||
], | ||
install_requires = [ | ||
'numpy', | ||
'numpy_groupies' | ||
] | ||
name='mobula', | ||
version='1.0.2', | ||
description='A Lightweight & Flexible Deep Learning (Neural Network) Framework in Python', | ||
author='wkcn', | ||
author_email='wkcn@live.cn', | ||
url='https://github.com/wkcn/mobula', | ||
packages=find_packages(), | ||
package_data={ | ||
'': ['*.md'], | ||
'docs': ['docs/*.md'], | ||
'examples': ['examples/*.py'] | ||
}, | ||
keywords='Deep Learning Framework in Python', | ||
license='MIT', | ||
classifiers=[ | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Topic :: Scientific/Engineering :: Mathematics', | ||
'License :: OSI Approved :: MIT License' | ||
], | ||
install_requires=[ | ||
'numpy', | ||
'numpy_groupies' | ||
], | ||
python_requires='>=3.6', | ||
) |