# Ape-X DQN with custom first part net

**URL:** <https://discuss.ray.io/t/ape-x-dqn-with-custom-first-part-net/864>\
**Category:** RLlib\
**Created:** [February 12, 2021, 5:58pm UTC](https://discuss.ray.io/t/ape-x-dqn-with-custom-first-part-net/864 "2021-02-12T17:58:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jogima-cyber](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jogima-cyber/32/454_2.png) [@Jogima-cyber](https://discuss.ray.io/u/Jogima-cyber)\
**Post date:** [February 12, 2021, 5:58pm UTC](https://discuss.ray.io/t/ape-x-dqn-with-custom-first-part-net/864/1 "2021-02-12T17:58:43Z")

</div>

Hi there, and thanks for this beautiful RL library ! I would like to use a residual convolutional network with batch normalization (written using pytorch) as first part of the network in an Ape-X DQN model. I’ve seen in the doc and in the examples how to create and register a custom model.  
However it is not clear whether my custom model will then be added a DQN head with dueling and other network related DQN advancement (if I’ve set them in the config) or if I have to implement them as part of my custom model.

---

<div class="post-metadata">

**Author:** ![sven1977](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sven1977/32/53_2.png) [@sven1977](https://discuss.ray.io/u/sven1977)\
**Post date:** [February 17, 2021, 8:57am UTC](https://discuss.ray.io/t/ape-x-dqn-with-custom-first-part-net/864/2 "2021-02-17T08:57:19Z")

</div>

Great question @Jogima-cyber .  
There are two options:

- If your custom model is not a child of DQNTF|TorchModel, RLlib will automatically mix-in your class into the DQNTF|TorchModel class and then create an instance of that new “wrapped” class.
- You can also directly sub-class DQNTF|TorchModel (override whatever methods you need to change, including the c’tor), in which case RLlib will not do the above auto-wrapping, but use your custom model directly (b/c it already satisfies the DQN API requirements).

---

<div class="post-metadata">

**Author:** ![Jogima-cyber](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jogima-cyber/32/454_2.png) [@Jogima-cyber](https://discuss.ray.io/u/Jogima-cyber)\
**Post date:** [February 17, 2021, 9:02am UTC](https://discuss.ray.io/t/ape-x-dqn-with-custom-first-part-net/864/3 "2021-02-17T09:02:30Z")

</div>

Thank you @sven1977 !
