deeplotx 0.2.18__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.
- {deeplotx-0.2.18 → deeplotx-0.2.19}/PKG-INFO +1 -1
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/trainer/text_binary_classification_trainer.py +3 -10
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx.egg-info/PKG-INFO +1 -1
- {deeplotx-0.2.18 → deeplotx-0.2.19}/pyproject.toml +1 -1
- {deeplotx-0.2.18 → deeplotx-0.2.19}/LICENSE +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/README.md +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/__init__.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/encoder/__init__.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/encoder/bert_encoder.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/encoder/long_text_encoder.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/nn/__init__.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/nn/base_neural_network.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/nn/linear_regression.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/nn/logistic_regression.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/nn/softmax_regression.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/trainer/__init__.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/trainer/base_trainer.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/util/__init__.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/util/hash.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx/util/read_file.py +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx.egg-info/SOURCES.txt +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx.egg-info/dependency_links.txt +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx.egg-info/requires.txt +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/deeplotx.egg-info/top_level.txt +0 -0
- {deeplotx-0.2.18 → deeplotx-0.2.19}/setup.cfg +0 -0
@@ -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} | "
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|