# ComputationGraph or non-sequential example?

**URL:** <https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738>\
**Category:** DL4J\
**Created:** [January 4, 2022, 7:45am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738 "2022-01-04T07:45:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgoderis](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kgoderis](https://community.konduit.ai/u/kgoderis)\
**Post date:** [January 4, 2022, 7:45am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738/1 "2022-01-04T07:45:28Z")

</div>

I have the need to create a non-sequential model using LSTM layers. Is there an example that shows how to combine ComputationGraph and regular layers into a model?

When I google this, I get references to examples on the deeplearning4j wiki, but those links do not work anymore.

Tx  
K

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [January 4, 2022, 7:47am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738/2 "2022-01-04T07:47:13Z")

</div>

@kgoderis could you clarify where you were looking? If you were on [https://deeplearning4j.org/](https://deeplearning4j.org/) that is not the place to look anymore. Please use [https://deeplearning4j.konduit.ai/](https://deeplearning4j.konduit.ai/) if you still have questions after that please go ahead and follow up.

I don’t quite know what you’re looking for but all of our examples are here: [GitHub - eclipse/deeplearning4j-examples: Deeplearning4j Examples (DL4J, DL4J Spark, DataVec)](https://github.com/eclipse/deeplearning4j-examples)

---

<div class="post-metadata">

**Author:** ![kgoderis](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kgoderis](https://community.konduit.ai/u/kgoderis)\
**Post date:** [January 4, 2022, 7:54am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738/3 "2022-01-04T07:54:53Z")

</div>

Well, I looked at \*.ai in the first place.

Growing the forum I understand that you can freely mix AddLayer and AddVertex as long as they are named/labelled correctly.

A kind of network is to have a LSTM → LSTM → SomeLayer on the right, and DenseLayer → … → SomeLayer at the left, e.g. merge 2 sequential branches into 1 at a given point, and from that have SomeLayer → DenseLayer → … → OutputLayer

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [January 4, 2022, 10:03am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738/4 "2022-01-04T10:03:59Z")

</div>

@kgoderis You might want to look at this page for a comprehensive explanation:

> **[Computation Graph](https://deeplearning4j.konduit.ai/deeplearning4j/reference/computation-graph#computation-graph-some-example-use-cases)**
>
> How to build complex networks with DL4J computation graph.

Use cases are here ^

You have the basic idea that the dl4j api has 2 kinds: a computation graph (harder to use but allows more general architectures) and the sequential kind (the multilayernetwork)

There’s also samediff if you’re looking for something pytorch like and is generally .  
See: [Quickstart - Deeplearning4j](https://deeplearning4j.konduit.ai/samediff/tutorials/quickstart)

Could you clarify what the docs or examples are missing so maybe we can help you better in the future? Thanks for the input!

---

<div class="post-metadata">

**Author:** ![kgoderis](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kgoderis](https://community.konduit.ai/u/kgoderis)\
**Post date:** [January 5, 2022, 7:27am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738/5 "2022-01-05T07:27:36Z")

</div>

Indeed, that was my initial thinking when going through the documentation. It was not clear that both kinds can be combined. Just did a quick search, came across this link ([https://deeplearning4j.konduit.ai/models/computationgraph#example-2-multiple-inputs-and-merge-vertex](https://deeplearning4j.konduit.ai/models/computationgraph#example-2-multiple-inputs-and-merge-vertex)) which is seemingly not working anymore. Just as an example

What would really helping is making it quite explicit how ones goes beyond sequential models, and how to combine them with Vertexes and also custom SameDiff layers. In essence, the question that always pop-up with me when reading an interesting ML paper is : how to implement this? Often people introduce new types of layers, or variations on an “old” theme (e.g. how easy is it to subclass an existing layer like LSTM or whatever)

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [January 5, 2022, 7:37am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738/6 "2022-01-05T07:37:08Z")

</div>

> [@kgoderis](#):
>
> Just did a quick search, came across this link ([https://deeplearning4j.konduit.ai/models/computationgraph#example-2-multiple-inputs-and-merge-vertex](https://deeplearning4j.konduit.ai/models/computationgraph#example-2-multiple-inputs-and-merge-vertex)) which is seemingly not working anymore.

> **[Computation Graph](https://deeplearning4j.konduit.ai/deeplearning4j/reference/computation-graph#example-2-multiple-inputs-and-merge-vertex)**
>
> How to build complex networks with DL4J computation graph.

Due to a reorganization of the docs (and because gitbook changes links without any regard for breaking links or good tooling to manually take care of this 😕 ) many links got broken. But at least the doc search should bring you to the correct place.

---

<div class="post-metadata">

**Author:** ![kgoderis](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kgoderis](https://community.konduit.ai/u/kgoderis)\
**Post date:** [January 5, 2022, 7:42am UTC](https://community.konduit.ai/t/computationgraph-or-non-sequential-example/1738/7 "2022-01-05T07:42:34Z")

</div>

Yes, you are right. I will start by rereading all the wiki pages since they seemingly answer what I was after
