Generalizing Goal-Conditioned Reinforcement Learning with Variational Causal Reasoning
Abstract
As a pivotal component to attaining generalizable solutions in human intelligence, reasoning provides great potential for reinforcement learning (RL) agents’ generalization towards varied goals by summarizing part-to-whole arguments and discovering cause-and-effect relations.
However, how to discover and represent causalities remains a huge gap that hinders the development of causal RL.
In this paper, we augment Goal-Conditioned RL (GCRL) with Causal Graph (CG) , a structure built upon the relation between objects and events.
We novelly formulate the GCRL problem into variational likelihood maximization with CG as latent variables.
To optimize the derived objective, we propose a framework with theoretical performance guarantees that alternates between two steps: using interventional data to estimate the posterior of CG; using CG to learn generalizable models and interpretable policies.
Due to the lack of public benchmarks that verify generalization capability under reasoning, we design nine tasks and then empirically show the effectiveness of the proposed method against five baselines on these tasks.
Further theoretical analysis shows that our performance improvement is attributed to the virtuous cycle of causal discovery, transition modeling, and policy training, which aligns with the experimental evidence in extensive ablation studies.
Introduction
The generalizability, which enables an algorithm to handle unseen tasks, is fruitful yet challenging in multifarious decision-making domains.
Recent literature [1, 2, 3] reveals the critical role of reasoning in improving the generalization of reinforcement learning (RL).
However, most off-the-shelf RL algorithms [4] have not regarded reasoning as an indispensable accessory, thus usually suffering from data inefficiency and performance degradation due to the mismatch between training and testing settings.
To attain generalization at the testing stage, some efforts were put into incorporating domain knowledge to learn structured information, including sub-task decomposition [5], or program generation [6, 7, 8] and execution [9, 10], which guide the model to solve complicated tasks in an explainable way.
However, such symbolism-dominant methods heavily depend on the re-usability of sub-tasks and pre-defined grammars, which may not always be accessible in decision-making tasks.
Inspired by the close link between reasoning and the cause-and-effect relationship, causality is recently incorporated to compactly represent the aforementioned structured knowledge in RL training [11].
Based on the form of causal knowledge, we divide the related works into two categories, i.e., implicit and explicit causation.
With implicit causal representation, researchers ignore the detailed causal structure.
For instance, [12] extracts invariant features as one node that influences the reward function, while the other node consists of task-irrelevant features [13, 14, 15, 16].
This neat structure has good scalability but requires access to multiple environments that share the same invariant feature [12, 16, 17].
One can also turn to the explicit side by estimating detailed causal structures [18, 19, 20, 21], which uses directed graphical models to capture the causality in the environment.
A pre-request for this estimation is the object-level or event-level abstraction of the observation, which is available in most tasks and also becoming a frequently studied problem [22, 23, 24].
However, existing explicit causal reasoning RL models either rely on heuristic design without theoretical guarantees [18] or require the true causal graph [25].
In this paper, we propose G ene RA lizing by D iscov ER ing (GRADER) , a causal reasoning method that augments the RL algorithm with data efficiency, interpretability, and generalizability.
We mainly focus on Goal-Conditioned RL (GCRL)
[26], where different goal distributions during training and testing reflect the generalization.
We formulate the GCRL into a probabilistic inference problem [27] with a learnable causal graph as the latent variable.
This novel formulation naturally explains the learning objective with three components, i.e., transition model learning, planning, and causal graph discovery, leading to an optimization framework that alternates between the causal structure discovery policy learning to gain generalizability.
Under some mild conditions, we prove the unique identifiability of the causal graph and the theoretical performance guarantee of the proposed framework.
To demonstrate the effectiveness of the proposed method, we conduct comprehensive experiments in environments that require strong reasoning capability.
Specifically, we design two types of generalization settings, i.e., spuriousness and composition, and provide an example to illustrate these settings in Figure 1.
The evaluation results confirm our method’s advantages in several aspects.
First, the proposed data-efficient discovery method provides an explainable causal graph yet requires much less data than score-based methods, increasing data efficiency and interpretability during task solving.
Second, simultaneously discovering the causal graph during policy learning dramatically increases the success rate of solving tasks.
In summary, the contribution of this paper is threefold:
• We use the causal graph as a latent variable to reformulate the GCRL problem and then derive an iterative training framework from solving this problem.
• We prove that our method uniquely identifies true causal graphs, and the performance of the iterative optimization is guaranteed with a lower bound given converged transition dynamics.
• We design nine tasks in three environments that require strong reasoning capability and show the effectiveness of the proposed method against five baselines on these tasks.
Problem Formulation and Preliminary
We start by discussing the setting of RL we use in this paper and the assumptions required in causal reasoning.
Then we briefly introduce the necessary concepts related to causality and causal discovery.
2.1 Factorized Goal-conditioned RL
We assume the environment follows the Goal-conditioned Markov Decision Process (MDP) setting with full observation.
This setting is represented by a tuple M =
( S , A , P , R , G ) , where S is the state space, A is the action space, P is the probabilistic transition model, G ⊂ S is the goal space which is a set of assignment of values to states, and r ( s, g )
=
1 ( s = g ) ∈ R is the sparse deterministic reward function that returns 1 only if the state s match the goal g .
In this paper, we focus on the goal-conditioned generalization problem, where the goal for training and testing stages will be sampled from different distributions p train ( g ) and p test ( g ) .
We refer to a goal g ∈ G as a task and use these two terms interchangeably.
To accomplish the causal discovery methods, we make a further assumption similar to [20, 28] for the state and action space:
Assumption 1 (Space Factorization) .
The state space S =
{S 1 × · · · × S M } and action space
A = {A 1 × · · · × A N } can be factorized to disjoint components {S i } Mi =1 and {A i } Ni =1 .
The components representing one event or object’s property usually have explicit semantic meanings for better interpretability.
This assumption can be satisfied by state and action abstraction, which has been widely investigated in [22, 23, 24].
Such factorization also helps deal with the high-dimensional states since it might be impossible to treat each dimension as one random variable [18].
2.2 Causal Reasoning with Graphical Models
Reasoning with causality relies on specific causal structures, which is commonly represented as directed acyclic graphs (DAGs) [29] over variables.
Consider random variables
X
=
( X 1 , . . .
, X d ) with index set V := { 1 , . . .
, d } .
A graph G =
( V , E ) consists of nodes V and edges E ⊆ V 2 with ( i, j ) for any i, j ∈ V .
A node i is called a parent of j if e ij ∈ E and e ji / ∈ E .
The set of parents of j is denoted by PA G j .
We formally discuss the graph representation of causality with the definitions:
Definition 1 (Structural Causal Models [29]) .
A structural causal model (SCM) C :
= ( S , U ) consists of a collection S of d functions,
[Equation]
where PA j ⊂ { X 1 , . . . , X d }\{ X j } are called parents of X j ; and a joint distribution U
= { U 1 , . .
, U d } over the noise variables, which are required to be jointly independent.
Definition 2 (Causal Graph [29], CG) .
The causal graph G of an SCM is obtained by creating one node for each X j and drawing directed edges from each parent in PA G j to X j .
We note that CG describes the structure of the causality, and SCM further considers the specific causation from the parents of X j to X j via f j as well as exogenous noises U j .
To uncover the causal structure from data distribution, we assume that the CG satisfies the Markov Property and Faithfulness ([29]), which makes the independences consistent between the joint distribution P ( X 1 , . . .
, X n ) and the graph G .
We also follow the Causal Sufficiency assumption [30] that supposes we have measured all the common causes of the measured variables.
Existing work [31, 20] believes that two objects have causation only if they are close enough while there is no edge between them if the distance is large.
Instead of using such a local view of the causality, we assume the causal graph is consistent across all time steps, which also handles the local causal influence.
The specific influence indicated by edges is estimated by the function f j ( PA j , U j ) .
Generalizing by Discovering (GRADER)
With proper definitions and assumptions, we now look at the proposed method.
We first derive the framework of GRADER by formulating the GCRL problem as a latent variable model, which provides a variational lower bound to optimize.
Then, we divide this objective function into three parts and iteratively update them with a specific performance guarantee.
3.1 GCRL as Latent Variable Models
The general objective of RL is to maximize the expected reward function w.r.t.
a learnable policy model π .
Particularly, in the goal-conditioned setting, such objective is represented as max π E τ ∼ π,g ∼ p ( g ) [ (cid:80) T t =0 r ( s t , g )] , where p ( g ) is the distribution of goals and τ :=
{ s 0 , a 0 , . . .
, s T } the action-state trajectory with maximal time step T .
The trajectory ends only if the goal is achieved g = s T or the maximal step is reached.
Inspired by viewing the RL problem as probabilistic inference [32, 27], we replace the question from "How to find actions to achieve the goal?" to "what are the actions if we achieve the goal?" , leading to a likelihood maximization problem for p ( τ | s ∗ ) with s ∗ :
= 1 ( g = s T ) .
Different from previous work [33] that recasts actions as latent variables and infers actions that result in "observed" high reward, we decompose p ( τ | s ∗ ) with G as the latent variable to get the evidence lower bound (ELBO)
[Equation]
where the prior p ( G ) and variational posterior q ( G| τ ) represent distributions over a graph structure, i.e, the probability of the existences of edges in the graph.
D KL represents the Kullback–Leibler (KL) divergence between two graphs, which will be explained in Section 3.3.
Recall that the space of goal
G is a subset of the state, here we extend the meaning of g and assume all trajectories achieve the goal in the final state [34], i.e., g = s T .
Such extension makes it possible to further decompose the first term of (2) as (refer to Appendix A.1.2)
[Equation]
Here, we use the fact that G is effective in both the transition model p ( s t +1 | a t , s t , G ) and the policy model log p ( a t | s t , s ∗ , G ) , g only influences the policy model, and the initial state s 0 depends neither on G nor g .
We assume that both initial state log p ( s 0 ) and goal log p ( g ) follow the uniform distribution; thus, the first and last terms of (3) are constants.
The policy term π , selecting action a t according to both current state s t and goal g , is implemented with the planning method and is further discussed in Section 3.2.
Finally, we maximize the likelihood p ( τ | s ∗ ) with the following reformulated ELBO as the objective
[Equation]
where θ is the shared parameter of transition model p θ ( s t +1 | a t , s t , G ) and policy π θ ( a t | s t , s ∗ , G ) , and ϕ is the parameter of causal graph q ϕ
( G| τ ) .
To efficiently solve this optimization problem, we iteratively updates parameter ϕ (causal discovery, Section 3.3) and parameter θ (model and policy learning, Section 3.2), as shown in Figure 2.
Intuitively, these processes can be respectively viewed as the discovery of graph and the update of f i , which share tight connections as discussed in Section 2.2.
3.2 Model and Policy Learning
Let us start with a simple case where we already obtain a G and use it to guide the learning of parameter θ via max θ J ( θ, ϕ ) .
Since the KL divergence of J ( θ, ϕ ) does not involve θ , we only need to deal with the first expectation term, i.e., the likelihood of transition model and policy.
For the transition p θ ( s t +1 | a t , s t , G ) , we connect it with causal structure by further defining a particular type of CG and denote it as G in the rest of this paper:
Definition 3 (Transition Causal Graph) .
We define a bipartite graph G , whose vertices are divided into two disjoint sets U =
{A t , S t } and V = {S t +1 } .
A t represents action nodes at step t , S t state nodes at step t , and S t +1 the state nodes at step t + 1 .
All edges start from set U and end in set V .
Model learning.
This definition builds the causal graph between two consecutive time steps, which indicates that the values of states in step t + 1 depend on values in step t .
It also implies that the interventions [29] on nodes in U are directly obtained since they have no parents.
We denote the marginal distribution of S as p I sπ , which is collected by RL policy π .
Combined with the Definitionof SCM, we find that p θ ( s t +1 | a t , s t , G ) essentially approximates a collection of functions
f j following the structure G , which take as input the values of parents of the state node s j and outputs the value s j .
Thus, we propose to model the transition corresponding to G with a collection of neural networks f θ ( G ) :
=
{ f θ j } Mj =1 to obtain
[Equation]
where [ PA G j ] t represents the values of all parents of node s tj at time step t and U j follows Gaussian noise U j ∼ N (0 , I ) .
In practice, we use Gated Recurrent Unit [35] as f j because it supports varying numbers of input nodes.
We take s tj as the initial hidden embedding and the rest parents [ PA G j \ s j ] t as the input sequence to f j .
The entire model is optimized by stochastic gradient descent with the log-likelihood log p θ ( s t +1 | a t , s t , G ) as objective.
Policy learning with planning.
Then we turn to the policy term π θ ( a t | s t , s ∗ , G ) in J ( θ, ϕ ) .
We optimize it with planning methods that leverage the estimated transition model.
Specifically, the policy aims to optimize an action-state value function Q ( s t , a t ) =
E (cid:104)(cid:80)
Ht ′
=
γ t ′ r
( s t ′ + t , a t ′ + t ) | s t , a t (cid:105) , which can be obtained by unrolling the transition model with a horizon of H steps and discount factor γ .
In practice, we use model predictive control (MPC) [36] with random shooting [37], which selects the first action in the fixed-horizon trajectory that has the highest action-state value Q ( s t , a t ) , i.e. ˆ π ( s t ) =
arg max a t ∈A Q G θ ( s t , a t ) .
The formulation we derived so far is highly correlated to the model-based RL framework [38].
However, the main difference is that we obtain it with variational inference by regarding the causal graph as a latent variable.
3.3 Data-Efficient Causal Discovery
Algorithm 1: GRADER
Input: Trajectory buffer B τ , Causal graph G , Transition model f θ , causal discovery threshold η while θ not converged do // Policy from planning
Sample a goal g ∼ p train ( g ) while t < T do a t ← Planner( f θ , s t , g ) s t +1 , r t ← Env( a t , g )
B τ ← B τ ∪ { a t , s t , s t +1 } //
Estimate causal graph for i ≤ M + N do for j ≤ M do
Infer edge e ij ← q ϕ ( ·|B , η ) //
Learn transition model
Update f θ ( G ) via (5) with B
In this step, we relax the assumption of knowing G and aim to estimate the posterior distribution q ( G| τ ) to increase the ELBO (4) w.r.t.
parameter ϕ .
In most score-based methods [39], likelihood is used to evaluate the correctness of the causal graph, i.e., a better causal graph leads to a higher likelihood.
Since the first term of (4) represents the likelihood of the transition model, we convert the problem of max ϕ J ( θ, ϕ ) to the causal discovery that finds the true causal graph based on collected data samples.
As for the second term of (4), the following proposition shows that the KL divergence between q ϕ ( G| τ ) and p ( G ) can be approximated by a sparsity regularization (proof in Appendix A.4.2).
Proposition 1 (KL Divergence as Sparsity Regularization) .
With entry-wise independent Bernoulli prior p ( G ) and point mass variational distribution q ( G| τ ) of
DAGs, D KL [ q ϕ ∥ p ] is equivalent to an ℓ 1 sparsity regularization for the discovered causal graph.
We restrict the posterior q ϕ ( G| τ ) to point mass distribution and use a threshold η to control the sparsity.
We perform the discovery process from the classification perspective by proposing binary classifiers q ϕ ( e ij | τ, η ) to determine the existence of an edge e ij .
This classifier q ϕ ( e ij | τ, η ) is implemented by statistic Independent Test [40], and η is the threshold for the p-value of the hypothesis.
A larger η corresponds to harder sparsity constraints, thus leading to a sparse G since two nodes are more likely to be considered independent.
According to the definition 3, we only need to conduct classification to edges connecting nodes between U and V .
If two nodes are dependent, we add one edge directed from the node in U to the node in V .
This definition also ensures that we always have q ( G| τ ) ∈ Q DAG , where Q DAG is the class of DAG.
With this procedure, we identify a unique CG G ∗ under optimality:
Proposition 2 (Identifiability) .
Given an oracle independent test, with an optimal interventional data distribution p ∗
I s π , causal discovery obtains ϕ ∗ that correctly tells the independence between any two nodes, then the causal graph is uniquely identifiable, with e ∗ ij =
q ϕ ∗ ( e ij | τ ) , ∀ i ∈
[ M + N ] , j ∈
[ M ] .
In practice, we use χ 2 -test for discrete variables and the Fast Conditional Independent Test [40] for continuous variables.
The sample size needed for obtaining the oracle test has been widely investigated [41].
However, testing with finite data is not a trivial problem, as stated in [42], especially when the data is sampled from a Goal-conditioned MDP.
Usually, the random policy is not enough to satisfy the oracle assumption because some nodes cannot be fully explored when the task is complicated and has a long horizon.
To make this assumption empirically possible, it is necessary to simultaneously optimize π θ ( a t | s t , s ∗ , G ) to access more samples close to finishing the task, which is further analyzed in Section 3.4.
We also empirically support this argument in Section 4.2 and provide a detailed theoretical proof in Appendix A.3 and A.4.
3.4 Analysis of Performance Guarantee
The entire pipeline of GRADER is summarized in Algorithm 1.
To analyze the performance of the optimization of (4), we first list important lemmas that connect previous steps and then show that the iteration of these steps in GRADER leads to a virtuous cycle.
By the following lemmas, we show the following performance guarantees step by step.
Lemmashows model learning is monotonically better at convergence given a better causal graph from causal discovery.
Then the learned transition model helps to improve the lower bound of the value function during planning according to Lemma 2.
Lemma 3 reveals the connection between policy learning and interventional data distribution, which in turn improves the quality of our causal discovery, as is shown in Lemma 4 and Proposition 2.
Lemma 1 (Monotonicity of Transition Likelihood) .
Assume G ∗ =
( V, E ∗ ) be the true CG, for two
[Equation]
and
[Equation] [Equation]
when transition model θ converges, the following inequality holds for the transition model in (4):
[Equation]
where SHD is the Structural Hamming Distance defined in Appendix A.2.
Lemma 2 (Bounded Value Function in Policy Learning) .
Given a planning horizon H → ∞ , if we already have an approximate transition model D TV (ˆ p ( s ′ | s, a ) , p ( s ′ | s, a )) ≤ ϵ m , the approximate policy ˆ π achieves a near-optimal value function (refer to Appendix A.3 for detailed analysis):
[Equation]
Lemma 3 (Policy Learning Improves Interventional Data Distribution) .
With a step reward r ( s, a ) =
(cid:112) ð 1 ( s = g ) , we show that the value function determines an upper bound for TV divergence between the interventional distribution with its optimal (proof details in Appendix A.3):
[Equation]
where p I sπ is the marginal state distribution in interventional data, and p g is the goal distribution.
A better policy with larger V π ( s ) enforces the distribution of interventional data toward the goal.
Lemma 4 (Interventional Data Benefits Causal Discovery) .
For ϵ g = min p g > 0 p g , D TV ( p I sπ , p g ) <
ϵ g , the error of our causal discovery is upper bounded with E ˆ G
[ SHD ( ˆ G , G ∗ )] ≤ |S| − 1 .
After the close-loop analysis of our model, we are now able to analyze the overall performance of the proposed framework.
Under the construction of p θ ( s t +1 | a t , s t , G ) with NN-parameterized functions, the following theorem shows that the learning process will guarantee to perform a close estimation of true ELBO under the iterative optimization among model learning, planning, and causal discovery.
Theorem 1.
With T-step approximate transition dynamics D TV (cid:16) ˆ p ( s ′ | s, a ) , p ( s ′ | s, a ) (cid:17) ≤ ϵ m , if the goal distribution satisfies ϵ g >
[Equation]
ϵ m , and the distribution prior CG is entry-wise independent
Bernoulli ( ϵ G ) , GRADER guarantees to achieve an approximate ELBO ˆ J with the true ELBO J ∗ :
[Equation]
An intuitive understanding of the performance guarantee is that a better transition model indicates a better approximation of objective J .
The proof of this theorem and corresponding empirical results are in Appendix A.5.
Experiments
In this section, we first discuss the setting of our designed environments as well as the baselines used in the experiments.
Then, we provide the numerical results and detailed discussions to answer the following important research questions: Q1.
Compared to baselines, how does GRADER gain performance improvement under both in-distribution and generalization settings?
Q2.
Compared to an offline random policy, how does a well-trained policy improve the results of causal discovery?
Q3.
Compared to score-based causal discovery, does the proposed data-efficient causal discovery pipeline guarantee identifying the true causal graph as stated in Section 3.3?
Q4.
Compared to imperfect causal graphs, how does the correctness of discovered causal graph influence the task-solving performance of GCRL agents?
[Table]
4.1 Environments and Baselines
Since most commonly used RL benchmarks do not explicitly require causal reasoning for generalization, we design three environments besides Chemistry [43], which are shown in Figure 3.
These environments use the true state as observation to disentangle the reasoning task from visual understanding.
For each environment, we design three settings – in-distribution ( I ), spuriousness ( S ), and composition ( C ) – corresponding to different goal distributions for generalization.
We use p train ( g ) and p test ( g ) to represent the goal distribution during training and testing, respectively.
I uses the same p train ( g ) and p test ( g ) , S introduces spurious correlations in p train ( g ) but remove them in p test ( g ) , and C contains more similar sub-goals in p test ( g ) than in p train ( g ) .
The details of these settings in are briefly summarized in the following (details in Appendix C.2.1):
• Stack : We design this manipulation task inspired by the CausalWorld [44], where the agent must stack objects to match specific shapes and colors.
In Stack-S , we let the same shape have the same color in p train ( g ) but randomly sample the color and shape in p test ( g ) .
In Stack-C , the maximum number of object is two in p train ( g ) but five in p test ( g ) .
• Unlock : We design this indoor house-holding task for the agent to collect a key to open doors.
This environment is built upon the Minigrid [45].
In Stack-S , the door and the key are always in the same row in p train ( g ) but uniformly sample in p test ( g ) .
In Unlock-C , there are one door in p train ( g ) but two doors in p test ( g ) .
• Crash : The occurrence of accidents usually relies on causality, e.g., an autonomous vehicle (AV) collides with a jaywalker because its view is blocked by another car [46].
We design such a crash scenario based on highway-env [47], where the goals are to create crashes between a pedestrian and different AVs.
In Stack-S , the initial distance between ego car and pedestrian is a constant in p train ( g ) but irrelevant in p test ( g ) .
In Stack-C , there is one pedestrian in p train ( g ) but two in p test ( g ) .
• Chemistry [43]: There are 10 nodes with different colors.
An underlying causal graph controls the color-changing mechanism of all nodes.
In one step, the agent changes the color of one node.
The goal is to match the given colors of all nodes.
In the spuriousness setting, we let all nodes have the same target color.
There is no composition setting in this environment.
We use the following methods as our baselines to fairly demonstrate the advantages of GRADER.
SAC: [48] Soft Actor-Critic is a well-known model-free RL method; we augment it with HER [49] in Stack because the goal in this task does not have pre-conditions.
ICIN:
[25] It uses DAgger [50] to learn goal-conditioned policy with the causal graph estimated from the expert policy.
We assume it can access the true causal graph for supervised learning.
PETS:
[51] We consider the ensemble transition model with random shoot planning as one baseline, which achieves generalization with the uncertaintyaware design.
TICSA:
[18] This is a causal-augmented MBRL method that simultaneously optimizes a
soft adjacent matrix (representing the causality) and a transition model.
ICIL:
[16] This method proposes an invariant feature learning structure that captures the implicit causality of multiple tasks.
We only use it for transition model learning since the original method is designed for imitation learning.
GNN: [52] Since graph neural networks are good at learning structural information, we implement a GNN-based baseline using Relational Graph Convolutional Network.
4.2 Results Discussion
Overall Performance (Q1)
We compare the testing reward of all methods under nine tasks and summarize the results in Table 1 to demonstrate the overall performance.
Generally, our method outperforms other baselines in all tasks except Stack-I , which is simple for all methods.
We note that the gap between our method and baselines under S and C settings is more significant than the I setting, showing that our method still works well in the non-trivial generalization task.
As a model-free method, SAC fails in all three tasks of Unlock and Crash environments since they have sparse rewards.
Without learning the causal structure of the environment, PETS even cannot fully solve Unlock-S ,
Unlock-C , and all Crash tasks.
Both TICSA and ICIL learn explicit or implicit causality of the task, so they are relatively better than SAC and PETS.
However, they are still worse than GRADER in two generalization settings because of the unstable and inefficient causal reasoning mechanism.
We also find that even if the ICIN is given the true causal graph, the policy learning part cannot efficiently leverage the causality, leading to worse performance in generalization settings.
To further analyze the tendency of learning, we plot the curves of all methods under Crash in Figure 4.
Our method quickly learns to solve the tasks at the beginning of the training, demonstrating data efficiency.
GRADER also outperforms other methods with large gaps in the later training phase.
The results of the other two environments can be found in Appendix B.1.
Importance of Policy Learning (Q2)
As we mentioned in Section 3.3, we empirically compare GRADER and Offline [53], which uses data from offline random policy, and plot results in the right part of Figure 4.
We use SHD [54] to compute the distance between the estimated causal graph and the true causal graph, which is obtained by checking the best causal graph with human analysis.
The true causal graph for each environment can be found in Appendix B.2.
When we only use samples collected offline by random policy, we cannot obtain variables’ values that require long-horizon reasoning, e.g., the door can be opened if the agent is close to the door and has the key, leading to unreliable discovery.
As a consequence, the causal graph obtained by Offline indeed harms the performance, as shown in
Figure 4.
Instead, GRADER gradually explores more regions and quickly obtains the true causal graph when we iteratively discover the causal graph and update the policy.
Advantage of Data-efficient Causal Discovery (Q3)
To show the advantage of proposed constraintbased methods, we design a model named Score that optimizes a soft adjacent matrix similar to the score-based method in the discovery step.
Score-based discovery methods, also used in TICSA, are recently combined with NN for differentiable training.
According to the discovery accuracy shown in the right part of Figure 4, we find that score-based discovery is inefficient.
Based on the performance of the Score model summarized in Table 1, we also conclude that it is not as good as our constraint-based method and has a large variance due to the unstable learning of the causal graph.
Influence of Causal Graph (Q4)
To illustrate the importance of the causal graph, we implement another variant of GRADER named Full , which uses a fixed full graph that connects all nodes
[Table]
between the sets U and V .
According to the performance shown in Table 1 and Figure
[Table]
we find that the full graph achieves worse results than GRADER because of the redundant and spurious correlation.
Intuitively, unrelated information causes additional noises to the learning procedure
[Table]
and the spurious correlation creates a shortcut that makes the model extract wrong features, leading to worse results in the spuriousness generalization as shown in Table 1.
We then investigate how the correctness of the causal graph influences the performance.
We use fixed graphs interpolating from the best causal graph to the full graph to train a GRADER model on
Unlock-S and summarize the results in Figure
The more correct the graph is, the higher reward the agent obtains, which supports our statements in Section 3.4 that the causal graph is important for the reasoning tasks – a better causal graph helps the model have better task-solving performance.
4.3 Further Analysis of Causal Discovery
Finally, we conduct further analysis of the discovery performance on the Chemistry environment [43], which is a standard benchmark for evaluating causal discovery methods.
In this environment, the colors of nodes are controlled by the causal graph, therefore, finding the true causal graph makes it much easier to achieve the goal that requires matching all target colors.
The agent can discover the graph by doing interventions via interacting with the environment.
We consider four types of causal graphs ( Collider , Chain , Jungle , Full ) with 10 nodes in this experiment.
The discovery performance is shown in Tablewith five metrics indicating the classification error.
We can see that GRADER outperforms the Score method in all 4 types of graphs.
In
Figure 6, we show the discovered graphs from
GRADER (averaged over 10 seeds) and the true causal graphs of Collider and Jungle settings.
We also show that GRADER achieves advantages over other baselines in solving the color-matching downstream task, which can be found with detailed experiment results in Appendix B.4.
Related Works
RL Generalization From the agent’s view, algorithms focus on actively obtaining the structure of the task or environment.
Some decompose the given task into sub-tasks [55, 56, 57, 5] and when they encounter an unseen task, they rearrange those sub-tasks to solve new tasks.
Instead of dividing tasks, Symbolic RL learns a program-based policy consisting of domain language [6, 8] or grammar [7, 58].
The generated program is then executed [9] to interact with the environment, which has the potential to solve unseen tasks by searching the symbolic space.
From the other view, we generate environments to augment agents’ experience for better generalization.
One straightforward way is data augmentation of image-based observation [59, 60, 61, 62, 63, 64].
When extended to other factors of the environment, Domain Randomization [65] and its variants [66, 67] are proposed.
Considering the interaction between agent and environment, Curriculum Learning [68] also gradually generates difficult tasks to train generalizable agents.
Goal-Conditioned RL (GCRL)
The generalization problem is naturally related to GCRL [26], which aims to train an agent for multiple tasks.
From the optimization perspective, Universal Value
Function [69], reward shaping [70], and latent dynamic model [71] are widely used tools to solve
GCRL problem.
Sub-goal generation [72] is another intuitive idea to tackle the long horizon with sparse reward, where the core thing is to make sure the generated sub-goals are solvable.
Finally,
HER [34], belonging to the relabelling category, is a ground-breaking yet straightforward method that treats visited states as "fake" goals when the goal and state share the same space.
Later on, improved versions of HER [49, 73, 74] were widely studied.
One limitation is that we cannot directly use a visited state as a goal if the goal has pre-conditions.
Similar to our setting, [75] and [76] convert the
GCRL problem to variational inference by regarding control as inference [27].
[75] propose an EM framework under the HER setting and [76] treats the last state as the goal and estimates a shaped reward during training.
RL with Causal Reasoning Causality is now frequently discussed in the machine learning field to complement the interpretability of neural networks [29].
RL algorithms also incorporate causality to improve the reasoning capability [77].
For instance, [25] and [19] explicitly estimate causal structures with the interventional data obtained from the environment.
These structures can be used to constraint output space [78] or adjust the buffer priority [20].
Building dynamic models in model-based
RL [18, 79, 53] based on causal graph is also widely studied recently.
Implicitly, we can abstract the causal structure and formulate it using the Block MDP [12] setting or training multiple encoders to extract different kinds of representations [15].
Following the idea of invariant risk minimization [80], they assume task-relevant features are invariant and shared across all environments, which can be used as the only cause of the reward.
Causal Discovery Causal discovery [81] is a long-stand topic in economics and sociology, where the traditional methods can be generally categorized into constraint-based and score-based.
Constraintbased methods [30] start from a complete graph and iteratively remove edges with conditional independent test [82, 83] as constraints.
Score-based methods [39, 84] use metrics such as Bayesian
Information Criterion [85] as scores and prefer edges that maximize the score given the dataset.
Recently, researchers extend score-based methods with RL [86] or differentiable discovery [87, 88, 89].
The former selects edges with a learned policy, and the latter learns a soft adjacent matrix with observational or interventional data.
Active intervention methods are also explored [90] to increase the efficiency of data collection and decrease the cost of conducting intervention [91].
Conclusion
This paper proposes a latent variable model that injects a causal graph reasoning process into transition model learning and planning to solve GCRL problems under the generalization setting.
We theoretically prove that our iterative optimization process can obtain the true causal graph.
To evaluate the performance of the proposed method, we designed nine tasks in three environments.
The comprehensive experiment results show that our method has better data efficiency and performance than baselines.
Our method also provides interpretability by the explicitly discovered causal graph.
The main limitation of this work is that the explicit estimation of causal structure does not scale well to the number of nodes.
Developing efficient gradient-based discovery methods could be a promising direction.
In addition, the factorized state and action space assumption may restrict the usage of this work to semantic representations, which need to be processed with abstraction methods.
We further discuss the potential negative social impact and additional limitations in Appendix C.3.
Acknowledgements.
This work is partially supported by the NSF CAREER grant CNS No.2047454, NSF grant No.1910100, NSF CNS No.2046726, C3 AI, and the Alfred P. Sloan Foundation.
Table
of Contents
A.1 Formulation of Latent Variable Models . . . . . . . . . . . . . . . . . . . . . .
A.2 Transition Model Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.3 Derivation of Planner Module . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.4 Causal Discovery . .
A.5 Overall Performance Guarantee of Iterative Optimization . .
B Additional Experiment
B.1 Overall Performance . .
B.2 Causal Graph Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.3 Distance between Goal and State Distribution . . . . . . . . . . . . . . . . . . .
B.4 Task Performance of Chemistry Experiment . . . . . . . . . . . . . . . . . . .
C Additional Information
C.1 Details about Conditional Independence Test . . . . . . . . . . . . . . . . . . .
C.2 Experiment Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C.3 Broader Social Impact and Additional Limitation . . . . . . . . . . . . . . . . .
A Theoretical Proofs
In Appendix A, we first show the derivation of the latent variable models A.1, then provide some analytical results in the iterative optimization of model learning A.2, planning A.3, and causal discovery A.4.
Finally, we give the proof of the theorem of overall performance guarantee A.5 given some common assumptions.
To compactly write down our formulas, we slightly abuse the notations by representing s t , a t as the joint states and actions at timestep t , while using s i , a i to denote the i -th dimension of factorized states or actions.
Without the loss of generality, we implement our reward in a deterministic way, which only involves r ( s, g ) in its notation, we will slightly generalize to some state-action reward function for our analysis as well.
A.1 Formulation of Latent Variable Models A.1.1 Derivation of Equation (2)
The ELBO of the likelihood of the trajectory is obtained by
[Equation]
where the third line is obtained by Jensen’s inequality and the last line is because the prior of the causal graph G is independent of the achieved goal s ∗ .
A.1.2 Derivation of Equation (3)
According to the decomposition of state-action trajectory
[Equation]
we can get the following
[Equation]
A.2 Transition Model Learning
The optimization in the model learning step can be described below:
[Equation]
where τ =
[ s 1 , a 1 , · · · , s T ] is the trajectory in data buffer, and G is the given causal graph.
Here below, we show some necessary definitions and propositions to prove the Lemma 1.
Definition 4 (Structural Hamming Distance (SHD)) .
For any two DAGs G , H with identical vertices set V , we define the following function SHD:
G × H
→
R ,
[Equation]
Definition 5 (Respect the graph) .
For any given transition model with specific causal graph G , the transition model respects the graph if the distribution p ( s t +1 | a t , s t , G ) can be factorized as:
[Equation]
where M is the total number of factorized states, PA ( · ) represents the parents in the causal graph.
Proposition 3 (GRU model respects the graph) .
As the parameterized transition model p θ ( s ′ | s, a, G ) reaches the steady state, it respects the graph.
Proof of Proposition 3.
The GRU modules with parameter θ =
[ W, U ] can be rewritten as a message passing process, where AGG · ( · ) is the iterative aggregation function.
[Equation]
As an iterated process of message passing, where the input causal graph controls the information flow between different entities, this GRU model can be rewritten as a fixed point iteration [92]:
[Equation]
With proper initialization and some sufficient conditions provided by [92], F has a unique equilibrium point, where
[Equation]
In our bipartite graph, when GRU reaches the equilibrium point, we can get a structural causal model:
[Equation]
s ′ i ∈ S ′ , PA (
[Equation]
S
[Equation]
Based on the SCM derivation 19, we can then factorize the transition model as:
[Equation]
We denote the ground truth causal graph as G ∗ =
( V, E ∗ ) , and PA ∗ ( s ′ i ) as the true parents of s ′ i in
G ∗ .
■
Definition 6 (Causal optimality at equlibrium point) .
For any G ′ ̸
= G ∗ with at least one pair of flawed parental relationship PA ′ ( s ′ i )
̸ = PA ∗ ( s ′ i ) , the following inequality holds:
[Equation]
Lemma 5 (Local monotonicity) .
Given one state variable s i and its any parental relationship
PA 1 ( s i ) , PA 2 ( s i ) , if #( PA 1 ( s i ) ∪ PA ∗ ( s i )) ≥ #( PA 2 ( s i ) ∪ PA ∗ ( s i ))
, then at steady state, the
SCM derived in 19 will miss part of the message provided from the true parents, therefore p θ ( s ′ i | PA 1 ( s ′ i ) , G 1 ) ≥ p θ ( s ′ i | PA 2 ( s ′ i ) , G 2 )
Proof of Lemma 1.
Based on the factorization defined in 20, we denote the parental relationship in
G 1 as PA 1 ( · ) ,
[Equation]
For G 1 and G 2 , suppose the only different edges e has a target node s ′ j , with SHD ( G 1 , G ∗ ) <
SHD ( G 2 , G ∗ ) , based on Lemma 5:
[Equation]
Based on the inequality derived in 22 and
[Equation]
the monotonicity of likelihood in Lemma 1 is proved.
■
A.3 Derivation of Planner Module
The optimization in the planning part is:
[Equation]
[Equation]
Ideally, given the access to real dynamics p ( s ′ | s, a ) and goal distribution p ( g ) .
We first define the expected goal-conditioned state-action reward r ( s, a, g ) =
E s ′ ∼ p ( ·| s,a ) r
( s ′ , g ) , and the expected state-action reward r ( s, a )
=
E g ∼ p
g
( · ) r ( s, a, g ) .
In practice, due to the inaccuracy of transition model, we can only query the following reward estimation at certain state-action pair: r ( s, a, g ) =
E s ′ ∼ p
θ ( ·| s,a, G ) r
( s ′ , g ) , r ( s, a )
=
E g ∼ p
g
( · ) r ( s, a, g ) .
Then we consider the distribution of the goal g ∼ p g ( · ) , which is supported on the state space S .
Based on Algorithm 1, our interventional data is collected by the MPC that maximizes the expected discounted cumulative reward from learned dynamics.
Thus, we could denote the interventional distribution of state (depending on the current policy π ) in the data buffer as p I sπ , s ∼ p I sπ ( · ) which is also supported on the state space S .
Proof of Lemma 3.
Assume our planning algorithm has an infinite planning horizon, with the optimal transition dynamics and optimal policy, the action-value function Q ∗ can be expressed as:
[Equation]
The estimation of action value function ˆ Q ( s t , a t ) =
Q ˆ πθ, G ( s t , a t ) can be written as:
[Equation]
The policy by MPC in algorithm 1 can be deducted by: ˆ π ( s t ) =
arg max a t ∈A ˆ Q ( s t , a t ) , let s
= s , and we could derive value function under the MPC policy as follows:
[Equation]
where D TV ( p I sπ , p g ) is the total variation distance between the marginal state distribution p I sπ in the data buffer, as well as the goal distribution p g , both of which share the same support.
■
In addition, we could define a more general form of goal-conditioned reward as based on the distance: r ( s, g )
= 1 − d ( s ′ , g ) .
Where D is a (normalized) distance measure between two vectors in the state space,
s.t. ∀ s, g ∈ S , 0 ≤ d ( s, g ) ≤ 1 .
For instance, if we pick d ( s, g ) = 1 ( s ̸ = g ) , the derived reward under this distance measure will go back to the reward function defined in section 2.1.
By defining a (normalized) ℓ p distance between s’ and g, d ( s, g ) =
[Equation]
, we can also shape a continuous form of goal-conditioned step reward r ( s, g ) between 0 and 1.
Notice that all the Euclidean-based distances are all valid metrics with symmetry, non-negativity, the identity of indiscernibles, and the triangle inequality.
With such a definition, the estimated value function will fit in with:
[Equation]
where W is some Wasserstein distance between marginal state distribution and goal distribution.
Therefore, optimizing the Q value is equivalent to minimizing an upper bound for some types of the statistical distance between goal distribution and target distribution.
For the term related to policy in (4), we can define the goal-conditioned policy distribution as:
[Equation] [Equation]
As a result, arg max π (cid:80) T − 1 t =0 log π θ ( a t | s t , s ∗ , G ) =
arg max π (cid:80) T − 1 t =0 Q ( s t , a t )
However, the real
Q ( s t , a t ) is intractable, so we alternatively optimize the ˆ Q ( s t , a t ) at each time step.
Next, we’ll start to derive a bound between ˆ Q ( s, ˆ π ( s )) and Q ( s, π ∗ ( s ))
Proof of Lemma 2.
For simplicity, we denote the learned transition function ˆ p ( s ′ | s, a ) =
p θ ( s ′ | s, a, G ) , which is ϵ m -approximate dynamics, D TV (ˆ p, p ) =
∥ ˆ p ( s ′ | s, a ) − p ( s ′ | s, a )
∥ ∞ ≤ ϵ m ,
Firstly, we show by value iteration that the estimated value function ˆ V ( s ) will converge to V ( s ) :
Assume exists K > 0 , s.t. ∀ k > K , ∥ ˆ p
[Equation]
s
[Equation]
|
[Equation]
s
[Equation]
p
[Equation]
s
[Equation]
Given the result of the Bellman Contraction,
[Equation]
Based on the definition of greedy policy in planning: ˆ π ( s ) = arg max a ∈A ˆ Q ( s, a )
[Equation]
we can derive the inequality:
[Equation]
Then let s be the state with the largest value error
[Equation] [Equation]
Since r ( s, g ) ∈ [0 , 1]
[Equation]
the value function V ( s ) ∈ [0 , 11 − γ ] , also by ∥ ˆ p ( s ′ | s, ˆ π ( s )) − p ( s ′ | s, ˆ π ( s ))
∥ ≤ ϵ , we have
[Equation]
We already analyzed the state s with the largest value error, and it’s sufficient to show:
[Equation]
[Equation]
By combining ∥ V π ∗ ( s ) − V ˆ π ( s ) ∥ ∞ on both sides, we have
[Equation] [Equation]
■
A.4 Causal Discovery A.4.1 Assumptions of Causality
Assumption 2 (Markov property) .
Given a DAG G and a joint distribution P X , this distribution is said to satisfy
• (i) the global Markov property with respect to the DAG G if
[Equation]
for all disjoint vertex sets A , B , C .
The symbol independent G denotes d-separation.
• (ii) the local Markov property with respect to the DAG G if each variable is independent of its non-descendants (without its parents) given its parents, and • (iii) the Markov factorization property with respect to the DAG G if
[Equation]
where we assume that P X has a density p .
Assumption 3 (Faithfulness) .
Consider a distribution P X and a DAG G , P X is faithful to the DAG
G if we know
[Equation]
for all disjoint vertex sets A , B , C .
A.4.2 KL Divergence as Sparsity Regularization
Similar to the assumption in Factorized MDP, the existence of a causal relationship between two arbitrary entities among x is can also be treated as independent.
Therefore, we construct the prior distribution p ( G ) as independent Bernoulli Distribution in the transition causal graph.
[Equation]
41) where G ij represents the edge from i-th node in source node set U
= {A ∪ S} to the j-th node in target node set V = {S ′ } in the bipartite transition causal graph.
On the other hand, for the variational posterior q ( G| τ ) , for the discovered transition causal graph, it needs to satisfy two constraints: (i) q
( G| τ ) needs to be a DAG, denoted Q DAG , and more specifically, a bipartite graph.
We denote such subset of DAG as Q Bi , (ii) q
( G| τ ) needs to be as sparse as possible.
Common score-based causal discovery works use two regularization terms, DAGNess and ℓ 1 regularization to constrain the discovered causal graph in the constraint set, while in our work, we explicitly constrain the posterior variational distribution q ( G| τ ) ∈ Q Bi ⊂ Q DAG .
We then show in the following section that by defining a certain independent Bernoulli prior p ( G ) , the KL divergence between variational posterior q ( G| τ ) and p ( G ) can be equivalent to a sparsity regularization.
According to our constraint-based causal reasoning modules, Q Bi consists of M ( M + N ) independent binary classifiers (that form a DAG) parameterized by our kernel-based independent testing modules ϕ , i.e.
[Equation]
Proof of Proposition 1.
Let the prior p ij =
ϵ G ∈ (0 , 12 ] , ∀ i ∈
[ M + N ] , j ∈
[ M ] , based on the definition above, the KL divergence term in (4) can be expanded as follows:
[Equation]
Since q ij ∈ { 0 , 1 } , lim q ij
[Equation]
ij
[Equation]
ij =
lim
q ij
[Equation]
1 − q ij
[Equation]
1 −
[Equation]
ij
[Equation] [Equation]
Therefore, the KL divergence term is equivalent to an ℓ 1 sparsity regularizer in score-based causal discovery [87].
The strength of this regularizer η = log (cid:16) 1 − ϵ G ϵ G (cid:17) ∈ [0 , ∞ ) .
The larger ϵ G in prior Bernoulli distribution indicates the smaller strength of this sparsity regularizer (e.g. when ϵ G = 12 , η = 0 ).
In the implementation of data-efficient causal discovery, we adjust the parameter of the classifier to set the strength of this sparsity constraint.
■
A.4.3 Unique Identifiability of Causal Graph
We construct our causal model based on the Factorized MDP in Assumption 1.
According to the definition, the causal graph is a directed bipartite graph, with s t , a t on the source side, and s t +1 on the target side.
For the theoretical analysis part in Section A.4.3 and A.2, we denote s t +1 as s ′ , s t as s , a t as a and x = {A ∪ S ∪ S ′ } , x ∈ R 2 M + N for simplicity.
Definition 7 (Interventional Family I ) .
For any DAG G , we define the interventional family I =
( I 1 , I 2 , · · · , I K ) .
Here I 1 := ∅ corresponds to the pure observational setting.
The joint distribution for the interventional family can be rewritten as:
[Equation]
Definition 8.
For a specific DAG G , we define M ( G ) to be the set of strictly positive densities p : R 2 |S| + |A|
→ R which satisfies:
[Equation]
where (cid:82) X j f j ( x j | PA G ( x j ))
dx j = 1 for all PA G ( x j ) ∈
X j and all j ∈ [2 M + N ] .
Definition 9.
For a specific DAG G and an interventional family I , we define
[Equation]
Such set of functions is conherent with condition of strictly positive densities in (46) as well as factorization of interventional distribution in (45).
Definition 10 ( I -Markov Equivalence Class, I -MEC) .
Two DAGs G 1 and G 2 are I -Markov equivalent
iff M I ( G 1 ) =
M I ( G 2 ) .
We denote by I − MEC ( G 1 ) the set of all DAGs which are I -Markov equivalent to G 1 , this is the I -Markov equivalence class of G 1 .
Lemma 6 (Sufficient and Necessary Conditions for I -MEC, Yang el.
al.
Suppose the interventional family I is such that
I 1 := ∅ .
Two DAGs G 1 and G 2 are I -Markov equivalent iff
their
I-DAGs G I 1 and G I 2 share the same skeleton and v-structures.
Proof of Proposition 2.
In the bipartite graph ( U , V , E ) , for the discovered graph ˆ G that is in the
I -Markov equivalence class of the ground truth causal graph, ˆ G is unique.
Based on the Lemma 6, all possible ˆ G that are I -Markov equivalent will share an identical skeleton with G ∗ , so we consider only graphs obtained by reversing edges in ˆ G .
Due to the bipartite nature of the transition causal graph defined in Definition 3, for all the v-structured colliders c ∈ C , we know that c ∈ S ′ , therefore, reversing any edge of ˆ G will harm the immorality of ˆ G , and the new graph will no longer be an I -MEC to G ∗
Therefore, ˆ G is the only graph in the I -MEC of G ∗ , i.e. ˆ G = G ∗ .
■
A.4.4 Causal Discovery Benefits from Policy Learning
In this section, we would like to show how the learned GCRL model could aid the performance of causal discovery.
Before we put the formal proof, we first list several assumptions which is quite common in causal discovery literatures [94].
Assumption 4 (Oracle Conditional Independence Test) .
The conditional independent test could tell the independence between any two variables in the causal graph.
Proof of Lemma 4.
Given the oracle conditional independence test in appendix 4, if the state distribution covers all the support of goal distribution, with abundant actions from action space, we can cover all the connections between the current state and the next states.
When D TV ( p I sπ , p g ) < ϵ g , it is sufficient to derive that p I sπ ( s ) > 0 , ∀ s ∈ Supp g , where Supp g is the support set of the goal distribution p g .
We then discuss the three possible circumstances under such condition:
• Case 1: Both source state and target state distribution in the buffer are fully supported on Supp g .
In this case, given our Assumption 4 and abundant samples, our causal discovery q ϕ ( G| τ ) will correctly classify all the edges in the transition causal graph.
• Case 2: Only the target state distribution is supported on Supp g , while the source side leaves away from the goal node.
In this case, the independent tests may not be able to distinguish the (in)dependence relationship between goal nodes and other state nodes, SHD ( ˆ G , G ∗ )
≤ |S| − 1 .
• Case 3: Only source state is supported on Supp g , while the target side leaves away from the goal node.
This case corresponds to the case where some initial states hit the goal, while the learned transition model and policy fail to guide the future states to the goal.
The causal discovery model ϕ may falsely classify the edges from all the source states (except the source goal state) towards the target goal states.
Thus SHD ( ˆ G , G ∗ ) ≤ |S| − 1 .
In conclusion, for all the three cases that satisfy D TV ( p I sπ , p g ) ≤ ϵ g , we have
[Equation]
(48) thus
[Equation] [Equation]
■
A.5 Overall Performance Guarantee of Iterative Optimization
Based on all the derivation from previous sections, we finally give out the proof of the overall performance of our proposed iterative optimization in GRADER .
Proof of Theorem 1.
Let d max = max s 1 ,s 2 ∈S ∥ s 1 − s 2 ∥ 2 , d θ =
∥ ˆ s ′ ( θ ) − s ′
∥ 2 , then the log likelihood term becomes
[Equation]
In the model learning part, since we take the log space, we have log p θ ( s ′ | s, a ) =
( d max − d θ ) − C .
We neglect the constant term C when deriving the bound.
Without the loss of generality, we set p θ ( s ′ | s, a ) =
exp( d max − d θ ) , log p θ ( s ′ | s, a ) =
d max − d θ in (4).
As d max − d θ ≥ 0 , we have the
Lipchitz L ≤ 1 of log function,
[Equation]
Based on Lemma 2 that is derived in Appendix A.3, we have the policy learning term
[Equation]
For the KL divergence term, if the goal distribution satisfies ϵ g > γ 1 − γ ϵ m , the following conditions hold:
[Equation]
According to Lemma 3 and the condition that V ( s ) ∈ [0 , 11 − γ ] ,
[Equation]
where t ∗ is the shortest time step to reach the goal.
Here we assume t ∗ = 1 for optimal policy in the theoretical design part, while in practice, the bound may get loosened when larger t ∗ or smaller γ .
Since D TV ( p I sπ , p g ) ≤ ϵ g , according to Lemma 4 proved in Appendix
A.4, we have
[Equation]
∗
[Equation]
∞ = log
[Equation] [Equation]
[Equation] [Equation]
≤ log
[Equation]
ϵ
[Equation] [Equation]
∞ = log
[Equation]
max
[Equation]
≤ log
[Equation]
Finally
[Equation]
we can derive the overall performance guarantee as follows:
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
B Additional Experiment B.1 Overall Performance
The overall performance results corresponding to the Table 1 for Stack and Unlock environments are shown in Figure 7 and Figure 8.
In all Stack experiments, we find that the advantage of GRADER over other methods is small.
The reason is that this task is simple and the true causal graph only contains 7 nodes as shown in
Figure B.2.
Due to the simple causal graph, even the Offline random policy can obtain the true causal graph, thus there is almost no difference between the discovery efficiency between GRADER and
Offline as shown in the right part of Figure 7.
In the Unlock-I experiment, there is no gap between GRADER and Full, which means the causal graph may not have many contributions to solving this task.
However, there are large gaps in
Unlock-S and Unlock-C settings since indicating that the causal graph helps the model obtain better generalizable performance.
As for the Offline method, since the causal graph is wrongly discovered, the performance is bad in all three settings.
B.2 Causal Graph Analysis
Since the environments we designed have clear and explicit causality, we can get the true causal graph with human analysis.
We plot the true causal graphs corresponding to the three environments in Figure 9, where the semantic meanings of all nodes are explained in Appendix C.2.1.
We observe that the causal graphs are sparse with very few edges, indicating that non-causal methods that use the full graph may import redundant or even wrong information.
B.3 Distance between Goal and State Distribution
In Figure 10, we empirically show the upper bound proved in (28), which describes the TV distance between the goal distribution and the state distribution collected from the GRADER policy.
We use 10 trails and plot the mean and standard derivation of the distance.
We observe that the distance becomes smaller as the policy gets better in
GRADER.
This supports our statement that the planning module helps to collect better data samples, which will be used in the causal discovery module.
We also plot the distance with a random policy, which is always large since the goal is not easy to be achieved by random actions.
B.4 Task Performance of Chemistry Experiment
In the main context, we only show the discovery results of the Chemistry experiment.
We provide the results of task performance in this section.
The downstream task is to change the color of nodes to match given colors within maximum steps ( T = 10 ).
A reward r = 1 is received if all colors are matched.
Results are reported with 200 episodes.
We use planning horizon H = 5 .
We provide the
RL downstream task results in Table 3 (ID setting) and Table 4 (OOD setting).
The testing reward is shown in Figure 11.
The graphs in the ID setting have 10 nodes while those in the OOD setting have 5 nodes.
In the ID setting, we randomly sample the target colors in the goal.
In the OOD setting, we set the target colors of all nodes to the same color during the training to create spurious correlations, then randomly set the target colors during testing.
[Table]
C Additional Information C.1 Details about Conditional Independence Test
In Algorithm
[Table]
we describe the discovery of causal graph with edge inference e ij ← q ϕ ( ·|B , η ) implemented by conditional independent test.
We ignore the details about the test process in the main context and thus provide more details in this section.
For discrete variables, we use Pearson’s chi-square test 1 , which is a statistical test applied to sets of categorical data to evaluate how likely it is that any observed difference between the sets arose by chance.
In our experiment, we use the implementation provided by package Scipy 2 .
We first define the null hypothesis, which is true when two random variables are statistically independent.
These two variables have samples stored in a contingency table O , which has c columns and r rows.
Then, the "theoretical frequency" for a cell is:
[Equation]
where N is the total sample size in the table, O i,j is the sample size of cell ( i, j ) .
Then, we can calculate the value of the test statistic:
[Equation]
Now, we can obtain a p-value (falls in [0 , 1] ) that indicates the significance of this statistic follows the χ 2 distribution from chi-square probability 3 .
We compare this p-value with a threshold η and reject
[Table]
the null hypothesis if the p-value is smaller than η .
Therefore, the larger we set η , the more likely we find the two variables are dependent.
This testing process is summarized in Algorithm
[Table]
If the two variables are continuous, we cannot use the above statistical test anymore.
We turn to a more advanced test method proposed in [40].
The general idea is that if P ( X | Y, Z ) =
P ( X, Y ) ,
Z is not useful as a feature to predict X .
To achieve this, the authors propose to use decision tree regression to predict Y using both X and Z, and also using Z only.
Input: A contingency table O with samples for two variables X and Y .
Define Null hypothesis: X and Y are independent.
Calculate p i · = (cid:80) cj
=1 O i,j N and p i · = (cid:80) ri
=
O i,j N
Calculate expected frequencies E ij =
N p
i · p · j
Calculate the chi-square statistic χ 2 = (cid:80) ri =1 (cid:80) cj
=
( O i,j − E i,j ) 2 E
i,j
Obtain p-value p from chi-square probability if p < η then
Reject the Null hypothesis, i.e., X and Y are dependent.
C.2 Experiment Details C.2.1 Environment Design
More details about the design of the environments are summarized below:
Stack : Manipulation is important for house-holding and factory assembly.
Sometimes, the color of the object is not relevant to the task but may leak information by sharing spuriousness with the task.
Also, the goal could compose several previously seen goals such as repeating similar actions.
Totally, we have 5 different shapes and 5 different colors and the goals are some combinations of the colors and shapes.
At each step, the agent can either stack an object with a chosen color and shape or stop stacking.
The state is the colors and shapes of all current objects.
The agent receives a positive reward when the goal is achieved and a punishment if it stacks a new object.
Unlock : Collecting specific objects to fulfill required conditions is useful for mobile robots.
The causality in this environment exists between the key and the door.
The action contains six operations, including four-direction movements (Move), pick key (Pick Key), and open door (Open Door).
The state is the position of the agent, the position of the key, and the status of the door.
In the first generalization setting, we intentionally create a spurious correlation between the position of the key and the door.
If the agent figures out that key can open the door no matter what its position is, it will ignore the spurious correlation.
In the second generalization setting, we increase the number of door from one to two.
This setting contains two same sub-tasks and can be used to test the compositional generalization.
Crash : The causality in this environment mainly exists between the pedestrian (Ped), the ego vehicle (Ego), and another vehicle (Car 1) [95].
The collision between Ped and Ego only happens when the view of Ego is blocked by Car 1.
To make this happen, we design a rule-based AV, which will brake if it detects any obstacles within a certain distance.
Therefore, if the pedestrian directly hits the AV, the AV will stop and the crash will not happen.
To make this task difficult, we also place two other vehicles (Car 2 and Car 3) on the scene but they will not interrupt the crash scenario.
The agent can control the acceleration and steering of Ped, Car 1, Car 2, and Car 3.
The state is the position and velocity of all objects plus the status of whether a collision happens.
To create a spurious correlation, we fix the initial distance between Ego and Ped to a constant since this creates a shortcut for the feature extractor.
However, remembering this distance is not enough since we change the initial distance in the testing stage.
Chemistry : Please refer to [43] for more details.
[Table]
C.2.2 Model Structures and Hyper-parameters
Since different nodes have different dimensions, we design a set of encoders E j and a set of decoders
D j to convert the dimension of features.
Thus, the entire model structure is
[Equation]
We list all important hyper-parameters in the implementation for three environments in Table 6.
C.3 Broader Social Impact and Additional Limitation C.3.1 Broader Social Impact
We identify several important social impacts of our proposed method, including both positive and potential negative impacts:
1) Incorporating causality into reinforcement learning methods increases both the interpretability and generalizability of artificial intelligence, which helps users easily check the working progress of agents and the source of failures.
2) Insufficient data and training may cause flawed causal graphs, which may lead to a wrong understanding of the causation of the task.
This wrong understanding of the task may cause risky and irrational actions of agents.
The discovered causal graph could be accessed and modified by users to manipulate the behaviors of agents on purpose.
If the task contains private information, the discovered causal graph may cause privacy issues when the graph is interpreted by other users.
To mitigate the potential negative societal impacts mentioned above, we encourage research to follow these instructions:
1) People should always check the convergence of the causal discovery step and verify the discovered causal graph with domain knowledge.
The discovered causal graph should be frequently checked and verified with the training data to ensure its correctness.
The causal graphs also need to be encrypted and only accessible to algorithms and trustworthy users.
C.3.2 Additional Limitation
Causal discovery methods.
The gradient-based discovery method are widely investigated recently for large datasets since they have good scalability.
However, these methods also require lots of training data to converge.
In Online RL, we don’t have enough data at the beginning of training.
Thus, constraint-based methods are more suitable for causal RL tasks.
Although our constraint-based causal discovery does not scale as well as the score-based methods, our proposed independence tests achieve a time complexity of Ω( | S | ( | S | + | A | )) , which is tolerable for most RL problems with lower dimensional state space.
Empirical studies also show that our independent tests enjoy better data efficiency.
[Table]
Assumptions in our theoretical analysis.
Faithfulness and Markov properties are commonly used in causal discovery literature such as [87, 39].
It is claimed in [39] that the oracle independent test can be ensured by the satisfaction of Markov property and faithfulness.
Recent work [94] also assumes the oracle of conditional independent test in its Assumption 2.1.
Practically, the oracle test can be implemented with certain sub-linear sample complexity, as is investigated in [41].
In reinforcement learning tasks, agents interact with the environment by doing interventions, which is achieved by assigning values to action nodes.
Then, the intervention results are reflected by the states.
Under fully observable Markov settings, the value of these states contains all information about the intervention.
Thus, our RL setting usually satisfies the assumptions we use in the theoretical proof.