Answers.Body: <p>Graph neural networks, of which GCNs are a specific type, are able to handle arbitrary graphs as input. GNNs operate first over &quot;neighborhoods&quot; of nodes to compute individual node representations and then optionally apply a pooling function to reduce these to a single graph-level representation that can be used in classification. This means that GNNs work &quot;locally&quot; and do not contain implicit assumptions about the graph topology.</p>
  <p>For example, the update equation for a given node's representation in a GCN can be written as</p>
  <p><span class="math-container">$$h_v^{t+1} = \sigma\left({\bf W}^{t+1} \sum_{u \in \mathcal{N}_v} {\bf L}_{uv}~ h_u^t \right) $$</span></p>
  <p>where <span class="math-container">$h_v^l$</span> is the representation of node <span class="math-container">$v$</span> at update <span class="math-container">$t$</span>, <span class="math-container">$\sigma$</span> is an activation function, <span class="math-container">${\bf W^{t}}$</span> is a weight matrix, <span class="math-container">${\bf L_{uv}}$</span> is the value of the graph Laplacian (which is a matrix) at nodes <span class="math-container">$u$</span> and <span class="math-container">$v$</span>, and finally <span class="math-container">$\mathcal{N}_v$</span> is the neighborhood of <span class="math-container">$v$</span>. Looking at this expression it becomes clear that the value of the summation is always of the same dimension as <span class="math-container">$h$</span>, no matter how you define the neighborhood <span class="math-container">$\mathcal{N}_v$</span>. So you are correct that as long as the node representation size is static, the network can take arbitrary graphs as input.</p>
  <p>I highly recommend <a href="https://arxiv.org/abs/1912.12693" rel="nofollow noreferrer">this tutorial paper on GNNs</a>, which I used when first learning about them. Section 2.3 specifically answers your question and discusses how things like cycles and non-positional graphs are handled.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-20T17:43:51.937Z
Answers.LastActivityDate: 2020-11-20T17:43:51.937Z
Answers.UserDisplayName: primussucks
Body: <p>Quick questions to see whether I understand GCNs correctly.</p>
  <p>Is it correct that, if I have trained a GCN, it can take arbitrary graphs as input, assuming the feature size is the same?</p>
  <p>I can't seem to find explicit literature on this.</p>
  
Tags: <geometric-deep-learning><graphs><graph-neural-networks>
Title: How does a GCN handle new input graphs?
UserDisplayName: Nikita Makarov
ThreadText: # How does a GCN handle new input graphs?
  
  (Asked by: username_0 on 2020-11-17)
  
  Quick questions to see whether I understand GCNs correctly.
  
  Is it correct that, if I have trained a GCN, it can take arbitrary graphs as input, assuming the feature size is the same?
  
  I can't seem to find explicit literature on this.
  
  **Tags:** geometric-deep-learning, graphs, graph-neural-networks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-20. Score: 1
  
  Graph neural networks, of which GCNs are a specific type, are able to handle arbitrary graphs as input. GNNs operate first over "neighborhoods" of nodes to compute individual node representations and then optionally apply a pooling function to reduce these to a single graph-level representation that can be used in classification. This means that GNNs work "locally" and do not contain implicit assumptions about the graph topology.
  
  For example, the update equation for a given node's representation in a GCN can be written as
  
  $$h\_v^{t+1} = \sigma\left({\bf W}^{t+1} \sum\_{u \in \mathcal{N}\_v} {\bf L}\_{uv}~ h\_u^t \right) $$
  
  where $h\_v^l$ is the representation of node $v$ at update $t$, $\sigma$ is an activation function, ${\bf W^{t}}$ is a weight matrix, ${\bf L\_{uv}}$ is the value of the graph Laplacian (which is a matrix) at nodes $u$ and $v$, and finally $\mathcal{N}\_v$ is the neighborhood of $v$. Looking at this expression it becomes clear that the value of the summation is always of the same dimension as $h$, no matter how you define the neighborhood $\mathcal{N}\_v$. So you are correct that as long as the node representation size is static, the network can take arbitrary graphs as input.
  
  I highly recommend [this tutorial paper on GNNs](https://arxiv.org/abs/1912.12693), which I used when first learning about them. Section 2.3 specifically answers your question and discusses how things like cycles and non-positional graphs are handled.
  
  
  ---
  
  