Compare commits
1 Commits
2cb59f5e3f
...
5687479ecd
Author | SHA1 | Date | |
---|---|---|---|
5687479ecd |
@ -2,13 +2,6 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
### [0.7.3](https://gitea.deepak.science:2222/physics/deepdog/compare/0.7.2...0.7.3) (2023-07-27)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* adds utility options and avoids memory leak ([598dad1](https://gitea.deepak.science:2222/physics/deepdog/commit/598dad1e6dc8fc0b7a5b4a90c8e17bf744e8d98c))
|
|
||||||
|
|
||||||
### [0.7.2](https://gitea.deepak.science:2222/physics/deepdog/compare/0.7.1...0.7.2) (2023-07-24)
|
### [0.7.2](https://gitea.deepak.science:2222/physics/deepdog/compare/0.7.1...0.7.2) (2023-07-24)
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ class BayesRunWithSubspaceSimulation:
|
|||||||
ss_default_r_step=0.01,
|
ss_default_r_step=0.01,
|
||||||
ss_default_w_log_step=0.01,
|
ss_default_w_log_step=0.01,
|
||||||
ss_default_upper_w_log_step=4,
|
ss_default_upper_w_log_step=4,
|
||||||
ss_dump_last_generation=False,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
self.dot_inputs = pdme.inputs.inputs_with_frequency_range(
|
self.dot_inputs = pdme.inputs.inputs_with_frequency_range(
|
||||||
dot_positions, frequency_range
|
dot_positions, frequency_range
|
||||||
@ -134,7 +133,6 @@ class BayesRunWithSubspaceSimulation:
|
|||||||
self.ss_default_r_step = ss_default_r_step
|
self.ss_default_r_step = ss_default_r_step
|
||||||
self.ss_default_w_log_step = ss_default_w_log_step
|
self.ss_default_w_log_step = ss_default_w_log_step
|
||||||
self.ss_default_upper_w_log_step = ss_default_upper_w_log_step
|
self.ss_default_upper_w_log_step = ss_default_upper_w_log_step
|
||||||
self.ss_dump_last_generation = ss_dump_last_generation
|
|
||||||
|
|
||||||
self.run_count = run_count
|
self.run_count = run_count
|
||||||
|
|
||||||
@ -174,8 +172,6 @@ class BayesRunWithSubspaceSimulation:
|
|||||||
self.ss_default_r_step,
|
self.ss_default_r_step,
|
||||||
self.ss_default_w_log_step,
|
self.ss_default_w_log_step,
|
||||||
self.ss_default_upper_w_log_step,
|
self.ss_default_upper_w_log_step,
|
||||||
keep_probs_list=False,
|
|
||||||
dump_last_generation_to_file=self.ss_dump_last_generation,
|
|
||||||
)
|
)
|
||||||
results.append(subset_run.execute())
|
results.append(subset_run.execute())
|
||||||
|
|
||||||
@ -200,9 +196,7 @@ class BayesRunWithSubspaceSimulation:
|
|||||||
for (name, result) in zip(self.model_names, results):
|
for (name, result) in zip(self.model_names, results):
|
||||||
if result.over_target_likelihood is None:
|
if result.over_target_likelihood is None:
|
||||||
clamped_likelihood = result.probs_list[-1][0] / CLAMPING_FACTOR
|
clamped_likelihood = result.probs_list[-1][0] / CLAMPING_FACTOR
|
||||||
_logger.warning(
|
_logger.warning(f"got a none result, clamping to {clamped_likelihood}")
|
||||||
f"got a none result, clamping to {clamped_likelihood}"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
clamped_likelihood = result.over_target_likelihood
|
clamped_likelihood = result.over_target_likelihood
|
||||||
likelihoods.append(clamped_likelihood)
|
likelihoods.append(clamped_likelihood)
|
||||||
|
@ -17,7 +17,6 @@ class SubsetSimulationResult:
|
|||||||
over_target_likelihood: Optional[float]
|
over_target_likelihood: Optional[float]
|
||||||
under_target_cost: Optional[float]
|
under_target_cost: Optional[float]
|
||||||
under_target_likelihood: Optional[float]
|
under_target_likelihood: Optional[float]
|
||||||
lowest_likelihood: Optional[float]
|
|
||||||
|
|
||||||
|
|
||||||
class SubsetSimulation:
|
class SubsetSimulation:
|
||||||
@ -38,8 +37,6 @@ class SubsetSimulation:
|
|||||||
default_r_step=0.01,
|
default_r_step=0.01,
|
||||||
default_w_log_step=0.01,
|
default_w_log_step=0.01,
|
||||||
default_upper_w_log_step=4,
|
default_upper_w_log_step=4,
|
||||||
keep_probs_list=True,
|
|
||||||
dump_last_generation_to_file=False,
|
|
||||||
):
|
):
|
||||||
name, model = model_name_pair
|
name, model = model_name_pair
|
||||||
self.model_name = name
|
self.model_name = name
|
||||||
@ -82,9 +79,6 @@ class SubsetSimulation:
|
|||||||
self.target_cost = target_cost
|
self.target_cost = target_cost
|
||||||
_logger.info(f"will stop at target cost {target_cost}")
|
_logger.info(f"will stop at target cost {target_cost}")
|
||||||
|
|
||||||
self.keep_probs_list = keep_probs_list
|
|
||||||
self.dump_last_generations = dump_last_generation_to_file
|
|
||||||
|
|
||||||
def execute(self) -> SubsetSimulationResult:
|
def execute(self) -> SubsetSimulationResult:
|
||||||
|
|
||||||
probs_list = []
|
probs_list = []
|
||||||
@ -122,18 +116,6 @@ class SubsetSimulation:
|
|||||||
for i in range(self.m_max):
|
for i in range(self.m_max):
|
||||||
next_seeds = all_chains[-self.n_c:]
|
next_seeds = all_chains[-self.n_c:]
|
||||||
|
|
||||||
if self.dump_last_generations:
|
|
||||||
_logger.info("writing out csv file")
|
|
||||||
next_dipoles_seed_dipoles = numpy.array([n[1] for n in next_seeds])
|
|
||||||
for n in range(self.model.n):
|
|
||||||
_logger.info(f"{next_dipoles_seed_dipoles[:, n].shape}")
|
|
||||||
numpy.savetxt(
|
|
||||||
f"generation_{self.n_c}_{self.n_s}_{i}_dipole_{n}.csv",
|
|
||||||
next_dipoles_seed_dipoles[:, n],
|
|
||||||
delimiter=",",
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.keep_probs_list:
|
|
||||||
for cost_index, cost_chain in enumerate(all_chains[: -self.n_c]):
|
for cost_index, cost_chain in enumerate(all_chains[: -self.n_c]):
|
||||||
probs_list.append(
|
probs_list.append(
|
||||||
(
|
(
|
||||||
@ -187,13 +169,9 @@ class SubsetSimulation:
|
|||||||
|
|
||||||
shorter_probs_list = []
|
shorter_probs_list = []
|
||||||
for cost_index, cost_chain in enumerate(all_chains):
|
for cost_index, cost_chain in enumerate(all_chains):
|
||||||
if self.keep_probs_list:
|
|
||||||
probs_list.append(
|
probs_list.append(
|
||||||
(
|
(
|
||||||
(
|
((self.n_c * self.n_s - cost_index) / (self.n_c * self.n_s))
|
||||||
(self.n_c * self.n_s - cost_index)
|
|
||||||
/ (self.n_c * self.n_s)
|
|
||||||
)
|
|
||||||
/ (self.n_s ** (i)),
|
/ (self.n_s ** (i)),
|
||||||
cost_chain[0],
|
cost_chain[0],
|
||||||
i + 1,
|
i + 1,
|
||||||
@ -213,14 +191,12 @@ class SubsetSimulation:
|
|||||||
over_target_likelihood=shorter_probs_list[over_index - 1][1],
|
over_target_likelihood=shorter_probs_list[over_index - 1][1],
|
||||||
under_target_cost=shorter_probs_list[over_index][0],
|
under_target_cost=shorter_probs_list[over_index][0],
|
||||||
under_target_likelihood=shorter_probs_list[over_index][1],
|
under_target_likelihood=shorter_probs_list[over_index][1],
|
||||||
lowest_likelihood=shorter_probs_list[-1][1],
|
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# _logger.debug([c[0] for c in all_chains[-n_c:]])
|
# _logger.debug([c[0] for c in all_chains[-n_c:]])
|
||||||
_logger.info(f"doing level {i + 1}")
|
_logger.info(f"doing level {i + 1}")
|
||||||
|
|
||||||
if self.keep_probs_list:
|
|
||||||
for cost_index, cost_chain in enumerate(all_chains):
|
for cost_index, cost_chain in enumerate(all_chains):
|
||||||
probs_list.append(
|
probs_list.append(
|
||||||
(
|
(
|
||||||
@ -239,16 +215,12 @@ class SubsetSimulation:
|
|||||||
# for prob, prob_cost in probs_list:
|
# for prob, prob_cost in probs_list:
|
||||||
# _logger.info(f"\t{prob}: {prob_cost}")
|
# _logger.info(f"\t{prob}: {prob_cost}")
|
||||||
probs_list.sort(key=lambda c: c[0], reverse=True)
|
probs_list.sort(key=lambda c: c[0], reverse=True)
|
||||||
|
|
||||||
min_likelihood = ((1) / (self.n_c * self.n_s)) / (self.n_s ** (self.m_max + 1))
|
|
||||||
|
|
||||||
result = SubsetSimulationResult(
|
result = SubsetSimulationResult(
|
||||||
probs_list=probs_list,
|
probs_list=probs_list,
|
||||||
over_target_cost=None,
|
over_target_cost=None,
|
||||||
over_target_likelihood=None,
|
over_target_likelihood=None,
|
||||||
under_target_cost=None,
|
under_target_cost=None,
|
||||||
under_target_likelihood=None,
|
under_target_likelihood=None,
|
||||||
lowest_likelihood=min_likelihood,
|
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
6
poetry.lock
generated
6
poetry.lock
generated
@ -461,11 +461,11 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest-cov"
|
name = "pytest-cov"
|
||||||
version = "4.1.0"
|
version = "3.0.0"
|
||||||
description = "Pytest plugin for measuring coverage."
|
description = "Pytest plugin for measuring coverage."
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
coverage = {version = ">=5.2.1", extras = ["toml"]}
|
coverage = {version = ">=5.2.1", extras = ["toml"]}
|
||||||
@ -730,7 +730,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-co
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = ">=3.8.1,<3.10"
|
python-versions = ">=3.8.1,<3.10"
|
||||||
content-hash = "111972d04616ce3ddfc9039a0b38c7eb7c4a41f10390139b27e958aedac7e979"
|
content-hash = "0161af7edf18c16819f1ce083ab491c17c9809f2770219725131451b1a16a970"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
black = []
|
black = []
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "deepdog"
|
name = "deepdog"
|
||||||
version = "0.7.3"
|
version = "0.7.2"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Deepak Mallubhotla <dmallubhotla+github@gmail.com>"]
|
authors = ["Deepak Mallubhotla <dmallubhotla+github@gmail.com>"]
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ scipy = "1.10"
|
|||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
pytest = ">=6"
|
pytest = ">=6"
|
||||||
flake8 = "^4.0.1"
|
flake8 = "^4.0.1"
|
||||||
pytest-cov = "^4.1.0"
|
pytest-cov = "^3.0.0"
|
||||||
mypy = "^0.991"
|
mypy = "^0.991"
|
||||||
python-semantic-release = "^7.24.0"
|
python-semantic-release = "^7.24.0"
|
||||||
black = "^22.3.0"
|
black = "^22.3.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user