rbms 0.3.0__tar.gz → 0.3.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.
Files changed (76) hide show
  1. {rbms-0.3.0 → rbms-0.3.2}/PKG-INFO +1 -1
  2. {rbms-0.3.0 → rbms-0.3.2}/pyproject.toml +1 -1
  3. {rbms-0.3.0 → rbms-0.3.2}/rbms/dataset/__init__.py +2 -2
  4. {rbms-0.3.0 → rbms-0.3.2}/rbms/dataset/dataset_class.py +5 -4
  5. {rbms-0.3.0 → rbms-0.3.2}/rbms/dataset/load_h5.py +0 -8
  6. {rbms-0.3.0 → rbms-0.3.2}/rbms/io.py +3 -1
  7. {rbms-0.3.0 → rbms-0.3.2}/rbms/training/pcd.py +0 -1
  8. {rbms-0.3.0 → rbms-0.3.2}/rbms/training/utils.py +1 -1
  9. {rbms-0.3.0 → rbms-0.3.2}/.github/workflows/codecov.yaml +0 -0
  10. {rbms-0.3.0 → rbms-0.3.2}/.github/workflows/test.yaml +0 -0
  11. {rbms-0.3.0 → rbms-0.3.2}/.github/workflows/whats_new.yaml +0 -0
  12. {rbms-0.3.0 → rbms-0.3.2}/.gitignore +0 -0
  13. {rbms-0.3.0 → rbms-0.3.2}/LICENSE +0 -0
  14. {rbms-0.3.0 → rbms-0.3.2}/MANIFEST.in +0 -0
  15. {rbms-0.3.0 → rbms-0.3.2}/README.md +0 -0
  16. {rbms-0.3.0 → rbms-0.3.2}/rbms/__init__.py +0 -0
  17. {rbms-0.3.0 → rbms-0.3.2}/rbms/bernoulli_bernoulli/__init__.py +0 -0
  18. {rbms-0.3.0 → rbms-0.3.2}/rbms/bernoulli_bernoulli/classes.py +0 -0
  19. {rbms-0.3.0 → rbms-0.3.2}/rbms/bernoulli_bernoulli/functional.py +0 -0
  20. {rbms-0.3.0 → rbms-0.3.2}/rbms/bernoulli_bernoulli/implement.py +0 -0
  21. {rbms-0.3.0 → rbms-0.3.2}/rbms/classes.py +0 -0
  22. {rbms-0.3.0 → rbms-0.3.2}/rbms/const.py +0 -0
  23. {rbms-0.3.0 → rbms-0.3.2}/rbms/custom_fn.py +0 -0
  24. {rbms-0.3.0 → rbms-0.3.2}/rbms/dataset/fasta_utils.py +0 -0
  25. {rbms-0.3.0 → rbms-0.3.2}/rbms/dataset/load_fasta.py +0 -0
  26. {rbms-0.3.0 → rbms-0.3.2}/rbms/dataset/parser.py +0 -0
  27. {rbms-0.3.0 → rbms-0.3.2}/rbms/dataset/utils.py +0 -0
  28. {rbms-0.3.0 → rbms-0.3.2}/rbms/map_model.py +0 -0
  29. {rbms-0.3.0 → rbms-0.3.2}/rbms/metrics/__init__.py +0 -0
  30. {rbms-0.3.0 → rbms-0.3.2}/rbms/metrics/aats.py +0 -0
  31. {rbms-0.3.0 → rbms-0.3.2}/rbms/parser.py +0 -0
  32. {rbms-0.3.0 → rbms-0.3.2}/rbms/partition_function/ais.py +0 -0
  33. {rbms-0.3.0 → rbms-0.3.2}/rbms/partition_function/exact.py +0 -0
  34. {rbms-0.3.0 → rbms-0.3.2}/rbms/plot.py +0 -0
  35. {rbms-0.3.0 → rbms-0.3.2}/rbms/potts_bernoulli/__init__.py +0 -0
  36. {rbms-0.3.0 → rbms-0.3.2}/rbms/potts_bernoulli/classes.py +0 -0
  37. {rbms-0.3.0 → rbms-0.3.2}/rbms/potts_bernoulli/functional.py +0 -0
  38. {rbms-0.3.0 → rbms-0.3.2}/rbms/potts_bernoulli/implement.py +0 -0
  39. {rbms-0.3.0 → rbms-0.3.2}/rbms/potts_bernoulli/tools.py +0 -0
  40. {rbms-0.3.0 → rbms-0.3.2}/rbms/potts_bernoulli/utils.py +0 -0
  41. {rbms-0.3.0 → rbms-0.3.2}/rbms/sampling/gibbs.py +0 -0
  42. {rbms-0.3.0 → rbms-0.3.2}/rbms/sampling/pt.py +0 -0
  43. {rbms-0.3.0 → rbms-0.3.2}/rbms/scripts/__init__.py +0 -0
  44. {rbms-0.3.0 → rbms-0.3.2}/rbms/scripts/entrypoint.py +0 -0
  45. {rbms-0.3.0 → rbms-0.3.2}/rbms/scripts/pt_sampling.py +0 -0
  46. {rbms-0.3.0 → rbms-0.3.2}/rbms/scripts/train_rbm.py +0 -0
  47. {rbms-0.3.0 → rbms-0.3.2}/rbms/utils.py +0 -0
  48. {rbms-0.3.0 → rbms-0.3.2}/tests/conftest.py +0 -0
  49. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_energy_bbrbm.py +0 -0
  50. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_energy_hiddens_bbrbm.py +0 -0
  51. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_energy_visibles_bbrbm.py +0 -0
  52. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_compute_gradient_bbrbm.py +0 -0
  53. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_init_chains_bbrbm.py +0 -0
  54. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_init_parameters_bbrbm.py +0 -0
  55. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_sample_hiddens_bbrbm.py +0 -0
  56. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/implement/test_sample_visibles_bbrbm.py +0 -0
  57. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/test_bernoulli_utils_bbrbm.py +0 -0
  58. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/test_functional_bbrbm.py +0 -0
  59. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/bernoulli_bernoulli/test_methods_bbrbm.py +0 -0
  60. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/metrics/test_aats.py +0 -0
  61. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_compute_energy_hiddens_pbrbm.py +0 -0
  62. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_compute_energy_pbrbm.py +0 -0
  63. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_compute_energy_visibles_pbrbm.py +0 -0
  64. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_compute_gradient_pbrbm.py +0 -0
  65. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_init_chains_pbrbm.py +0 -0
  66. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_init_parameters_pbrbm.py +0 -0
  67. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_sample_hiddens_pbrbm.py +0 -0
  68. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/implement/test_sample_visibles_pbrbm.py +0 -0
  69. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/test_functional_pbrbm.py +0 -0
  70. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/test_methods_pbrbm.py +0 -0
  71. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/potts_bernoulli/test_utils_pbrbm.py +0 -0
  72. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/test_custom_fn.py +0 -0
  73. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/test_utils.py +0 -0
  74. {rbms-0.3.0 → rbms-0.3.2}/tests/unit_test/training/test_pcd.py +0 -0
  75. {rbms-0.3.0 → rbms-0.3.2}/tests/use_cases/test_bbrbm.py +0 -0
  76. {rbms-0.3.0 → rbms-0.3.2}/tests/use_cases/test_pbrbm.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rbms
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Training and analyzing Restricted Boltzmann Machines in PyTorch
5
5
  Project-URL: Homepage, https://github.com/DsysDML/rbms
6
6
  Project-URL: Issues, https://github.com/DsysDML/rbms/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "rbms"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  authors = [
9
9
  {name="Nicolas Béreux", email="nicolas.bereux@gmail.com"},
10
10
  {name="Aurélien Decelle"},
@@ -42,6 +42,8 @@ def load_dataset(
42
42
  alphabet=alphabet,
43
43
  device=device,
44
44
  )
45
+ if not binarize:
46
+ is_binary = False
45
47
  case _:
46
48
  raise ValueError(
47
49
  """
@@ -51,8 +53,6 @@ def load_dataset(
51
53
  - '.fasta'
52
54
  """
53
55
  )
54
- if not binarize:
55
- is_binary = False
56
56
 
57
57
  # Select subset of dataset w.r.t. labels
58
58
  if subset_labels is not None and labels is not None:
@@ -130,13 +130,14 @@ class RBMDataset(Dataset):
130
130
  test_size: Optional[float] = None,
131
131
  ) -> Tuple[Self, Self | None]:
132
132
  num_samples = self.data.shape[0]
133
+ if test_size is None:
134
+ test_size = 1.0 - train_size
135
+
133
136
  # Shuffle dataset
134
137
  permutation_index = rng.permutation(num_samples)
135
138
  train_size = int(train_size * num_samples)
136
- if test_size is not None:
137
- test_size = int(test_size * num_samples)
138
- else:
139
- test_size = num_samples - train_size
139
+ test_size = int(test_size * num_samples)
140
+
140
141
  train_dataset = RBMDataset(
141
142
  data=self.data[permutation_index[:train_size]].cpu().numpy(),
142
143
  labels=self.labels[permutation_index[:train_size]].cpu().numpy(),
@@ -31,14 +31,6 @@ def load_HDF5(
31
31
  f"Ignoring labels since its dimension ({labels.shape[0]}) does not match the number of samples ({dataset.shape[0]})."
32
32
  )
33
33
  labels = None
34
- # From BEG to Potts
35
- if not binarize:
36
- X = (dataset[:, :] + 1) / 2
37
- for i in range(X.shape[0]):
38
- for j in range(X.shape[1]):
39
- if X[i, j] == 0.5:
40
- X[i, j] = 2
41
- return X, labels
42
34
  if "cont" not in str(filename.resolve()):
43
35
  unique_values = np.unique(dataset)
44
36
  is_ising = np.all(unique_values == np.array([-1, 1]))
@@ -133,7 +133,9 @@ def load_model(
133
133
  if "seed" in f["hyperparameters"].keys():
134
134
  hyperparameters["seed"] = int(f["hyperparameters"]["seed"][()])
135
135
  if "train_size" in f["hyperparameters"].keys():
136
- hyperparameters["train_size"] = int(f["hyperparameters"]["train_size"][()])
136
+ hyperparameters["train_size"] = float(
137
+ f["hyperparameters"]["train_size"][()]
138
+ )
137
139
  params = load_params(
138
140
  filename=filename, index=index, device=device, dtype=dtype, map_model=map_model
139
141
  )
@@ -15,7 +15,6 @@ from rbms.potts_bernoulli.utils import ensure_zero_sum_gauge
15
15
  from rbms.training.utils import create_machine, setup_training
16
16
  from rbms.utils import check_file_existence, log_to_csv
17
17
  from rbms.parser import default_args, set_args_default
18
- from rbms.potts_bernoulli.utils import ensure_zero_sum_gauge
19
18
 
20
19
 
21
20
  def fit_batch_pcd(
@@ -137,7 +137,7 @@ def create_machine(
137
137
  hyperparameters["gibbs_steps"] = gibbs_steps
138
138
  hyperparameters["filename"] = str(filename)
139
139
  hyperparameters["learning_rate"] = learning_rate
140
- hyperparameters["train_size"] = True
140
+ hyperparameters["train_size"] = train_size
141
141
  hyperparameters["seed"] = seed
142
142
 
143
143
  save_model(
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