# Flux came a long way

**URL:** <https://discourse.julialang.org/t/flux-came-a-long-way/62288>\
**Category:** Machine Learning\
**Tags:** flux\
**Created:** [June 2, 2021, 4:27pm UTC](https://discourse.julialang.org/t/flux-came-a-long-way/62288 "2021-06-02T16:27:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander-Barth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander-barth/32/3692_2.png) [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Post date:** [June 2, 2021, 4:27pm UTC](https://discourse.julialang.org/t/flux-came-a-long-way/62288/1 "2021-06-02T16:27:04Z")

</div>

I was following the [Keras presentation](https://www.youtube.com/watch?v=FCz9m4T0DI0) at the Google IO 2021 by  
Martin Gorner and François Chollet (creator of Keras) about convolutional varitional autoencoder (VAE). As a way to learn about VAE, I re-implemented the notebook in Flux.jl.

I run into some small issues about asymmetric padding ([CuDNN: Support for asymmetric padding? · Issue #128 · JuliaGPU/CUDA.jl · GitHub](https://github.com/JuliaGPU/CUDA.jl/issues/128)).  
My work-around was to do some manual cropping.

In the end, I got equivalent results than the Keras implementation from François Chollet (the model has exactly the same number of parameters, and results are very similar, but not exactly the same as the network is initialised randomly).

But to my surprise, Flux.jl (2.6 second per epoch without compilation) was about twice as fast as Keras with Tensorflow back-end (5.05 seconds per epoch) on the same hardware (GeForce RTX 3080). The Keras notebook shows two ways to implement a VAE, but both have the same performance. It is clear that MNIST is a very small dataset and it would be interesting to know the performance with larger datasets.

As I posted before some [issues](https://discourse.julialang.org/t/upsampling-in-flux-jl/25919/7) with reaching similar performance between Flux.jl and Tensorflow, I thought this would be an interesting follow-up.

Here is my Flux.jl code

> <https://gist.github.com/Alexander-Barth/e9d0b19e274b56baa1913dfb6098e23a>

Here is the Keras code:

> **[Google Colaboratory](https://colab.research.google.com/drive/1Y4bVbikXACZfZr1VAWDo8Qvnu3ya7yfK)**

Let me know in case there is a problem with my Flux.jl code, but at least the Keras implementation should be good! 😀

Kudos to Flux and CUDA developpers!

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [June 3, 2021, 12:45am UTC](https://discourse.julialang.org/t/flux-came-a-long-way/62288/2 "2021-06-03T00:45:19Z")

</div>

> [@Alexander-Barth](#):
>
> got equivalent results than the Keras implementation from François Chollet (the model has exactly the same n

Nice to hear. I also tried Flux recently and it was pretty decent. But then i was just doing a GLM and the glm in R is fast enough

---

<div class="post-metadata">

**Author:** ![Alexander-Barth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander-barth/32/3692_2.png) [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Post date:** [June 3, 2021, 7:02pm UTC](https://discourse.julialang.org/t/flux-came-a-long-way/62288/3 "2021-06-03T19:02:02Z")

</div>

I am wondering if GLM in R uses the GPU, or is a CPU fast enought for your case?

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [June 3, 2021, 9:12pm UTC](https://discourse.julialang.org/t/flux-came-a-long-way/62288/4 "2021-06-03T21:12:59Z")

</div>

Cpu. But the CPU one is fast enough. Same speed as my gpu implementation. Although for such a small dataset. GPU is not necessary
