# Convolutional Bayesian Neural Networks

**URL:** <https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650>\
**Category:** Machine Learning\
**Created:** [May 22, 2021, 5:03pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650 "2021-05-22T17:03:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [May 22, 2021, 5:03pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/1 "2021-05-22T17:03:40Z")

</div>

Hello, I need to implement convolutional and partly bayesian neural networks. I looked into Turing.jl but it looks like it still doesn’t provide such option. Any suggestion?

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [May 22, 2021, 5:19pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/2 "2021-05-22T17:19:14Z")

</div>

@elizavetasemenova may have some pointers

> **[A Bayesian neural network for toxicity prediction](https://www.biorxiv.org/content/10.1101/2020.04.28.065532v3.full)**
>
> Predicting the toxicity of a compound preclinically enables better decision making, thereby reducing development costs and increasing patient safety. It is a complex issue, but in vitro assays and physico-chemical properties of compounds can be used...

---

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [May 22, 2021, 5:58pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/3 "2021-05-22T17:58:24Z")

</div>

Looking at her code, she only used dense layers…

[https://github.com/elizavetasemenova/BNN\_tox/blob/master/functions.jl](https://github.com/elizavetasemenova/BNN_tox/blob/master/functions.jl)

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [May 22, 2021, 6:32pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/4 "2021-05-22T18:32:51Z")

</div>

Forgive my ignorance. Why would it matter? Isn’t Turing still just sending in parameter estimates and recieving the final outputs from the neural net?

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [May 22, 2021, 6:33pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/5 "2021-05-22T18:33:23Z")

</div>

Not that I’m doubting you. I’m just genuinely interested!

---

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [May 22, 2021, 6:40pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/6 "2021-05-22T18:40:59Z")

</div>

Yes, maybe you are right. I’m still rather new to Julia…

I was just scared from this description:

> The below code is intended for use in more general applications, where you need to be able to change the basic network shape fluidly. The code above is highly rigid, and adapting it for other architectures would be time consuming. Currently the code below only supports networks of `Dense` layers.

You can find it [here](https://turing.ml/dev/tutorials/3-bayesnn/#generic-bayesian-neural-networks)

---

<div class="post-metadata">

**Author:** ![sapo](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sapo](https://discourse.julialang.org/u/sapo)\
**Post date:** [May 22, 2021, 6:41pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/7 "2021-05-22T18:41:48Z")

</div>

I’m in the code designing phase and I have to decide which parts I have to implement in which language…

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [May 22, 2021, 7:51pm UTC](https://discourse.julialang.org/t/convolutional-bayesian-neural-networks/61650/8 "2021-05-22T19:51:35Z")

</div>

Assuming your CNN architecture doesn’t change dynamically part-way through training, the “rigid” approach shouldn’t be a problem. I’m not aware of limitations that would prevent one from using a convolutional BNN in Julia, so the best approach would be to try for yourself and report any bugs you find 🙂
