{'fraction_non_alphanumeric': 0.022886443221610805, 'fraction_numerical': 0.009129564782391195, 'mean_word_length': 4.868150684931507, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Weakly-Supervised Deep Learning of Heat Transport via Physics Informed Loss

In typical machine learning tasks and applications, it is necessary to obtain or create large labeled datasets in order to to achieve high performance. Unfortunately, large labeled datasets are not always available and can be expensive to source, creating a bottleneck towards more widely applicable machine learning. The paradigm of weak supervision offers an alternative that allows for integration of domain-specific knowledge by enforcing constraints that a correct solution to the learning problem will obey over the output space. In this work, we explore the application of this paradigm to 2-D physical systems governed by non-linear differential equations. We demonstrate that knowledge of the partial differential equations governing a system can be encoded into the loss function of a neural network via an appropriately chosen convolutional kernel. We demonstrate this by showing that the steady-state solution to the 2-D heat equation can be learned directly from initial conditions by a convolutional neural network, in the absence of labeled training data. We also extend recent work in the progressive growing of fully convolutional networks to achieve high accuracy (<1.5% error) at multiple scales of the heat-flow problem, including at the very large scale (1024x1024). Finally, we demonstrate that this method can be used to speed up exact calculation of the solution to the differential equations via finite difference.


Introduction
Most of the dramatic successes of machine learning in the 21st century have utilized very large datasets in order to achieve their performance 1 . In supervised tasks, including in image recognition [RDS + 15], speech recognition [GrMH13] and machine translation [SVL14], large datasets had to be assembled before neural network architectures particularly suited to these applications could emerge and achieve human-level performance on these tasks. In reinforcement learning [SB98], successful agents, including Go champion AlphaZero [SSS + 17] and Atari-playing DQNs [MKS + 15], operate in easilysimulated toy environments that enable the collection of large quantities of data in the form of observations and interactions with the environment.
The paradigm of weakly-supervised learning [RBVR17] seeks to reduce the data requirements by encoding our prior knowledge into machine learning systems. In this work, we explore the ability to encode our prior knowledge about the physical world into an appropriate loss function to guide deep learning.
We are interested in inference within physical environments whose rules can be defined by differential equations. We focus on the case of 2-dimensional heat transport [Fou07], whose dynamics are defined by a secondorder differential equation. We seek to encode the dynamics of the system into a loss function, such that the learning algorithm can learn to produce correct solutions to the future state of the system without having to observe any labeled data. We develop a convolutional kernel which encodes the constraint that must be satisfied by any steady-state solution to the heat flow problem, and we use this kernel to determine the loss function. By seeking to minimize this loss, the network learns to satisfy the differential equations of heat transport, effectively learning the underlying physics of the system despite never explicitly being shown the outcomes for any given initial condition. While the physical system examined throughout this paper is 2-D heat transport, the methods developed are extremely general and can be applied to any system defined by partial differential equations and theoretically capable of being solved by the finite difference method (even if it is not practical to do so). This points us towards to possibility of encoding the equations we have discovered, which govern many physical environments of interest to us, into neural networks. It would be quite convenient if we could encode this information directly in our learning agents, such that they could benefit from the knowledge we've already gained about how the world works.

Related Work
This work exists at the intersection of two different lines of research pursued by disparate research communities. The first line of work, weakly supervised machine learning, is pursued primarily within the machine learning community and seeks to reduce the data requirements of machine learning applications. It aims to do so by incorporating some form of prior knowledge, either to augment existing data, or to create context-aware learning algorithms that are able to achieve high performance with less data. The second line of work involves the use of physics informed machine learning for modeling physical systems, and is pursued primarily within the mathematical physics and engineering communities.
[RBVR17] defines weak supervision as a unified approach to incorporating various types of weak signal into the machine learning pipeline. These forms of weak signal include crowdsourced [WfWB + 09], noisy [NDRT13], or sparse labels (as in active and semisupervised learning) [ZG09,Set12]. Additionally, weak signal can be specified in the form of constraints and invariances over the output space (often provided by domain experts), or in terms of weak or biased classifiers (as in transfer learning or boosting). Although these techniques and approaches are disparate, they are unified by their aim to alleviate the need for vast quantities of data to solve machine learning problems.
The present work is most closely connected to work that aims to incorporate domain-specific prior knowledge in the form of constraints over the output space. The nearest cousin to this work is [SE16], in which physical constraints are specified over the output trajectories that must be satisfied by solutions for problems in motiontracking, enabling it to be done in a label-free way. We extend this work to the broader domain of prediction in physical systems governed by non-linear PDEs. In natural language processing, [LJK13,AZ11] seek to se-mantically parse statements or questions (i.e. convert them into their logical forms) with weak supervision signals (e.g. in the form of responses to queries rather than the meaning of the query itself). Recent works [CGCR10,GPLL17] in this area apply constraints on the output space to provide weak signal to the semantic parser.
The second line of research that the present work extends leverages machine learning techniques to either discover the underlying dynamics of a system governed by unknown PDEs, or to build faster and more accurate differential equation solvers. [RK17,Rai18] use traditional machine learning techniques and deep learning techniques respectively for both predicting the future of time-dependent dynamical systems and for discovering their underlying equations. [FGP17] uses conditional generative models to find the equilibrium solution to a number of transport problems faster than traditional iterative methods. [HJE17,SS17] leverage deep learning techniques to approximately solve partial differential equations is high-dimensional spaces, where traditional iterative techniques break down. All of these techniques use large quantities of data in a supervised way, unlike the present work.

Heat-Transport
In 2-D heat transport, we consider a flat square plate made of some thermally conductive material that is insulated along its edges. Heat is applied to the plate in some way, and our goal is to model the way thermal energy moves through the plate. The initial condition is given by T (x, y, 0), and we wish to determine T (x, y, t), the temperature field on the plate at time t. In our model we assume that non-zero elements of T (x, y, 0) represent an applied heat i.e. heat applied the point (x, y) on the grid for the duration of the transport experiment. Under ideal assumptions, it can be shown that T satisfies the two dimensional heat equation [Fou07] where c > 0 is a constant for the thermal conductivity of the plate. We can also study solutions that do not vary with time, known as the steady-state solutions to the system ∂T ∂t = 0 In this case we get the Laplace Equation: Solutions to the Laplace equation are known as harmonic functions, and the particular solution to the steady-state heat transport problem is the harmonic function which also satisfies the initial condition of the system. When heat is applied only to the boundary of the plate, as it is in the cases we study in this paper, equation 1 is known as the Dirichlet boundary problem [Dir50].

Finite Difference
Finite difference is an iterative method used to compute exact solutions to partial differential equations via a discretization of the equations, and an update rule that is defined by the equations. To solve the 2D steady state heat equation using finite difference, we need to discretize ∇ 2 T =0. Considering evenly spaced 2-D grid, the discretized form of ∇ 2 T =0 for node (i,j) would be: The nodal relation expressed in the above equation is solved iteratively by applying the rule above at each node (point in the grid) until convergence.

Approach
The aim of this work is to train a fully convolutional neural network to directly infer the solution to the Laplace equation (1) when given the initial condition as input (i.e. train the neural network to be a solver for the Dirichlet boundary problem [Dir50]). We accomplish this without ever seeing solutions to the boundary problem by encoding the differential equations into a physics-informed loss function, described in section 4.3, which motivates the network to find the solution without the use of supervision in the form of data. The architecture of the network is described in section 4.2.
Each instantiation of the Dirichlet boundary problem is given to the neural network in the form of a n × n image matrix representing a thermally conductive plate, with the value in each entry representing the temperature applied to each point on the plate. In this work, we only apply heat to the boundary of the plate, so the only non-zero entries in the input are at the boundaries. Zero values in the input represent points on the plate with no temperature applied, meaning they can change over the course of time, as they are influenced by the temperature at neighboring points on the thermally conductive plate.
The desired output is also an n × n image matrix representing the temperature values at each point on the plate after the heat flow process has converged to an equilibrium temperature distribution.
The network is trained with randomly initialized boundary conditions. Because the network is never provided solutions to the boundary value problem, we can generate new data points on the fly virtually free of cost by creating new n × n matrices with the boundaries filled in by random values. In this work, we choose four random temperatures uniformly between 0 and 100 and set the temperatures of the top, right, left and bottom of the plate to be constant, and equal to each of the random temperatures correspondingly. An example input and output are shown in Figure 1.
In section 4.4, we describe how the output image is downsampled repeatedly and multiscale loss function is computed. Downsampling and training over multiple losses in this fashion dramatically speeds up training and improves the quality of the output images.

Network Architecture
The architecture of the network is a fully convolutional encoder-decoder network adapted from the U-Net architecture [RFB15]. The fully convolutional network is comprised of several encoding convolutional layers that decrease the image size to that of the latent space (in our case, 512 × 1 × 1). The decoding layers consist of transposed convolutions on the output of the previous layer concatenated with the corresponding encoding layer. The concatenations amount to skip connections from each encoding layer to its corresponding output layer. Ultimately, an image of the original input size is recovered, and the aim is for the final image to represent the equilibrium temperatures on the plate. The architecture is shown in Figure 1. Each encoding layer is connected to its corresponding decoder layer via a skip connection. The network is fully convolutional, and thus can be scaled to arbitrary size by adding layer. The input is the initial condition, and the output is the equilibrium condition.
The motivation for using a fully convolutional architecture is to flexibly use the same architecture to solve problems at multiple scales. The purpose of the skip connections are to pass the boundary values of the input to the output layers, so the network is not forced to memorize the structure of the input in its bottleneck layers. The architecture mirrors that of [FGP17], in which this network architecture was used to solve a variety of differential equations in a supervised way.

Physics Informed Kernel
The equilibrium condition defined in Equation (1) can be encoded in a simple rule: the temperature at each point on the plate (that is not initially driven by a heat source) should be the average of its neighbors. In fact, it is by iteration of this rule that the finite-difference method for solving partial differential equations typically solves this problem, as was shown in equation 2.
Examining this condition, we find that it can easily be encoded into a 3x3 convolutional kernel as follows: This kernel is run convolutionally across an image, and the outputs flattened and normed, to calculate the loss of the output: By minimizing this loss, the neural networks learns to identify harmonic functions that form solutions to the given Dirichlet boundary problem specified by the initial condition, since the boundary of the output is fixed to be equal to the initial condition Although this kernel can easily be identified by the structure of the heat equations, we show in section 5.3 that this kernel can easily be learned if labels are provided (in the form of correct solutions to the heat flow equations). Although this kernel is easy derive and justify for the case of heat transport, in principle a similar kernel can be found for any system whose dynamics are defined by partial differential equations. In general, given an update rule for finite difference equations, it is easy to encode this rule into a convolutional kernel.

Progressive Downsampling for Growing Loss
The network can have difficulty learning to output the heat distribution that minimizes the loss function for very large input sizes, in part because outputting a constant on the entire field has a loss of 0, if we ignore the boundary. As the image size grows larger, the boundary values becomes a proportionally smaller fraction of the total image, reducing the proportion of loss contributed by outputting incorrect values for the points near the border of the plate. Thus, the network is less able to accurately fill in correct temperatures, especially towards the center of the image, instead opting to output constant temperature fields.
In order to solve this problem, we adopt a modified version of the strategy of progressively growing the output of the network to the final problem size, first introduced in [KALL17]. In our case, instead of progressively adding decoding layers, as in [KALL17], we compute the loss on several downsampled versions of the output image, and weight their contribution to the overall loss according to a weight vector where each λ i is the weight of the loss on the i th downsampled version of the output. The loss for each individual downsampled output is computed in the same way as described in section 4.3, but the weight vector can slowly be tuned from λ = [0, 0, . . . , 1] to λ = [1, . . . , 0, 0]. Early in training, this motivates the network to output images which satisfy the overall higher level structure of the desired output. We slowly increase the weights associated with getting the finer grained details of the output correct.
In our training, we choose a downsample factor of 4, until the images are of size 32 × 32, the scale at which training works well even without a progressively downsampled loss function.
The general framework is shown in Figure 2  This framework can be viewed as a special case of curriculum learning [BLCW09], where the difficulty of the curriculum scales as the weights in λ become more concentrated on the largest scale. This provides a flexible framework by which output size can be used to craft a curriculum, and we suspect that it can be widely applied to multiscale problems in image generation, as well as other domains.

Solving the Boundary Value Problem
Test results are shown for inputs of size 256×256 in Figure 3. During training of this experiment, the network was never shown the correct answer to the boundary value problem, but only ever given random initializations and trained to minimize the loss in equation ( 3). In the figure a number of images are shown containing the boundary value problem specified, the true equilibrium temperatures given that boundary condition (solved to high precision via finite difference), and the output of the neural network after training.
The network has sixteen hidden layers (8 encoding, 8 decoding) and has been trained for 128 epochs using a progressive downsampling strategy to grow the loss function as described in section 4.4. The optimization is done with an Adam optimizer [KB14]. Despite never seeing a correct desired output for the boundary value problem, the average per-pixel output error is only 1.39% with a standard deviation of 1.24%. The test examples are unseen during training, and are generated randomly according to the same procedure as during training.

Solving at Very Large Scale
As described in section 4.4, the network has difficulty learning the correct solution at larger scales, because outputting constant values along the entire image becomes a viable strategy to achieve a low loss. However, by using the strategy of progressive downsampling to grow the loss function, the network is able to easily find solutions to the boundary value problem, achieving good results in just a few epochs. The basic method, without progressive downsampling, fails entirely to learn. The third column shows the output of the deep neural network that is trained to minimize 3. These results are for inputs of size 1024×1024

Learning the Convolutional Kernel
The kernel defined in section 4.3, copied below, can be easily determined by inspection of the differential equations defining heat transport (i.e. the form of the Laplace equation (1)).
This may not be the case in general, however, as the local invariants satisfied by a system that obeys a certain set of differential equations may not be readily apparent. Furthermore, for some systems the differential equations governing their evolution may not even be known.
In this experiment, we show that for the case of heat transport, this convolutional kernel can be learned to high-precision as long as we have data. This data should consist of the equilibrium conditions of heat transport (i.e. solutions to the Dirichlet problem defined in equation (1) for various initial conditions -the initial conditions themselves are not required).
We generate data on the fly by randomizing the initial condition and running an iterative finite-difference solver to solve. The data generated is 8×8 images which are converged to high precision. We then run a learnable convolutional kernel across the data and sum the absolute value of the outputs. The convolutional kernel is optimized via Adam, and its parameters seek to minimize the absolute value of the outputs of the convolution. After several thousand iterations on randomly generated data points, this procedure learns the following kernel: 0 0.0545 0.0001 0.0545 -0.2181 0.0545 0 0.0547 0 This is almost exactly a scaled version of the original kernel, which encodes the same rule: that each point on the eqilibrium heat distribution should be the average of the temperature of its four neighboring points. This shows that if we have data which describes converged conditions of the phenomenon of interest, we can learn the local rules that define equilibrium condition directly from this data. In principle, this can be used to discover differential equations governing the dynamics for unknown systems, although more work is needed to show that this can be done with more complex systems than heat-transport (e.g. systems with higher-order nonlinearities).

Application: Speeding Up Finite Difference Calculation
The Finite Difference method described in Section 3.2 can be slow to converge to the correct solution [Rem12], and is particularly sensitive to the initial condition given to the algorithm. Thus, we can use a trained neural network to provide an output that is approximately correct (within 1.5% error), and this answer can be used as an initial condition to be refined by the finite difference method. The finite difference method can then compute the exact solution to a desired level of precision. Once trained, the forward pass through a neural network is fast, accounting for a negligible fraction of the time finite-difference algorithm takes to converge. Our results demonstrate that this "warm-start" approach for solving the heat equations converges much faster than a constant initialization -i.e. one in which all pixels not on the border of the image are set to the average of pixels on the border. In Figure 5, we compare the errors from ground truth at each iteration of finite difference for the two different solvers, one that is given the output of the trained neural net as a warm start and one that is not. We compute "ground truth" by running finite difference to a very high level of precision relative to both initializations of the algorithm.
A more appropriate comparison for this method would be to hierarchical finite difference solvers, which are more often used in practice, but it is hard to make a direct comparison of the error between a hierarchical solver and our proposed method, as the hierarchical solver does not solve the full problem until near the end of its computation. In terms of wall-clock time, our method is not competitive with the hierarchical solvers, however it is possible that if a separately trained neural network is used at each layer of the hierarchy, our strategy will be superior to hierarchical finte difference algorithms.

Conclusion
We have shown how the equilibrium solution of the heat transport problem can be learned in a weakly supervised way by use of a physics informed loss function that encodes the local rules defined by the differential equations of heat transport. Further, we have shown that it is possible to use this technique to speed up finite difference calculations relative to the naive approach. We have also demonstrated that the local rule defining heat transport can be learned, in the form of a kernel, directly from data. In principle, the differential equations for heat transport can be replaced with those for any other phenomenon whose dynamics are defined by partial differential equations. This work points toward the possibility of encod- Figure 5: A comparison of two strategies to solving finite difference are shown. The yellow line shows the average per-pixel error of the computed solution at each iteration of the finite difference algorithm when it is given the output of our trained neural network (size 256×256 as in section 5.1) as an initialization. The blue line shows the average per-pixel error of the computed solution at each iteration of the finite difference algorithm when it is initialized with constant values equal to the average temperature of each of the borders of the plate. Average perpixel error is computed relative to "ground truth", which is determined by running finite difference to a very high precision.