# Keras Sequential in DL4J

**URL:** <https://community.konduit.ai/t/keras-sequential-in-dl4j/2455>\
**Category:** DL4J\
**Created:** [April 7, 2023, 2:14pm UTC](https://community.konduit.ai/t/keras-sequential-in-dl4j/2455 "2023-04-07T14:14:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://community.konduit.ai/u/thomas)\
**Post date:** [April 7, 2023, 2:14pm UTC](https://community.konduit.ai/t/keras-sequential-in-dl4j/2455/1 "2023-04-07T14:14:51Z")

</div>

Is there anything native inside dl4j or samediff to build a network like this:

model = Sequential()  
model.add(Dense(units=64, activation=‘relu’, input\_dim=100))  
model.add(Dense(units=10, activation=‘softmax’))

to pack a ffn inside a sequential network model. as i understood with RNNToFeedforwardPreProcessor i get only a fully connected complet vector of all steps (time \* veclen) instead of only veclen sized weights.

Best regards

Thomas

---

<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:** [April 7, 2023, 2:18pm UTC](https://community.konduit.ai/t/keras-sequential-in-dl4j/2455/2 "2023-04-07T14:18:44Z")

</div>

@thomas could you clarify? Sequential in dl4j is multilayer network. This is just 1 dense layer and 1 output layer. Each of these can hold an activation function as a parameter.

It’s a bit late for me but if you can clarify a bit and need more help I can post an example tomorrow.

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://community.konduit.ai/u/thomas)\
**Post date:** [April 8, 2023, 3:12pm UTC](https://community.konduit.ai/t/keras-sequential-in-dl4j/2455/3 "2023-04-08T15:12:11Z")

</div>

i only try to get the dense layer with a vector length for 1 step and not the whole sequence. as i understood in the api documentation inside of dl4j with an DenseLayer and RnnToFeedForwardPreprocessor i would receive a complete connected time series not only 1 time step.

Best regards and no hurry

EDIT: Or could i also use an RnnOutputLayer as a hidden dense layer inside an model. would be the same on math sides like i understand.

---

<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:** [April 8, 2023, 9:21pm UTC](https://community.konduit.ai/t/keras-sequential-in-dl4j/2455/4 "2023-04-08T21:21:53Z")

</div>

@thomas preprocessors are automatically added if you use setInputType.

Just declare the layers you want (in this case DenseLayers)  
If you are trying to use the last dense layer for output use an output layer instead (equivalent but has all of the needed functionality for loss functions)

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://community.konduit.ai/u/thomas)\
**Post date:** [April 9, 2023, 10:33am UTC](https://community.konduit.ai/t/keras-sequential-in-dl4j/2455/5 "2023-04-09T10:33:49Z")

</div>

Thanks i will try with setInputType
