modelblock 0.1.0__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.
- modelblock-0.1.0/PKG-INFO +9 -0
- modelblock-0.1.0/modelblock/__init__.py +46 -0
- modelblock-0.1.0/modelblock.egg-info/PKG-INFO +9 -0
- modelblock-0.1.0/modelblock.egg-info/SOURCES.txt +7 -0
- modelblock-0.1.0/modelblock.egg-info/dependency_links.txt +1 -0
- modelblock-0.1.0/modelblock.egg-info/requires.txt +1 -0
- modelblock-0.1.0/modelblock.egg-info/top_level.txt +1 -0
- modelblock-0.1.0/pyproject.toml +17 -0
- modelblock-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modelblock
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ModelBlock - библиотека, созданная для использования готовых слоев и функций.
|
|
5
|
+
Author-email: Research MiniModel <radmirryan@icloud.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: torch>=2.0
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import torch.nn as nn
|
|
3
|
+
def vLSTM(in_channels, width, hidden_size):
|
|
4
|
+
class LinearAttention(nn.Module):
|
|
5
|
+
def __init__(self, in_size, heads):
|
|
6
|
+
super().__init__()
|
|
7
|
+
self.Heads = nn.ModuleList(
|
|
8
|
+
[
|
|
9
|
+
|
|
10
|
+
]
|
|
11
|
+
)
|
|
12
|
+
for _ in range(heads):
|
|
13
|
+
self.Heads.append(nn.Linear(in_size, (in_size//heads)*3, bias=False))
|
|
14
|
+
self.Softmax = nn.Softmax(dim=-1)
|
|
15
|
+
self.RMSNorm = nn.RMSNorm(in_size)
|
|
16
|
+
def forward(self, x):
|
|
17
|
+
out = []
|
|
18
|
+
for H in self.Heads:
|
|
19
|
+
q,k,v = H(x).chunk(3, dim=-1)
|
|
20
|
+
oa = (torch.mean(q, dim=1).unsqueeze(1))@(self.Softmax(self.RMSNorm(k.transpose(-1,-2)@v)))
|
|
21
|
+
out.append(oa.squeeze(1))
|
|
22
|
+
return torch.cat(out, dim=-1)
|
|
23
|
+
class viLSTM(nn.Module):
|
|
24
|
+
def __init__(self, in_channels, width, hidden_size):
|
|
25
|
+
super().__init__()
|
|
26
|
+
self.LSTM = nn.ModuleList(
|
|
27
|
+
[
|
|
28
|
+
|
|
29
|
+
]
|
|
30
|
+
)
|
|
31
|
+
for _ in range(in_channels):
|
|
32
|
+
self.LSTM.append(nn.LSTM(width, hidden_size//in_channels, batch_first=True))
|
|
33
|
+
self.out_proj = nn.Linear((hidden_size//in_channels)*in_channels, hidden_size)
|
|
34
|
+
self.SiLU = nn.SiLU()
|
|
35
|
+
self.Attention = LinearAttention(hidden_size, in_channels)
|
|
36
|
+
self.LOut = nn.Linear(hidden_size, 10)
|
|
37
|
+
def forward(self, x):
|
|
38
|
+
x = torch.chunk(x, x.size(1), dim=1)
|
|
39
|
+
out = []
|
|
40
|
+
for num, LSTM in enumerate(self.LSTM):
|
|
41
|
+
hidden, _ = LSTM(x[num].squeeze(1))
|
|
42
|
+
out.append(hidden)
|
|
43
|
+
x = torch.cat(out, dim=-1)
|
|
44
|
+
x = self.Attention(self.SiLU(self.out_proj(x)))
|
|
45
|
+
return x
|
|
46
|
+
return viLSTM(in_channels, width, hidden_size)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modelblock
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ModelBlock - библиотека, созданная для использования готовых слоев и функций.
|
|
5
|
+
Author-email: Research MiniModel <radmirryan@icloud.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: torch>=2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
torch>=2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
modelblock
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "modelblock"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "ModelBlock - библиотека, созданная для использования готовых слоев и функций."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Research MiniModel", email = "radmirryan@icloud.com"}
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"torch>=2.0",
|
|
17
|
+
]
|