rbms 0.4.0__tar.gz → 0.4.2__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.
- {rbms-0.4.0 → rbms-0.4.2}/PKG-INFO +1 -1
- {rbms-0.4.0 → rbms-0.4.2}/pyproject.toml +1 -1
- {rbms-0.4.0 → rbms-0.4.2}/rbms/bernoulli_bernoulli/implement.py +3 -3
- {rbms-0.4.0 → rbms-0.4.2}/rbms/dataset/parser.py +9 -2
- {rbms-0.4.0 → rbms-0.4.2}/rbms/potts_bernoulli/classes.py +1 -1
- {rbms-0.4.0 → rbms-0.4.2}/rbms/potts_bernoulli/implement.py +4 -4
- {rbms-0.4.0 → rbms-0.4.2}/rbms/scripts/train_rbm.py +2 -1
- {rbms-0.4.0 → rbms-0.4.2}/rbms/training/pcd.py +11 -1
- {rbms-0.4.0 → rbms-0.4.2}/rbms/training/utils.py +2 -1
- {rbms-0.4.0 → rbms-0.4.2}/.github/workflows/codecov.yaml +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/.github/workflows/test.yaml +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/.github/workflows/whats_new.yaml +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/.gitignore +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/LICENSE +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/MANIFEST.in +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/README.md +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/__init__.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/bernoulli_bernoulli/__init__.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/bernoulli_bernoulli/classes.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/bernoulli_bernoulli/functional.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/classes.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/const.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/custom_fn.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/dataset/__init__.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/dataset/dataset_class.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/dataset/fasta_utils.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/dataset/load_fasta.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/dataset/load_h5.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/dataset/utils.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/io.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/map_model.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/metrics/__init__.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/metrics/aats.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/parser.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/partition_function/ais.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/partition_function/exact.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/plot.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/potts_bernoulli/__init__.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/potts_bernoulli/functional.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/potts_bernoulli/tools.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/potts_bernoulli/utils.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/sampling/gibbs.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/sampling/pt.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/scripts/__init__.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/scripts/entrypoint.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/scripts/pt_sampling.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/rbms/utils.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/conftest.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_energy_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_energy_hiddens_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_energy_visibles_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_gradient_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_init_chains_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_init_parameters_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_sample_hiddens_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_sample_visibles_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/test_bernoulli_utils_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/test_functional_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/test_methods_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/metrics/test_aats.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_compute_energy_hiddens_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_compute_energy_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_compute_energy_visibles_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_compute_gradient_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_init_chains_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_init_parameters_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_sample_hiddens_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_sample_visibles_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/test_functional_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/test_methods_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/test_utils_pbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/test_custom_fn.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/test_utils.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/training/test_pcd.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/use_cases/test_bbrbm.py +0 -0
- {rbms-0.4.0 → rbms-0.4.2}/tests/use_cases/test_pbrbm.py +0 -0
|
@@ -121,9 +121,9 @@ def _compute_gradient(
|
|
|
121
121
|
grad_hbias = h_data_mean - h_gen_mean
|
|
122
122
|
|
|
123
123
|
if lambda_l1 > 0:
|
|
124
|
-
grad_weight_matrix -=
|
|
125
|
-
grad_vbias -=
|
|
126
|
-
grad_hbias -=
|
|
124
|
+
grad_weight_matrix -= lambda_l1 * torch.sign(weight_matrix)
|
|
125
|
+
grad_vbias -= lambda_l1 * torch.sign(vbias)
|
|
126
|
+
grad_hbias -= lambda_l1 * torch.sign(hbias)
|
|
127
127
|
|
|
128
128
|
if lambda_l2 > 0:
|
|
129
129
|
grad_weight_matrix -= 2 * lambda_l2 * weight_matrix
|
|
@@ -8,10 +8,17 @@ def add_args_dataset(parser: argparse.ArgumentParser) -> argparse.ArgumentParser
|
|
|
8
8
|
dataset_args = parser.add_argument_group("Dataset")
|
|
9
9
|
dataset_args.add_argument(
|
|
10
10
|
"-d",
|
|
11
|
-
"--
|
|
11
|
+
"--dataset",
|
|
12
12
|
type=str,
|
|
13
13
|
required=True,
|
|
14
|
-
help="
|
|
14
|
+
help="Path to a data file (type should be .h5 or .fasta)",
|
|
15
|
+
)
|
|
16
|
+
dataset_args.add_argument(
|
|
17
|
+
"--test_dataset",
|
|
18
|
+
type=str,
|
|
19
|
+
required=False,
|
|
20
|
+
default=None,
|
|
21
|
+
help="Path to test dataset file (type should be .h5 or .fasta)",
|
|
15
22
|
)
|
|
16
23
|
dataset_args.add_argument(
|
|
17
24
|
"--subset_labels",
|
|
@@ -179,11 +179,11 @@ def _compute_gradient(
|
|
|
179
179
|
grad_hbias = h_data_mean - h_gen_mean
|
|
180
180
|
|
|
181
181
|
if lambda_l1 > 0:
|
|
182
|
-
grad_weight_matrix -=
|
|
183
|
-
grad_vbias -=
|
|
184
|
-
grad_hbias -=
|
|
182
|
+
grad_weight_matrix -= lambda_l1 * torch.sign(weight_matrix)
|
|
183
|
+
grad_vbias -= lambda_l1 * torch.sign(vbias)
|
|
184
|
+
grad_hbias -= lambda_l1 * torch.sign(hbias)
|
|
185
185
|
|
|
186
|
-
if lambda_l2
|
|
186
|
+
if lambda_l2 > 0:
|
|
187
187
|
grad_weight_matrix -= 2 * lambda_l2 * weight_matrix
|
|
188
188
|
grad_vbias -= 2 * lambda_l2 * vbias
|
|
189
189
|
grad_hbias -= 2 * lambda_l2 * hbias
|
|
@@ -36,7 +36,8 @@ def train_rbm(args: dict):
|
|
|
36
36
|
num_updates=args["num_updates"], n_save=args["n_save"], spacing=args["spacing"]
|
|
37
37
|
)
|
|
38
38
|
train_dataset, test_dataset = load_dataset(
|
|
39
|
-
dataset_name=args["
|
|
39
|
+
dataset_name=args["dataset"],
|
|
40
|
+
test_dataset_name=args["test_dataset"],
|
|
40
41
|
subset_labels=args["subset_labels"],
|
|
41
42
|
use_weights=args["use_weights"],
|
|
42
43
|
alphabet=args["alphabet"],
|
|
@@ -24,6 +24,8 @@ def fit_batch_pcd(
|
|
|
24
24
|
gibbs_steps: int,
|
|
25
25
|
beta: float,
|
|
26
26
|
centered: bool = True,
|
|
27
|
+
lambda_l1: float = 0.0,
|
|
28
|
+
lambda_l2: float = 0.0,
|
|
27
29
|
) -> Tuple[dict[str, Tensor], dict]:
|
|
28
30
|
"""Sample the EBM and compute the gradient.
|
|
29
31
|
|
|
@@ -48,7 +50,13 @@ def fit_batch_pcd(
|
|
|
48
50
|
parallel_chains = params.sample_state(
|
|
49
51
|
chains=parallel_chains, n_steps=gibbs_steps, beta=beta
|
|
50
52
|
)
|
|
51
|
-
params.compute_gradient(
|
|
53
|
+
params.compute_gradient(
|
|
54
|
+
data=curr_batch,
|
|
55
|
+
chains=parallel_chains,
|
|
56
|
+
centered=centered,
|
|
57
|
+
lambda_l1=lambda_l1,
|
|
58
|
+
lambda_l2=lambda_l2,
|
|
59
|
+
)
|
|
52
60
|
logs = {}
|
|
53
61
|
return parallel_chains, logs
|
|
54
62
|
|
|
@@ -123,6 +131,8 @@ def train(
|
|
|
123
131
|
gibbs_steps=args["gibbs_steps"],
|
|
124
132
|
beta=args["beta"],
|
|
125
133
|
centered=not (args["no_center"]),
|
|
134
|
+
lambda_l1=args["L1"],
|
|
135
|
+
lambda_l2=args["L2"],
|
|
126
136
|
)
|
|
127
137
|
optimizer.step()
|
|
128
138
|
if isinstance(params, PBRBM):
|
|
@@ -201,6 +201,7 @@ def initialize_model_archive(
|
|
|
201
201
|
train_dataset: RBMDataset,
|
|
202
202
|
test_dataset: Optional[RBMDataset],
|
|
203
203
|
dtype: torch.dtype,
|
|
204
|
+
flags: List[str] = ["checkpoint"],
|
|
204
205
|
):
|
|
205
206
|
num_visibles = train_dataset.get_num_visibles()
|
|
206
207
|
args = set_args_default(args=args, default_args=default_args)
|
|
@@ -229,7 +230,7 @@ def initialize_model_archive(
|
|
|
229
230
|
learning_rate=args["learning_rate"],
|
|
230
231
|
train_size=args["train_size"],
|
|
231
232
|
log=args["log"],
|
|
232
|
-
flags=
|
|
233
|
+
flags=flags,
|
|
233
234
|
seed=args["seed"],
|
|
234
235
|
L1=args["L1"],
|
|
235
236
|
L2=args["L2"],
|
|
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
|
|
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
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_energy_bbrbm.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_init_chains_bbrbm.py
RENAMED
|
File without changes
|
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/bernoulli_bernoulli/implement/test_sample_hiddens_bbrbm.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_compute_energy_pbrbm.py
RENAMED
|
File without changes
|
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_compute_gradient_pbrbm.py
RENAMED
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_init_chains_pbrbm.py
RENAMED
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_init_parameters_pbrbm.py
RENAMED
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_sample_hiddens_pbrbm.py
RENAMED
|
File without changes
|
{rbms-0.4.0 → rbms-0.4.2}/tests/unit_test/potts_bernoulli/implement/test_sample_visibles_pbrbm.py
RENAMED
|
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
|