Comments (9)
@johnweis0480 has run into some questions here to. Would you have an example to share?
from simpeg.
I was looking at this a while back and saw that the derivative test for the smoothness would fail.
What I initially implemented and suggested last spring was to take the amplitude of the cell gradients of the components of magnetization instead of taking the cell gradient of the amplitude. I believe that the failure is because the derivative is actually matching my initial implementation of this regularization for the smoothness.
Currently, the f_m of the vector smoothness class is doing this:
Instead, I believe is should be doing this
to match the derivative and my initial implementation. By changing to the second, the derivative test will pass.
I do not believe that the format of f_m is well defined as it provides no information on the direction of magnetization. I did compare using cartesian smoothness (top row) to my implementation (bottom row) for MVI with positive results.
from simpeg.
@johnweis0480 What you're suggesting is taking the amplitude of the gradient of the vector components, which is not the same thing as the gradient of the vector amplitudes.
from simpeg.
This is not really related to what @thibaut-kobold is raising, but the result looks good. You might be onto something. I think we should write down the math for this.
@jcapriot Are we not running derivative tests for the regularization? It should brake if @johnweis0480 is right.
from simpeg.
I thought we were, but I'll need to double check. What @johnweis0480 is proposing is a JTV measure on the vector components of the model (Which is a valid thing to do to encourage joint sparsity in the vector components, just not explicitly what I think the VectorAmplitude
regularizer is trying to do.
from simpeg.
Hi all, @jcapriot, you are correct in that @johnweis0480 is suggesting taking the amplitude of the gradient of the vector components, and I support us doing this as I think it makes more sense than looking at spatial derivatives of the amplitude. I will expand…
The current implementation for the objective function is
This has some potential problems. Let’s consider 2 cells right next to each other. Cell 1: [1, 0, 0], cell 2: [0, 1, 0]. If we take the amplitude, and then spatial derivatives, the value of the objective function is 0, so we have reached a minimum. But I don’t think that is the behaviour that we want.
Instead, if we take the amplitude of the vector differences as John has suggested,
then in the example, I pose Cell 1: [1, 0, 0], cell 2: [0, 1, 0], the value of the objective function would be 2, and there would still be progress to be made in the minimization.
So the latter approach would promote smoothly varying vectors, which I think is the behaviour we want.
What makes this a bit subtle is that the derivatives as implemented are not correct, (@johnweis0480: do you have an example that you could share that runs the deriv test?). I don’t see a derivative test in the current SimPEG test suite (I checked in test_vector_amplitudes.py and in test_regularization
The derivate as implemented is first taking gradients
return sp.block_diag([self.cell_gradient] * self.n_comp) @ self.mapping.deriv(
self._delta_m(m)
)
and then amplitudes
return self.f_m_deriv(m).T * (
self.W.T
@ self.W
@ (self.f_m_deriv(m) @ d_m).reshape((-1, self.n_comp), order="F")
).flatten(order="F")
So the direction that the gradients are taking us is more aligned with the approach of taking spatial gradients and then amplitudes.
from simpeg.
I don't mean to imply that @johnweis0480's method is not a good thing, my point is it's not what I believe this class was meant to do, say if you only have reference information on the magnitude of the vector, the approach of taking the amplitude of the gradient of the vector components will not correspond to that information.
from simpeg.
plot_inv_mag_MVI_VectorAmplitude_failed_test.zip
For reference, here is a copy of the file used for the test and a printout of the result.
from simpeg.
simpeg/SimPEG/regularization/vector.py
Line 429 in 211f627
@domfournier : For the first derivative
deriv
, we are calling twicef_m_deriv
. I think the second one is potentially wrong. It should bef_m
(and potentially need then to removed_m
)See for reference the derivative of the base class: https://github.com/simpeg/simpeg/blob/211f627874c46d3a03450b840970b9a10a7fbe4b/SimPEG/regularization/base.py#L502C17-L502C17
Back to @thibaut-kobold original question - After reviewing, the algebra seems to work, but the confusion comes from what's in f_m_deriv
. We are currently mixing the purpose of the derivative of the mapping, and derivatives of the kernel function. We are usually using the mapping to handle wires (grabs a chunk of the model vector for the regularization), and assume that this matches the shape of the kernel function f_m
, which is not the case here. @jcapriot and I managed to re-use the mechanics of the base class and reduce code duplication, but it is less clear. I will submit a PR shortly to make it more explicit.
from simpeg.
Related Issues (20)
- spontaneous_potential
- DOC: Typo in codes comments
- Maintenance: ditch classes/funcs/methods flagged for deprecation
- ENH: Chain rules for nonlinear regularization HOT 1
- ENH: Amplitude lower and upper bounds for `VectorAmplitude`
- BUG: Random failure of dask.em.static test HOT 2
- FDEM 1D simulation PointMagneticFluxDensitySecondary and PointMagneticFieldSecondary calculate same results
- Fixed loop simulation for 1D FDEM and TDEM
- ENH: Add method to expose weights keys in regularizations
- ENH: Mark 'indActive' arguments for deprecation in maps classes
- ENH: Don't accept `weights` as arrays in regularizations HOT 8
- Data Misfit multipliers HOT 5
- Unintended behaviour of `SimPEG.utils.coterminal`? HOT 10
- ENH: Make `get_indices_sphere` to work only for 3D meshes HOT 3
- ENH: Update targets in Makefile
- DOC: Extend instructions on how to run tests locally with `pytest`
- Unassigned parent attributes in Regularizations HOT 2
- ENH: physical properties as functions? HOT 1
- ENH: Add spectral IP to the 2.5D static EM module HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpeg.