Controlling Neural Networks with Rule Representations


Deep neural networks (DNNs) present extra correct outcomes as the scale 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 information, concisely known as “guidelines” — reasoning heuristics, equations, associative logic, or constraints. Contemplate a typical instance from physics the place a mannequin is given the duty of predicting the following state in a double pendulum system. Whereas the mannequin might study to estimate the overall vitality of the system at a given time limit solely from empirical knowledge, it’s going to incessantly overestimate the vitality except additionally offered an equation that displays the recognized bodily constraints, e.g., vitality conservation. The mannequin fails to seize such well-established bodily guidelines by itself. How may one successfully educate such guidelines in order that DNNs take in the related information past merely studying from the info?

In “Controlling Neural Networks with Rule Representations”, printed 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 power. At inference, the person can modify rule power based mostly on the specified operation level of accuracy. We additionally suggest a novel enter perturbation technique, which helps generalize DeepCTRL to non-differentiable constraints. In real-world domains the place incorporating guidelines is vital — akin to physics and healthcare — we show the effectiveness of DeepCTRL in instructing guidelines for deep studying. DeepCTRL ensures that fashions observe guidelines extra intently whereas additionally offering accuracy positive aspects at downstream duties, thus enhancing reliability and person belief within the educated fashions. Moreover, DeepCTRL allows novel use instances, akin to speculation testing of the foundations on knowledge samples and unsupervised adaptation based mostly on shared guidelines between datasets.

The advantages of studying from guidelines are multifaceted:

  • Guidelines can present additional info for instances with minimal knowledge, enhancing the check accuracy.
  • A serious bottleneck for widespread use of DNNs is the lack of awareness 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 can be human-imperceptible. With guidelines, the impression of those modifications may be minimized because the mannequin search house is additional constrained to cut back underspecification.

Studying Collectively from Guidelines and Duties

The typical 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 intention to deal with: (i) rule power must be outlined earlier than studying (thus the educated mannequin can not function flexibly based mostly on how a lot the info satisfies the rule); (ii) rule power shouldn’t be 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 power 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 power of the rule on the output determination may be improved by rising the worth of α. By modifying α at inference, customers can management the habits 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 targets. The management parameter α is adjustable at inference to manage the relative weight of every encoder.

Integrating Guidelines through Enter Perturbations

Coaching with rule-based targets requires the targets to be differentiable with respect to the learnable parameters of the mannequin. There are numerous invaluable guidelines which can 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 typical DNNs. We additionally introduce a novel enter perturbation technique to generalize DeepCTRL to non-differentiable constraints by introducing small perturbations (random noise) to enter options and setting up a rule-based constraint based mostly on whether or not the end result is within the desired course.

Use Instances

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

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

    To show 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 allows controlling a mannequin’s habits after studying, however with out retraining. For the instance of a double pendulum, typical 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 power is low. So, the overall vitality of the system predicted at time t+1 ( blue) can typically be larger than that measured at time t (pink), which is bodily disallowed (backside left). If rule power in DeepCTRL is excessive, the mannequin might observe the given rule however lose accuracy (discrepancy between pink and blue is bigger; backside proper). If rule power is between the 2 extremes, the mannequin might obtain larger accuracy (blue curve is near pink) and observe the rule correctly (blue curve is decrease than pink one).

    We evaluate the efficiency of DeepCTRL on this activity to standard baselines of coaching with a set rule-based constraint as a regularization time period added to the target, λ. The very best of those regularization coefficients offers the very best verification ratio (proven by the inexperienced line within the second graph under), nonetheless, the prediction error is barely worse than that of λ = 0.1 (orange line). We discover that the bottom prediction error of the fastened baseline is corresponding to that of DeepCTRL, however the highest verification ratio of the fastened baseline remains to be decrease, which suggests that DeepCTRL may present correct predictions whereas following the legislation of vitality conservation. As well as, we contemplate the benchmark of imposing the rule-constraint with Lagrangian Twin Framework (LDF) and show two outcomes the place its hyperparameters are chosen by the bottom imply absolute error (LDF-MAE) and the very best rule verification ratio (LDF-Ratio) on the validation set. The efficiency of the LDF technique is extremely delicate to what the primary constraint is and its output shouldn’t be dependable (black and pink dashed strains).

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

    Moreover, the figures above illustrate the benefit DeepCTRL has over typical approaches. For instance, rising the rule power λ 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 lead to 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 might 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 threat 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) common, the place a affected person has hypertension and illness or low blood stress, however no illness.

    We show under that the supply knowledge don’t at all times observe the rule, and thus the impact of incorporating the rule can depend upon the supply knowledge. The check cross entropy, which signifies classification accuracy (decrease cross entropy is best), vs. rule power for supply or goal datasets with various common / uncommon ratio are visualized under. The error monotonically will increase as α → 1 as a result of the enforcement of the imposed rule, which doesn’t precisely replicate the supply knowledge, turns into extra strict.

    Take a look at cross entropy vs. rule power for a supply dataset with common / uncommon ratio of 0.30.

    When a educated mannequin is transferred to the goal area, the error may be diminished by controlling α. To show 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 common 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 common / uncommon ratio of 0.77.

    When the ratio of common sufferers is decreased in Goal 2 and three, the optimum α is an intermediate worth between 0 and 1. These show the potential to adapt the educated mannequin through α.

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


Studying from guidelines may be essential for setting up interpretable, sturdy, and dependable DNNs. We suggest DeepCTRL, a brand new methodology used to include guidelines into data-learned DNNs. DeepCTRL allows controllability of rule power at inference with out retraining. We suggest a novel perturbation-based rule encoding technique to combine arbitrary guidelines into significant representations. We show three use instances of DeepCTRL: enhancing reliability given recognized rules, inspecting candidate guidelines, and area adaptation utilizing the rule power.


We enormously respect the contributions of Jinsung Yoon, Xiang Zhang, Kihyuk Sohn and Tomas Pfister.


Please enter your comment!
Please enter your name here