Jekyll2021-05-14T16:51:43+00:00https://chinmayhegde.github.io/feed.xmlChinmay HegdeMy academic homepage.Chinmay HegdeData-free Data Science2020-07-30T00:00:00+00:002020-07-30T00:00:00+00:00https://chinmayhegde.github.io/blog/untrained-priors<p><em>This is Part 3 on my series of posts on physics-informed machine learning; for backstory, see Parts <a href="https://chinmayhegde.github.io/blog/science/">1</a> and <a href="https://chinmayhegde.github.io/blog/solving-pdes/">2</a>.</em></p>
<p>In my <a href="https://chinmayhegde.github.io/blog/solving-pdes/">previous post</a>, I had discussed <a href="https://maziarraissi.github.io/PINNs/">physics-informed neural networks</a>, or PINNs. These are networks that are trained in order to approximate the solution to a (possibly nonlinear) PDE:
\[
\mathcal{N}(u) = f
\]
The idea is to parameterize the solution as \(u = u_\Theta\) (where \(\Theta\) represents the weights of a neural network) and optimize the residual loss:
\[
L(\Theta) = E_\Omega (\mathcal{N}(u_\Theta) - f)^2 .
\]
Here the expectation is taken over points in the domain and/or the boundary. In practice, this can be replaced by a finite sum by sampling points either uniformly or at random. Once this is done, optimization can be performed by standard back-propagation over the network with assorted tips and tricks.</p>
<p>One point that struck me was that the above approach <em>requires no training data</em>. (There are data-dependent variations of PINNs, but that is perhaps a topic for a later post.) From a traditional ML modeling perspective, my first instinct would have been to generate a training dataset of input-output <em>pairs</em> (in this case, a bunch of \((f,u)\) tuples) and try to learn a neural map from forcing function space to solution space. But getting such a dataset would require considerable work up front.</p>
<p>In machine learning, we tend to take for granted the availability of <a href="https://openai.com/blog/better-language-models/">ginormous</a> training datasets. But this is not the case in most scientific or engineering applications — for proof, spend time talking with any physicist or material scientist. Data generation takes time, money, and manpower. But PINNs neatly sidestep this issue; the only information needed is</p>
<ul>
<li>the structure of the PDE (encoded in the loss function) and</li>
<li>a list of collocation/boundary points (also encoded in the loss function).</li>
</ul>
<p>However, reading about PINNs also brought to mind another recent success story in deep learning that also works without any training data: the <a href="https://dmitryulyanov.github.io/deep_image_prior">Deep Image Prior (DIP)</a>.</p>
<hr />
<p>A quick historical digression. <a href="http://www.argmin.net/2017/12/05/kitchen-sinks/">Back when we were kids</a>, there was a lot of fuss about modeling data via <em>priors</em>. Priors represent your belief that the solution to a particular problem obeys a certain structure. That structure is encoded by either a probability distribution or a deterministic low-dimensional manifold, depending on what strikes your fancy. Priors are hand-picked: at the onset, one declares what prior they want (“We will assume a <a href="https://towardsdatascience.com/behind-the-models-beta-dirichlet-and-gem-distributions-526b11a24359">stick-breaking Griffiths-Engel-McClosky distribution</a>…”), and then proceeds to solve the problem of interest.</p>
<p>The pendulum has now shifted the other way. Picking priors by hand has been fully surpassed by using <em>learned</em> priors in all sorts of applications. The idea is to parameterize the prior distribution/manifold of the data somehow, and figure out what parameters make sense for your problem. Yann LeCun makes the fascinating point that assuming <em>a priori</em> structure about your problem is a “<a href="http://www.abigailsee.com/2018/02/21/deep-learning-structure-and-innate-priors.html">necessary evil</a>”: your priors can be (and often are) wrong, and even if they are not, they might become obsolete when a new prior comes along.</p>
<p>What kind of parametric form should the priors take? A decade ago, <a href="https://en.wikipedia.org/wiki/Sparse_dictionary_learning">dictionary learning</a> would have been the answer. Now, one uses deep neural networks, typically with some form of convolutional structure. The results are amazing; look no further than the (synthetic) images sampled from the <a href="https://towardsdatascience.com/gangogh-creating-art-with-gans-8d087d8f74a1">GANGogh prior</a>.</p>
<p>But there is a subtle point to be made here. The belief encoded in neural networks consists of two parts:</p>
<ul>
<li>the <em>data-free</em> part, which is encapsulated via the architecture of the neural network (whether convolutional, recurrent, or whatever).</li>
<li>the <em>data-dependent</em> part, which is encapsulated via training over a given dataset.</li>
</ul>
<p>Both play major (if individually unacknowledged) roles in the predictive power of neural networks. I wish there was a clean mathematical way to separate the contributions of these two components. Far too often, a paper that constructs a <a href="https://arxiv.org/pdf/1605.09782.pdf">very rich and complicated prior</a> using massive amounts of training data is superseded a few years later by a paper that <a href="https://arxiv.org/pdf/1904.13132.pdf">replicates similar behavior while trained over a single training example</a>. The repeated emergence of such instances tells me that there are new, more sensible, more sample-efficient neural network training approaches that are waiting to be discovered.</p>
<hr />
<p>The <a href="https://arxiv.org/abs/1711.10925">DIP</a> is one example of a learned prior modeled via a (deep) neural network. The key is that this learning is done <em>without any training data</em>. Imagine, for example, a deblurring application where the input is a noisy, blurry image \(x\), and the goal is to sharpen it up. Call the clean image \(u\). The classical way to estimate \(u\) would be to solve the linear inverse problem:
\[
x = \mathcal{A}(u)
\]
where \(\mathcal{A}\) models the blurring operator. Since \(\mathcal{A}\) is most likely rank-deficient, one would have to use ridge regression, LASSO, or some other regularization scheme to make the problem well-posed.</p>
<p>The modern approach is to use deep learning. But let us pose the problem in the language of priors. If we assume that \(u = u_\Theta\), i.e., the <em>solution</em> is parameterized via a <em>neural prior</em> parameterized by \(\Theta\), then the weights of that network can be learned by optimizing, over \(\Theta\), the loss function:
\[
L(\Theta) = E_\Omega (\mathcal{A}(u_\Theta) - x)^2
\]
where the expectation is interpreted as the average over all the pixel intensities. (The latent code that is the input to this network is assumed to be fixed and held constant throughout). In essence, we are adjusting the weights of the network to fit the blurry measurements <em>of the particular image that we are interested in</em>.</p>
<p>Pause, for a moment, to observe a few points:</p>
<ul>
<li>that this learning problem is completely <em>data-free</em>: there is no auxiliary training dataset needed whatsoever.</li>
<li>that there is a risk of overfitting if the network is too large (the original DIP paper took care of this via early-stopping, but <a href="https://arxiv.org/abs/1810.03982">later works, such as the Deep Decoder</a> have dealt with this by designing smarter architectures).</li>
<li>that <em>each</em> new denoising problem requires us to retrain a whole new network, possibly from scratch (although perhaps some degree of transfer learning is possible).</li>
<li>the DIP learning problem is strikingly similar to the PINN formulation above.</li>
</ul>
<hr />
<p>There are several unanswered questions here (adding to the <a href="https://chinmayhegde.github.io/blog/solving-pdes/">already long list</a> of questions from last time). There is <a href="https://arxiv.org/pdf/1906.08763.pdf">hope</a> that <a href="https://arxiv.org/abs/1910.14634">some</a> of these can be answered, at least in the context of DIP.</p>
<p>More pertinently to this series of posts: Can the lessons learned by DIP and its descendants be applied to learning physics-informed models? What does this mean for solving PDEs? And is there any hope for theoretical analysis at all here? I will try to explain why I think these have affirmative answers in a future post.</p>Chinmay HegdeThis is Part 3 on my series of posts on physics-informed machine learning; for backstory, see Parts 1 and 2.Neurons meet Newton2020-07-16T00:00:00+00:002020-07-16T00:00:00+00:00https://chinmayhegde.github.io/blog/solving-pdes<p><em>This is Part 2 on my series of posts on physics-informed machine learning; for backstory, see Part <a href="https://chinmayhegde.github.io/blog/science/">1</a>.</em></p>
<p>In Book 1 of the <a href="https://mathshistory.st-andrews.ac.uk/Extras/Newton_Principia/">Principia Mathematica</a>, Newton puts forth his celebrated Laws of Motion. He uses them to provide qualitative explanations to a staggering number of measured phenomena (including the inverse square behavior of gravity, Kepler’s laws of planetary motion, the basis of tides, the precession of equinoxes, and the orbits of comets, among others). In particular, the Second Law of Motion assumes the form of an <em>ordinary differential equation</em> (ODE):</p>
<p>\[
\frac{d^2 x(t)}{dt^2} = \frac{1}{m} F(t)
\]</p>
<p>where \(x(t)\) is the instantaneous position of a body of mass \(m\) and \(F(t)\) is the force acting on it.</p>
<p>Despite the tag “ordinary”, ODEs can be simple to write down but become quickly complex. For the Second Law, analytical solutions for \(x(t)\) are available only if the force function is well-behaved. If not, one has to resort to numerical methods that involve appropriate discretization of the differential operators involved in the ODE. Natural questions start to emerge here: how does one do the discretization? How fine should we discretize? Does the approximation error induced by the discretization converge to zero, and if so, at what rate?</p>
<p>All these matters are doubly/triply exacerbated when we start talking about <em>partial</em> differential equations (PDEs). Here, the variable is an unknown multivariate function \(u\). Let us be concrete and limit ourselves to the variables being space and time, so that \(u = u(x,t)\). The equation to be solved now involves an arbitrary operator with partial derivatives:</p>
<p>\[
\mathcal{N}(u) = f
\]</p>
<p>where \(f = f(x,t)\) is called the <em>forcing</em> function. Let us assume this is deterministically fixed. If not, then the above equation is called a <em>stochastic</em> PDE.</p>
<p>Unlike ODEs, there is no general understanding of when (or whether) a generic PDE even admits a solution. The celebrated <a href="https://en.wikipedia.org/wiki/Navier%E2%80%93Stokes_existence_and_smoothness">Navier-Stokes</a> equation is an example of a system of PDEs whose theoretical understanding is incomplete:</p>
<p>\[
\frac{\partial u}{\partial t} + (u \cdot \Delta - \nu) u + \frac{1}{\rho} \nabla p = f .
\]</p>
<p>where \( \Delta, \nabla \) represent the Laplacian and the gradient respectively. Things have already become hairy, since the above PDE is <em>nonlinear</em> in its unknown variables. So even a heuristic application of numerical methods may not always work well.</p>
<hr />
<p>Let us now briefly set aside the 300+ year history of solving ODEs/PDEs, and instead imagine a completely different approach. Suppose we <em>parameterize</em> the solution using a <em>deep feedforward neural network.</em> In concrete terms, if \(\Theta\) represents the weight and biases of the network, we write down:</p>
<p>\[
u = u_\Theta(x,t)
\]</p>
<p>and formulate the <em>physics-informed</em> loss function:</p>
<p>\[
L(\Theta) = \sum_{(x_i,t_i) \in S_{\text{int}}}^{} (\mathcal{N} (u_\Theta(x_i, t_i)) - f(x_i, t_i) )^2 + \lambda \sum_{(x_j,t_j) \in S_{\text{bdry}}}^{} (u_\Theta(x_i, t_i) - u_0(x_i, t_i))^2
\]</p>
<p>where \(S_{\text{int}}\) denotes a set of collocation points in the interior and \(S_{\text{bdry}}\) denotes a set of boundary points. The weights can now be learned using standard neural training paraphernalia (autodiff, ADAM, batch normalization, etc). Once the weights are learned, the solution can be reconstructed by evaluating \(u_\Theta(x,t)\) over the entire domain.</p>
<p>Variants of this idea seem to have been floating around since (at least) the <a href="http://www.cs.uoi.gr/~lagaris/papers/TNN-LLF.pdf">1990s</a>. As with most ideas based on neural networks, they didn’t gain steam until much later, starting with an <a href="https://arxiv.org/abs/1711.10561">inspirational</a> <a href="https://arxiv.org/abs/1711.10566">series</a> of <a href="https://www.sciencedirect.com/science/article/pii/S0021999118307125">papers</a> from George Karniadakis and co-authors starting from 2017. They call this <em>PINN</em>, short for <em>Physics-Informed Neural Networks</em>.</p>
<p>The simplicity of the above formulation lends itself to a number of extensions. Among many others:</p>
<ul>
<li>Additional training data (in the form of, say, values of the solution at a pre-identified set of collocation points) can be incorporated by throwing in new loss terms.</li>
<li>The PDE operator \(\mathcal{N}\) itself can involve unknown parameters (say, \(\lambda\)) in which case both \(\Theta, \lambda\) are jointly estimated.</li>
<li>Extension to <a href="https://arxiv.org/pdf/1910.09098.pdf">stochastic PDEs</a> can be achieved by taking the expectation of the physics-informed loss function over appropriately defined probability measures.</li>
</ul>
<p>In this manner, the considerable advances in neural network learning over the last five years (and the democratization of software tools for learning neural nets, including powerful packages like TensorFlow and PyTorch) can now directly be ported to the field of numerical PDE analysis. The results are <a href="https://maziarraissi.github.io/PINNs/">very impressive</a>.</p>
<p>It leads me to wonder more broadly: what other fields in science are waiting for such a clean connection to be made to neural nets?</p>
<hr />
<p>However, despite all these exciting advances, there are several open questions here.</p>
<p>First, why should the above neural approach to solving PDEs be any better than a standard numerical method? The issues of discretization, solution uniqueness, and convergence continue to persist (note that the standard PINN formulation does <em>not</em> explicitly discretize the domain, but there is an implicit level of discretization achieved by how the collocation points in \(S_{\text{int}}\) are distributed).</p>
<p>Second, how do we know that we have obtained the right solution? One answer is to do a post hoc check: if we see low/zero training loss, then we are good. But <em>a priori</em> there do not seem to be any guarantees on how to achieve low loss, and I find this a bit unsatisfying.</p>
<p>Third, does the solution given by the PINN generalize to <em>all</em> points in the domain? In other words, how can we control the generalization error? See <a href="https://arxiv.org/pdf/2004.01806.pdf">here</a> and <a href="https://arxiv.org/abs/2007.01138">here</a> for interesting generalization upper bounds. But I am not entirely sure how powerful these are. In any case getting non-vacuous bounds on neural net generalization is a challenging problem in itself.</p>
<p>Fourth, somewhat unfortunately we have to learn a <em>different</em> network from scratch for each new set of boundary conditions and/or PDE system.</p>
<p>In a later post, I will describe potential avenues towards addressing some of these questions.</p>Chinmay HegdeThis is Part 2 on my series of posts on physics-informed machine learning; for backstory, see Part 1.AI and Scientific Discovery2020-07-08T00:00:00+00:002020-07-08T00:00:00+00:00https://chinmayhegde.github.io/blog/science<p>What might have happened if Isaac Newton had PyTorch at his disposal?</p>
<p>We are now nearing the end of Month 4 of the You-Know-What, and in the absence of commuting I suddenly found time to catch up on the (numerous) unread books sitting on my Kindle. One of them was <em><a href="https://en.wikipedia.org/wiki/Quicksilver_(novel)">Quicksilver</a></em> by fellow ex-<a href="https://en.wikipedia.org/wiki/Neal_Stephenson">Ames</a> resident Neal Stephenson. The book is (typically) dense and packed with information, but there is an interesting connection to the current capital-P Pandemic: the first part is set during the <a href="https://en.wikipedia.org/wiki/Great_Plague_of_London">Plague of 1666</a> which forced Newton to spend the year in the countryside watching apples fall out of trees.</p>
<p>In the preface of the <a href="https://mathshistory.st-andrews.ac.uk/Extras/Newton_Principia/">Principia Mathematica</a>, Newton defines the primary guiding principle of the scientific method as “[observing] the phenomena of motions to investigate the forces of nature, and then from these forces to demonstrate the other phenomena”.</p>
<p>IANA scientific historian, but it is interesting to interpret this in the light of today’s AI revolution. His words resonate with the principle of <em>generalization</em> in machine learning, where an abstract model is constructed (using numerical and/or other tools) from a given set of observations, and then deployed in new, unseen contexts. This forms the bedrock of a lot of ML (both theoretical and applied) research. Unfortunately, it has become clear that the community faces <a href="https://arxiv.org/abs/1611.03530">more questions than answers</a>.</p>
<p>Suppose we take for granted the (plausible) ability of modern AI to deduce patterns from observations, and to apply these deductions to new unseen contexts. Could a properly constructed AI system be used to discover new scientific laws? Or design new engineering systems? Or even just accelerate the current cycle of scientific progress, much of which relies on expensive and time-consuming trial-and-error?</p>
<p>I spent a large portion of the last eighteen months leading a <a href="https://www.darpa.mil/program/artificial-intelligence-research-associate">DARPA AIRA project</a> on the interplay between AI and scientific discovery. The goal of AIRA was to explore the possibility of AI being a co-equal partner to human ingenuity in the loop of scientific discovery. Kudos to the DARPA team for shepherding an inspirational program with an intellectually diverse collection of performers.</p>
<p>In the coming weeks, I will describe some key recent advances in this area. I will focus on <a href="https://arxiv.org/pdf/1708.00588.pdf">some</a> <a href="https://arxiv.org/pdf/2006.06813.pdf">of</a> <a href="https://arxiv.org/pdf/1710.06532.pdf">the</a> <a href="">work</a> developed during the AIRA program, although it should be clear that this is only the tip of a very large iceberg. Somewhere in this list is also our <a href="https://arxiv.org/pdf/1906.01626">recent</a> <a href="https://chinmayhegde.github.io/assets/papers/aaai20-invnet.pdf">work</a> on GAN-like models for accelerating PDE solvers and materials characterization.</p>Chinmay HegdeWhat might have happened if Isaac Newton had PyTorch at his disposal?Hello World!2020-05-31T00:00:00+00:002020-05-31T00:00:00+00:00https://chinmayhegde.github.io/blog/first<p>Trying out the Minimal Mistakes theme for my NYU website.</p>
<p>Test Latex:</p>
<p>\[
y = \Phi x
\]</p>
<p>Check out the <a href="https://wp.nyu.edu/chinmay/">Wordpress site</a> for more info.</p>Chinmay HegdeTrying out the Minimal Mistakes theme for my NYU website.