loglu-pytorch 0.0.1__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.
- loglu_pytorch-0.0.1/PKG-INFO +57 -0
- loglu_pytorch-0.0.1/README.md +39 -0
- loglu_pytorch-0.0.1/loglu_pytorch/__init__.py +1 -0
- loglu_pytorch-0.0.1/loglu_pytorch/loglu_pytorch.py +28 -0
- loglu_pytorch-0.0.1/loglu_pytorch.egg-info/PKG-INFO +57 -0
- loglu_pytorch-0.0.1/loglu_pytorch.egg-info/SOURCES.txt +9 -0
- loglu_pytorch-0.0.1/loglu_pytorch.egg-info/dependency_links.txt +1 -0
- loglu_pytorch-0.0.1/loglu_pytorch.egg-info/requires.txt +1 -0
- loglu_pytorch-0.0.1/loglu_pytorch.egg-info/top_level.txt +1 -0
- loglu_pytorch-0.0.1/setup.cfg +4 -0
- loglu_pytorch-0.0.1/setup.py +27 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: loglu-pytorch
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: LogLU Activation Function - PyTorch
|
|
5
|
+
Home-page: https://github.com/XenReZ/LogLU-PyTorch
|
|
6
|
+
Author: Murumuri Naga Poorni
|
|
7
|
+
Author-email: poorni.m0405@gmail.com
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.6
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: torch>=1.6.0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install loglu-pytorch
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Implementation
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import torch
|
|
30
|
+
from loglu_pytorch import LogLU
|
|
31
|
+
|
|
32
|
+
# Define the model
|
|
33
|
+
class MyModel(nn.Module):
|
|
34
|
+
def __init__(self):
|
|
35
|
+
super(MyModel, self).__init__()
|
|
36
|
+
self.fc1 = nn.Linear(784, 128)
|
|
37
|
+
self.loglu = LogLU() # <----- In This Way
|
|
38
|
+
self.fc2 = nn.Linear(128, 10)
|
|
39
|
+
|
|
40
|
+
def forward(self, x):
|
|
41
|
+
x = self.fc1(x)
|
|
42
|
+
x = self.loglu(x)
|
|
43
|
+
x = self.fc2(x)
|
|
44
|
+
return F.softmax(x, dim=1) # Equivalent to 'softmax' activation in final layer
|
|
45
|
+
|
|
46
|
+
# Instantiate the model
|
|
47
|
+
model = MyModel()
|
|
48
|
+
|
|
49
|
+
# Print the model summary (you can use torchsummary for a detailed view)
|
|
50
|
+
from torchsummary import summary
|
|
51
|
+
summary(model, input_size=(1, 784))
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
LogLU_Pytorch is released under the [Apache License 2.0](https://github.com/XenReZ/LogLU-PyTorch/blob/main/LICENSE).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
### Installation
|
|
3
|
+
|
|
4
|
+
```bash
|
|
5
|
+
pip install loglu-pytorch
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### Implementation
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
import torch
|
|
12
|
+
from loglu_pytorch import LogLU
|
|
13
|
+
|
|
14
|
+
# Define the model
|
|
15
|
+
class MyModel(nn.Module):
|
|
16
|
+
def __init__(self):
|
|
17
|
+
super(MyModel, self).__init__()
|
|
18
|
+
self.fc1 = nn.Linear(784, 128)
|
|
19
|
+
self.loglu = LogLU() # <----- In This Way
|
|
20
|
+
self.fc2 = nn.Linear(128, 10)
|
|
21
|
+
|
|
22
|
+
def forward(self, x):
|
|
23
|
+
x = self.fc1(x)
|
|
24
|
+
x = self.loglu(x)
|
|
25
|
+
x = self.fc2(x)
|
|
26
|
+
return F.softmax(x, dim=1) # Equivalent to 'softmax' activation in final layer
|
|
27
|
+
|
|
28
|
+
# Instantiate the model
|
|
29
|
+
model = MyModel()
|
|
30
|
+
|
|
31
|
+
# Print the model summary (you can use torchsummary for a detailed view)
|
|
32
|
+
from torchsummary import summary
|
|
33
|
+
summary(model, input_size=(1, 784))
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
LogLU_Pytorch is released under the [Apache License 2.0](https://github.com/XenReZ/LogLU-PyTorch/blob/main/LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .loglu_pytorch import LogLU
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import torch.nn as nn
|
|
3
|
+
from torch.autograd import Function
|
|
4
|
+
|
|
5
|
+
class LogLUFunction(Function):
|
|
6
|
+
@staticmethod
|
|
7
|
+
def forward(ctx, input):
|
|
8
|
+
epsilon = 1e-8
|
|
9
|
+
ctx.save_for_backward(input)
|
|
10
|
+
# We clip input to avoid log(0) for x = 1
|
|
11
|
+
input_clipped = torch.clamp(input, max=1.0 - 1e-8)
|
|
12
|
+
output = torch.where(input > 0, input, -torch.log(1 - input_clipped) + epsilon)
|
|
13
|
+
return output
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def backward(ctx, grad_output):
|
|
17
|
+
(input,) = ctx.saved_tensors
|
|
18
|
+
# Avoid division by zero
|
|
19
|
+
input_clipped = torch.clamp(input, max=1.0 - 1e-8)
|
|
20
|
+
grad_input = torch.where(input > 0, torch.ones_like(input), 1.0 / (1.0 - input_clipped))
|
|
21
|
+
return grad_output * grad_input
|
|
22
|
+
|
|
23
|
+
class LogLU(nn.Module):
|
|
24
|
+
def __init__(self):
|
|
25
|
+
super(LogLU, self).__init__()
|
|
26
|
+
|
|
27
|
+
def forward(self, input):
|
|
28
|
+
return LogLUFunction.apply(input)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: loglu-pytorch
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: LogLU Activation Function - PyTorch
|
|
5
|
+
Home-page: https://github.com/XenReZ/LogLU-PyTorch
|
|
6
|
+
Author: Murumuri Naga Poorni
|
|
7
|
+
Author-email: poorni.m0405@gmail.com
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.6
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: torch>=1.6.0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install loglu-pytorch
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Implementation
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import torch
|
|
30
|
+
from loglu_pytorch import LogLU
|
|
31
|
+
|
|
32
|
+
# Define the model
|
|
33
|
+
class MyModel(nn.Module):
|
|
34
|
+
def __init__(self):
|
|
35
|
+
super(MyModel, self).__init__()
|
|
36
|
+
self.fc1 = nn.Linear(784, 128)
|
|
37
|
+
self.loglu = LogLU() # <----- In This Way
|
|
38
|
+
self.fc2 = nn.Linear(128, 10)
|
|
39
|
+
|
|
40
|
+
def forward(self, x):
|
|
41
|
+
x = self.fc1(x)
|
|
42
|
+
x = self.loglu(x)
|
|
43
|
+
x = self.fc2(x)
|
|
44
|
+
return F.softmax(x, dim=1) # Equivalent to 'softmax' activation in final layer
|
|
45
|
+
|
|
46
|
+
# Instantiate the model
|
|
47
|
+
model = MyModel()
|
|
48
|
+
|
|
49
|
+
# Print the model summary (you can use torchsummary for a detailed view)
|
|
50
|
+
from torchsummary import summary
|
|
51
|
+
summary(model, input_size=(1, 784))
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
LogLU_Pytorch is released under the [Apache License 2.0](https://github.com/XenReZ/LogLU-PyTorch/blob/main/LICENSE).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
loglu_pytorch/__init__.py
|
|
4
|
+
loglu_pytorch/loglu_pytorch.py
|
|
5
|
+
loglu_pytorch.egg-info/PKG-INFO
|
|
6
|
+
loglu_pytorch.egg-info/SOURCES.txt
|
|
7
|
+
loglu_pytorch.egg-info/dependency_links.txt
|
|
8
|
+
loglu_pytorch.egg-info/requires.txt
|
|
9
|
+
loglu_pytorch.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
torch>=1.6.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
loglu_pytorch
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name='loglu-pytorch',
|
|
6
|
+
version='0.0.1',
|
|
7
|
+
description='LogLU Activation Function - PyTorch',
|
|
8
|
+
long_description=open('README.md', encoding='utf-8').read(),
|
|
9
|
+
long_description_content_type='text/markdown',
|
|
10
|
+
author= 'Murumuri Naga Poorni ',
|
|
11
|
+
author_email='poorni.m0405@gmail.com',
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
url='https://github.com/XenReZ/LogLU-PyTorch',
|
|
14
|
+
license="Apache-2.0",
|
|
15
|
+
install_requires=[
|
|
16
|
+
"torch>=1.6.0"
|
|
17
|
+
],
|
|
18
|
+
classifiers=[
|
|
19
|
+
'Programming Language :: Python :: 3',
|
|
20
|
+
"License :: OSI Approved :: Apache Software License",
|
|
21
|
+
'Operating System :: OS Independent',
|
|
22
|
+
'Intended Audience :: Developers',
|
|
23
|
+
'Intended Audience :: Science/Research',
|
|
24
|
+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
|
25
|
+
],
|
|
26
|
+
python_requires='>=3.6',
|
|
27
|
+
)
|