Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Fixes and improves logging for inference module
Browse files Browse the repository at this point in the history
  • Loading branch information
tingiskhan committed Jun 2, 2021
1 parent 0c55901 commit 3a32086
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyfilter/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.17.7"
__version__ = "0.17.8"
9 changes: 4 additions & 5 deletions pyfilter/inference/batch/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ def fit(self, y: torch.Tensor, logging=None, **kwargs) -> AlgorithmState:
state.converged = self.is_converged(old_loss, state.loss)
state.optimizer.zero_grad()

return state

except Exception as e:
logging.close()
raise e

logging.close()

return state
finally:
logging.close()
8 changes: 5 additions & 3 deletions pyfilter/inference/batch/mcmc/pmmh.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def fit(self, y: torch.Tensor, logging=None, **kwargs):

state.update(params_to_tensor(self._filter.ssm, constrained=True))
logging.do_log(i, state)

return state

except Exception as e:
logging.close()
raise e

return state
finally:
logging.close()
9 changes: 4 additions & 5 deletions pyfilter/inference/sequential/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ def fit(self, y, logging=None, **kwargs) -> FilteringAlgorithmState:
state = self.update(yt, state)
logging.do_log(i, state)

return state

except Exception as e:
logging.close()
raise e

logging.close()

return state
finally:
logging.close()


class SequentialParticleAlgorithm(SequentialFilteringAlgorithm, ABC):
Expand Down

0 comments on commit 3a32086

Please sign in to comment.