Controlling Neural Networks with Rule Representations


Deep neural networks (DNNs) present extra correct outcomes as the dimensions and protection of their coaching knowledge will increase. Whereas investing in high-quality and large-scale labeled datasets is one path to mannequin enchancment, one other is leveraging prior data, concisely known as “guidelines” — reasoning heuristics, equations, associative logic, or constraints. Contemplate a standard instance from physics the place a mannequin is given the duty of predicting the following state in a double pendulum system. Whereas the mannequin could study to estimate the whole vitality of the system at a given cut-off date solely from empirical knowledge, it is going to steadily overestimate the vitality until additionally offered an equation that displays the identified bodily constraints, e.g., vitality conservation. The mannequin fails to seize such well-established bodily guidelines by itself. How may one successfully train such guidelines in order that DNNs take up the related data past merely studying from the info?

In “Controlling Neural Networks with Rule Representations”, revealed at NeurIPS 2021, we current Deep Neural Networks with Controllable Rule Representations (DeepCTRL), an strategy used to offer guidelines for a mannequin agnostic to knowledge sort and mannequin structure that may be utilized to any form of rule outlined for inputs and outputs. The important thing benefit of DeepCTRL is that it doesn’t require retraining to adapt the rule energy. At inference, the person can modify rule energy primarily based on the specified operation level of accuracy. We additionally suggest a novel enter perturbation methodology, which helps generalize DeepCTRL to non-differentiable constraints. In real-world domains the place incorporating guidelines is crucial — resembling physics and healthcare — we exhibit the effectiveness of DeepCTRL in instructing guidelines for deep studying. DeepCTRL ensures that fashions comply with guidelines extra carefully whereas additionally offering accuracy good points at downstream duties, thus enhancing reliability and person belief within the skilled fashions. Moreover, DeepCTRL permits novel use instances, resembling speculation testing of the principles on knowledge samples and unsupervised adaptation primarily based on shared guidelines between datasets.

The advantages of studying from guidelines are multifaceted:

  • Guidelines can present further info for instances with minimal knowledge, enhancing the take a look at accuracy.
  • A serious bottleneck for widespread use of DNNs is the lack of knowledge the rationale behind their reasoning and inconsistencies. By minimizing inconsistencies, guidelines can enhance the reliability of and person belief in DNNs.
  • DNNs are delicate to slight enter modifications which might be human-imperceptible. With guidelines, the influence of those modifications could be minimized because the mannequin search house is additional constrained to scale back underspecification.

Studying Collectively from Guidelines and Duties

The standard strategy to implementing guidelines incorporates them by together with them within the calculation of the loss. There are three limitations of this strategy that we purpose to deal with: (i) rule energy must be outlined earlier than studying (thus the skilled mannequin can not function flexibly primarily based on how a lot the info satisfies the rule); (ii) rule energy isn’t adaptable to focus on knowledge at inference if there’s any mismatch with the coaching setup; and (iii) the rule-based goal must be differentiable with respect to learnable parameters (to allow studying from labeled knowledge).

DeepCTRL modifies canonical coaching by creating rule representations, coupled with knowledge representations, which is the important thing to allow the rule energy to be managed at inference time. Throughout coaching, these representations are stochastically concatenated with a management parameter, indicated by α, right into a single illustration. The energy of the rule on the output resolution could be improved by rising the worth of α. By modifying α at inference, customers can management the conduct of the mannequin to adapt to unseen knowledge.

DeepCTRL pairs a knowledge encoder and rule encoder, which produce two latent representations, that are coupled with corresponding goals. The management parameter α is adjustable at inference to manage the relative weight of every encoder.

Integrating Guidelines by way of Enter Perturbations

Coaching with rule-based goals requires the goals to be differentiable with respect to the learnable parameters of the mannequin. There are a lot of useful guidelines which might be non-differentiable with respect to enter. For instance, “larger blood stress than 140 is prone to result in heart problems” is a rule that’s arduous to be mixed with standard DNNs. We additionally introduce a novel enter perturbation methodology to generalize DeepCTRL to non-differentiable constraints by introducing small perturbations (random noise) to enter options and developing a rule-based constraint primarily based on whether or not the end result is within the desired course.

Use Circumstances

We consider DeepCTRL on machine studying use instances from physics and healthcare, the place utilization of guidelines is especially necessary.

  • Improved Reliability Given Recognized Ideas in Physics
  • We quantify reliability of a mannequin with the verification ratio, which is the fraction of output samples that fulfill the principles. Working at a greater verification ratio may very well be helpful, particularly if the principles are identified to be at all times legitimate, as in pure sciences. By adjusting the management parameter α, a better rule verification ratio, and thus extra dependable predictions, could be achieved.

    To exhibit this, we contemplate the time-series knowledge generated from double pendulum dynamics with friction from a given preliminary state. We outline the duty as predicting the following state of the double pendulum from the present state whereas imposing the rule of vitality conservation. To quantify how a lot the rule is realized, we consider the verification ratio.

    DeepCTRL permits controlling a mannequin’s conduct after studying, however with out retraining. For the instance of a double pendulum, standard studying imposes no constraints to make sure the mannequin follows bodily legal guidelines, e.g., conservation of vitality. The scenario is analogous for the case of DeepCTRL the place the rule energy is low. So, the whole vitality of the system predicted at time t+1 ( blue) can generally be larger than that measured at time t (pink), which is bodily disallowed (backside left). If rule energy in DeepCTRL is excessive, the mannequin could comply with the given rule however lose accuracy (discrepancy between pink and blue is bigger; backside proper). If rule energy is between the 2 extremes, the mannequin could obtain larger accuracy (blue curve is near pink) and comply with the rule correctly (blue curve is decrease than pink one).

    We evaluate the efficiency of DeepCTRL on this process to traditional baselines of coaching with a hard and fast rule-based constraint as a regularization time period added to the target, λ. The best of those regularization coefficients supplies the best verification ratio (proven by the inexperienced line within the second graph beneath), nonetheless, the prediction error is barely worse than that of λ = 0.1 (orange line). We discover that the bottom prediction error of the mounted baseline is similar to that of DeepCTRL, however the highest verification ratio of the mounted baseline continues to be decrease, which means that DeepCTRL may present correct predictions whereas following the regulation of vitality conservation. As well as, we contemplate the benchmark of imposing the rule-constraint with Lagrangian Twin Framework (LDF) and exhibit two outcomes the place its hyperparameters are chosen by the bottom imply absolute error (LDF-MAE) and the best rule verification ratio (LDF-Ratio) on the validation set. The efficiency of the LDF methodology is very delicate to what the primary constraint is and its output isn’t dependable (black and pink dashed strains).

    Experimental outcomes for the double pendulum process, displaying the task-based imply absolute error (MAE), which measures the discrepancy between the bottom fact and the mannequin prediction, versus DeepCTRL as a perform of the management parameter α. TaskOnly doesn’t have a rule constraint and Activity & Rule has totally different rule energy (λ). LDF enforces guidelines by fixing a constraint optimization downside.
    As above, however displaying the verification ratio from totally different fashions.
    Experimental outcomes for the double pendulum process displaying the present and predicted vitality at time t and t + 1, respectively.

    Moreover, the figures above illustrate the benefit DeepCTRL has over standard approaches. For instance, rising the rule energy λ from 0.1 to 1.0 improves the verification ratio (from 0.7 to 0.9), however doesn’t enhance the imply absolute error. Arbitrarily rising λ will proceed to drive the verification ratio nearer to 1, however will end in worse accuracy. Thus, discovering the optimum worth of λ would require many coaching runs by means of the baseline mannequin, whereas DeepCTRL can discover the optimum worth for the management parameter α rather more shortly.

  • Adapting to Distribution Shifts in Healthcare
  • The strengths of some guidelines could differ between subsets of the info. For instance, in illness prediction, the correlation between heart problems and better blood stress is stronger for older sufferers than youthful sufferers. In such conditions, when the duty is shared however knowledge distribution and the validity of the rule differ between datasets, DeepCTRL can adapt to the distribution shifts by controlling α.

    Exploring this instance, we concentrate on the duty of predicting whether or not heart problems is current or not utilizing a heart problems dataset. On condition that larger systolic blood stress is thought to be strongly related to heart problems, we contemplate the rule: “larger danger if the systolic blood stress is larger”. Based mostly on this, we cut up the sufferers into two teams: (1) uncommon, the place a affected person has hypertension, however no illness or decrease blood stress, however has illness; and (2) regular, the place a affected person has hypertension and illness or low blood stress, however no illness.

    We exhibit beneath that the supply knowledge don’t at all times comply with the rule, and thus the impact of incorporating the rule can depend upon the supply knowledge. The take a look at cross entropy, which signifies classification accuracy (decrease cross entropy is healthier), vs. rule energy for supply or goal datasets with various regular / uncommon ratio are visualized beneath. The error monotonically will increase as α → 1 as a result of the enforcement of the imposed rule, which doesn’t precisely mirror the supply knowledge, turns into extra strict.

    Check cross entropy vs. rule energy for a supply dataset with regular / uncommon ratio of 0.30.

    When a skilled mannequin is transferred to the goal area, the error could be decreased by controlling α. To exhibit this, we present three domain-specific datasets, which we name Goal 1, 2, and three. In Goal 1, the place nearly all of sufferers are from the regular group, as α is elevated, the rule-based illustration has extra weight and the resultant error decreases monotonically.

    As above, however for a Goal dataset (1) with a regular / uncommon ratio of 0.77.

    When the ratio of regular sufferers is decreased in Goal 2 and three, the optimum α is an intermediate worth between 0 and 1. These exhibit the aptitude to adapt the skilled mannequin by way of α.

    As above, however for Goal 2 with a regular / uncommon ratio of 0.50.
    As above, however for Goal 3 with a regular / uncommon ratio of 0.40.


Studying from guidelines could be essential for developing interpretable, strong, and dependable DNNs. We suggest DeepCTRL, a brand new methodology used to include guidelines into data-learned DNNs. DeepCTRL permits controllability of rule energy at inference with out retraining. We suggest a novel perturbation-based rule encoding methodology to combine arbitrary guidelines into significant representations. We exhibit three use instances of DeepCTRL: enhancing reliability given identified ideas, inspecting candidate guidelines, and area adaptation utilizing the rule energy.


We tremendously admire the contributions of Jinsung Yoon, Xiang Zhang, Kihyuk Sohn and Tomas Pfister.