deeplotx 0.2.17__tar.gz → 0.2.19__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.
Files changed (25) hide show
  1. {deeplotx-0.2.17 → deeplotx-0.2.19}/PKG-INFO +1 -1
  2. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/nn/base_neural_network.py +2 -3
  3. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/trainer/text_binary_classification_trainer.py +3 -10
  4. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx.egg-info/PKG-INFO +1 -1
  5. {deeplotx-0.2.17 → deeplotx-0.2.19}/pyproject.toml +1 -1
  6. {deeplotx-0.2.17 → deeplotx-0.2.19}/LICENSE +0 -0
  7. {deeplotx-0.2.17 → deeplotx-0.2.19}/README.md +0 -0
  8. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/__init__.py +0 -0
  9. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/encoder/__init__.py +0 -0
  10. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/encoder/bert_encoder.py +0 -0
  11. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/encoder/long_text_encoder.py +0 -0
  12. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/nn/__init__.py +0 -0
  13. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/nn/linear_regression.py +0 -0
  14. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/nn/logistic_regression.py +0 -0
  15. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/nn/softmax_regression.py +0 -0
  16. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/trainer/__init__.py +0 -0
  17. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/trainer/base_trainer.py +0 -0
  18. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/util/__init__.py +0 -0
  19. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/util/hash.py +0 -0
  20. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx/util/read_file.py +0 -0
  21. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx.egg-info/SOURCES.txt +0 -0
  22. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx.egg-info/dependency_links.txt +0 -0
  23. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx.egg-info/requires.txt +0 -0
  24. {deeplotx-0.2.17 → deeplotx-0.2.19}/deeplotx.egg-info/top_level.txt +0 -0
  25. {deeplotx-0.2.17 → deeplotx-0.2.19}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deeplotx
3
- Version: 0.2.17
3
+ Version: 0.2.19
4
4
  Summary: Easy-2-use long text classifier trainers.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -25,9 +25,8 @@ class BaseNeuralNetwork(nn.Module):
25
25
  return l2_reg
26
26
  return _lambda * _l2()
27
27
 
28
- def elastic_net(self, alpha: float = 1e-4, rho: float = 0.5,
29
- lambda_l1: float = 1e-4, lambda_l2: float = 1e-4) -> torch.Tensor:
30
- return alpha * rho * self.l1(_lambda=lambda_l1) + alpha * (1 - rho) * self.l2(_lambda=lambda_l2) / 2.
28
+ def elastic_net(self, alpha: float = 1e-4, rho: float = 0.5) -> torch.Tensor:
29
+ return alpha * rho * self.l1(_lambda=1.) + alpha * (1 - rho) * self.l2(_lambda=1.) / 2.
31
30
 
32
31
  def forward(self, x) -> torch.Tensor: ...
33
32
 
@@ -21,8 +21,7 @@ class TextBinaryClassifierTrainer(BaseTrainer):
21
21
  def train(self, positive_texts: list[str], negative_texts: list[str],
22
22
  num_epochs: int, learning_rate: float = 2e-5, balancing_dataset: bool = True,
23
23
  train_loss_threshold: float = 0.0, valid_loss_threshold: float = 0.0,
24
- alpha: float = 1e-4, rho: float = 0.2,
25
- lambda_l1: float = 1e-4, lambda_l2: float = 1e-4) -> LogisticRegression:
24
+ alpha: float = 1e-4, rho: float = 0.2) -> LogisticRegression:
26
25
  if balancing_dataset:
27
26
  min_length = min(len(positive_texts), len(negative_texts))
28
27
  positive_texts = positive_texts[:min_length]
@@ -52,10 +51,7 @@ class TextBinaryClassifierTrainer(BaseTrainer):
52
51
  total_loss = 0.0
53
52
  for batch_texts, batch_labels in train_loader:
54
53
  outputs = self.model.forward(batch_texts)
55
- loss = loss_function(outputs, batch_labels) + self.model.elastic_net(
56
- alpha=alpha, rho=rho,
57
- lambda_l1=lambda_l1, lambda_l2=lambda_l2
58
- )
54
+ loss = loss_function(outputs, batch_labels) + self.model.elastic_net(alpha=alpha, rho=rho)
59
55
  optimizer.zero_grad()
60
56
  loss.backward()
61
57
  optimizer.step()
@@ -66,10 +62,7 @@ class TextBinaryClassifierTrainer(BaseTrainer):
66
62
  with torch.no_grad():
67
63
  self.model.eval()
68
64
  outputs = self.model.forward(batch_texts)
69
- loss = loss_function(outputs, batch_labels) + self.model.elastic_net(
70
- alpha=alpha, rho=rho,
71
- lambda_l1=lambda_l1, lambda_l2=lambda_l2
72
- )
65
+ loss = loss_function(outputs, batch_labels) + self.model.elastic_net(alpha=alpha, rho=rho)
73
66
  total_valid_loss += loss.item()
74
67
  self.model.train()
75
68
  logger.debug(f"Epoch {epoch + 1}/{num_epochs} | "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deeplotx
3
- Version: 0.2.17
3
+ Version: 0.2.19
4
4
  Summary: Easy-2-use long text classifier trainers.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "deeplotx"
3
- version = "0.2.17"
3
+ version = "0.2.19"
4
4
  description = "Easy-2-use long text classifier trainers."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
File without changes
File without changes
File without changes