Develop#47
Conversation
| delta = np.matmul(chol, z.T).T | ||
| return inputs + delta, cov | ||
|
|
||
| def multivariate_normal_logpdf_batch(self, data_points, means, covariances): |
| new_inputs, new_log_like, new_log_priors | ||
| ) | ||
|
|
||
| # loop through multivariate_normal.logpdf is the same result as batch version |
| ), | ||
| ], | ||
| ) | ||
| def test_vectorized_acceptance_ratio_different_covariances(array_covs, vector_mcmc): |
There was a problem hiding this comment.
"array_covs" -> "array_old_covs"
| regularized_cov = call_args[0][0][2] | ||
| expected_regularized = old_covariance + np.eye(2) * 1e-12 | ||
| np.testing.assert_array_equal(regularized_cov, expected_regularized) | ||
| scipy_old_proposal_logpdf = [] |
There was a problem hiding this comment.
Make a helper function and call it twice w/ old vs. new variables
|
|
||
|
|
||
| def test_local_mcmc_proposal_check_changing_scale_factor(mocker, vector_mcmc): | ||
| mock_local_mcmc_proposal = mocker.patch( |
There was a problem hiding this comment.
Check if you can put the return value here as an arg to patch and put a return value in mocker.Mock(return_value=...)
|
|
||
| def mutate(self, particles, num_samples): | ||
| cov = particles.compute_covariance() if self._compute_cov else None | ||
| if self.mcmc_kernel._mcmc.proposal == self.mcmc_kernel.local_mcmc_proposal: |
There was a problem hiding this comment.
Let's move this to inside VectorMCMCKernel. Otherwise looks great.
Test will need to be associated with VectorMCMCKernel as well (should be simpler)
You can use "git revert " to undo the changes to the mutator. "git log" to find the hash.
| def __call__(self, inputs, scale_factor): | ||
| if inputs.shape[0] < 2: | ||
| raise ValueError("inputs parameter contains less than 2 points") | ||
| orig_inputs = inputs.copy() |
There was a problem hiding this comment.
We need to go back to storing this as a member variable and then using it to compute pairwise kernels relative to last accepted set of particles (not proposed). Details TBD
| raise ValueError(f"Sigma must be postive, got {sigma}") | ||
|
|
||
| gamma = -1 / (2 * sigma**2) | ||
| return pairwise_kernels(inputs.copy(), metric="rbf", gamma=gamma) |
There was a problem hiding this comment.
This needs to be `pairwise_kernels(inputs.copy(), self._orig_inputs, metric='rbf', gamma=gamma).
Sigma may also need to be stored.
| D = inputs.shape[1] | ||
| NU = 2.38 / np.sqrt(D) | ||
|
|
||
| rbfs = self.rbf(inputs, sigma=self.median_distance(inputs)) |
There was a problem hiding this comment.
Does sigma need to be relative to original inputs as well? @peleser
No description provided.