deeplotx 0.3.1__py3-none-any.whl → 0.4.1__py3-none-any.whl

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.
deeplotx/nn/__init__.py CHANGED
@@ -1,3 +1,5 @@
1
1
  from .linear_regression import LinearRegression
2
2
  from .logistic_regression import LogisticRegression
3
3
  from .softmax_regression import SoftmaxRegression
4
+ from .recursive_sequential import RecursiveSequential
5
+ from .auto_regression import AutoRegression
@@ -0,0 +1,9 @@
1
+ from deeplotx.nn import RecursiveSequential
2
+
3
+
4
+ class AutoRegression(RecursiveSequential):
5
+ def __init__(self, feature_dim: int, hidden_dim: int | None = None,
6
+ recursive_layers: int = 2, model_name: str | None = None):
7
+ super().__init__(input_dim=feature_dim, output_dim=feature_dim,
8
+ hidden_dim=hidden_dim, recursive_layers=recursive_layers,
9
+ model_name=model_name)
@@ -31,7 +31,7 @@ class BaseNeuralNetwork(nn.Module):
31
31
  return alpha * (rho * self.l1(_lambda=1.) + (1 - rho) * self.l2(_lambda=1.))
32
32
 
33
33
  @abstractmethod
34
- def forward(self, x) -> torch.Tensor: ...
34
+ def forward(self, *args, **kwargs) -> torch.Tensor: ...
35
35
 
36
36
  def predict(self, x) -> torch.Tensor:
37
37
  __train = self.training
@@ -0,0 +1,30 @@
1
+ from typing_extensions import override
2
+
3
+ import torch
4
+ from torch import nn
5
+
6
+ from deeplotx.nn.base_neural_network import BaseNeuralNetwork
7
+ from deeplotx.nn import LinearRegression
8
+
9
+
10
+ class RecursiveSequential(BaseNeuralNetwork):
11
+ def __init__(self, input_dim: int, output_dim: int,
12
+ hidden_dim: int | None = None, recursive_layers: int = 2,
13
+ model_name: str | None = None):
14
+ super().__init__(model_name=model_name)
15
+ if hidden_dim is None:
16
+ hidden_dim = input_dim
17
+ self.lstm = nn.LSTM(input_size=input_dim, hidden_size=hidden_dim,
18
+ num_layers=recursive_layers, batch_first=True,
19
+ bias=True, bidirectional=True)
20
+ self.regressive_head = LinearRegression(input_dim=hidden_dim * 2, output_dim=output_dim)
21
+
22
+ def initial_state(self, batch_size: int = 1) -> tuple[torch.Tensor, torch.Tensor]:
23
+ zeros = torch.zeros(self.lstm.num_layers * 2, batch_size, self.lstm.hidden_size)
24
+ return zeros, zeros
25
+
26
+ @override
27
+ def forward(self, x, state: tuple[torch.Tensor, torch.Tensor]) -> tuple[torch.Tensor, tuple[torch.Tensor, torch.Tensor]]:
28
+ x, (hidden_state, cell_state) = self.lstm(x, state)
29
+ x = self.regressive_head(x[:, -1, :])
30
+ return x, (hidden_state, cell_state)
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deeplotx
3
- Version: 0.3.1
3
+ Version: 0.4.1
4
4
  Summary: Easy-2-use long text classifier trainers.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
7
7
  License-File: LICENSE
8
- Requires-Dist: huggingface-hub[hf-xet]>=0.30.2
8
+ Requires-Dist: hf-xet>=1.0.5
9
9
  Requires-Dist: jupyter>=1.1.1
10
10
  Requires-Dist: numpy>=2.2.5
11
11
  Requires-Dist: python-dotenv>=1.1.0
@@ -3,10 +3,12 @@ deeplotx/encoder/__init__.py,sha256=EM-xrTsHoGaiiFpj-iFAxilMHXC_sQKWYrcq1qCnI3U,
3
3
  deeplotx/encoder/bert_encoder.py,sha256=A-B7Gj94xv6UhvsFTBH7tnkAdGHRhfUZA2QjSnTKB6c,1970
4
4
  deeplotx/encoder/long_text_encoder.py,sha256=V6VxaHW6bMMaZHgU1UZ8n19UfSIV2f2sarWXquiFffQ,3018
5
5
  deeplotx/encoder/longformer_encoder.py,sha256=mZpC5TrGHQo98-ydGtVQQ9KRHgCGl1sRoxcQs7r4SSo,1409
6
- deeplotx/nn/__init__.py,sha256=9gh8rhKqVWtJyvryU_wHPTLEQIorwOBhAQRc0DtNamM,153
7
- deeplotx/nn/base_neural_network.py,sha256=Rkwu58mXXcuusf-59yLX89MywQx-EvTsSXOvlzUptRE,1621
6
+ deeplotx/nn/__init__.py,sha256=oQ-vYXyuaGelfCOs2im_gZXAiiBlCCVXh1uw9yjvRMs,253
7
+ deeplotx/nn/auto_regression.py,sha256=o82C9TREZbhGdj2knSVGTXhjJne0LGEqc7BllByJJWE,449
8
+ deeplotx/nn/base_neural_network.py,sha256=xWKG4FX6Jzdlrfc1HOW1aO9uh0Af3D-dB5Jl7eCxsAk,1635
8
9
  deeplotx/nn/linear_regression.py,sha256=D4mEWVOq6q1Fm2otm57rgZ_E06HJLZBV5k636PprAf4,1520
9
10
  deeplotx/nn/logistic_regression.py,sha256=QAtZp2oyqOW8-1pJWVcahsSM83bzfA68EHObg-wSHHY,463
11
+ deeplotx/nn/recursive_sequential.py,sha256=Nj5B4iPAq7SUCKepextZbHWvGPxHo3w9UXEsEg_nFi4,1352
10
12
  deeplotx/nn/softmax_regression.py,sha256=eUn3mVNlye9ewVdw3McPHZuKbUvvaamsUgFIJMVMgBU,487
11
13
  deeplotx/similarity/__init__.py,sha256=JA1om2zeDcQVS1R04nDMdP6yegxdLJ14WF63pSTL3oo,418
12
14
  deeplotx/similarity/distribution.py,sha256=wQGouuuW531pZeBRKBujXsdsoz4fDnPw7_GW81jwepc,1066
@@ -18,8 +20,8 @@ deeplotx/trainer/text_binary_classification_trainer.py,sha256=5O-5dwVMCj5EDX9gjJ
18
20
  deeplotx/util/__init__.py,sha256=JxqAK_WOOHcYVSTHBT1-WuBwWrPEVDTV3titeVWvNUM,74
19
21
  deeplotx/util/hash.py,sha256=wwsC6kOQvbpuvwKsNQOARd78_wePmW9i3oaUuXRUnpc,352
20
22
  deeplotx/util/read_file.py,sha256=ptzouvEQeeW8KU5BrWNJlXw-vFXVrpS9SkAUxsu6A8A,612
21
- deeplotx-0.3.1.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
22
- deeplotx-0.3.1.dist-info/METADATA,sha256=GzIi1llGFDTLvHDLF3GOQ4G6MafM10M-7IeosZwZlaY,1616
23
- deeplotx-0.3.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
24
- deeplotx-0.3.1.dist-info/top_level.txt,sha256=hKg4pVDXZ-WWxkRfJFczRIll1Sv7VyfKCmzHLXbuh1U,9
25
- deeplotx-0.3.1.dist-info/RECORD,,
23
+ deeplotx-0.4.1.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
24
+ deeplotx-0.4.1.dist-info/METADATA,sha256=0Y3sfxpnTZgN8Edk_AIt8bphP9TQ6UScSn2k0tyThj0,1598
25
+ deeplotx-0.4.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
26
+ deeplotx-0.4.1.dist-info/top_level.txt,sha256=hKg4pVDXZ-WWxkRfJFczRIll1Sv7VyfKCmzHLXbuh1U,9
27
+ deeplotx-0.4.1.dist-info/RECORD,,