Removing A Node
Introduction
This example first generates a basic model, and then removes a node in the middle of the model, and reconnects the remaining nodes in the graph.
In order to remove a node, we replace the output tensors of its input node with its own outputs, and then remove its own connection to its outputs.
Node Removal Basics
For example, for a graph with the following structure:
Node0
|
Tensor0
|
Node1
|
Tensor1
|
Node2
|
Tensor2
In order to remove Node1,
- Change
Node0's outputs to[Tensor1]instead of[Tensor0]. - Change
Node1's outputs to[]instead of[Tensor1]
The resulting graph looks like this:
Node0
|
Tensor1 Tensor0
| |
Node2 Node1
|
Tensor2
Note that Node1 remains in the graph.
This is easily remedied by running the cleanup() function.

