# Flux.jl versus Lux.jl

**URL:** <https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499>\
**Category:** General Usage\
**Created:** [May 8, 2023, 6:40pm UTC](https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499 "2023-05-08T18:40:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 8, 2023, 6:40pm UTC](https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499/1 "2023-05-08T18:40:18Z")

</div>

The Scientific machine ecosystem in Julia now recommends Lux.jl as opposed to Flux.jl. What are the use cases in general where Flux.jl is better than Lux.jl? Looking at the questions on Discourse, I have the impression that most of the work still uses `Flux`. Is this true?

I tried to find complex examples of networks using `Lux.jl` and came up short? Where can I find these? For example, have transformers been implemented with Lux? How about GRUs? LSTMs? Attention models?

Thanks.

Gordon

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [May 8, 2023, 6:55pm UTC](https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499/2 "2023-05-08T18:55:07Z")

</div>

The documentation explains some here [Why use Lux over Flux?](https://lux.csail.mit.edu/dev/introduction/overview/)

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 8, 2023, 7:22pm UTC](https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499/3 "2023-05-08T19:22:08Z")

</div>

Thanks.

I read that DiffEqFlux extends Lux. Is it 100% implemented in Lux? If not, why not? If yes, shouldn’t the module then be renamed `DiffEqLux`? I have on this site that coding good names is important. Using the substring Flux for a library that extends Lux is confusing to me.

Thanks.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 9, 2023, 9:49am UTC](https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499/4 "2023-05-09T09:49:25Z")

</div>

> [@erlebach](#):
>
> I read that DiffEqFlux extends Lux. Is it 100% implemented in Lux? If not, why not? If yes, shouldn’t the module then be renamed `DiffEqLux`? I have on this site that coding good names is important. Using the substring Flux for a library that extends Lux is confusing to me.

> <https://github.com/SciML/DiffEqFlux.jl/pull/820>
>
> \- \[X\] remove Flux parts and use \`Lux.transform\`
> \- \[\] clean any Flux related pa…tterns (re, ...)
> \- \[\] convert it to an extension
> 
> I guess now \`DiffEqFlux\` is actually \`DiffEqFLux\`. 😏 (F stands for "for")

> I guess now `DiffEqFlux` is actually `DiffEqFLux` . 😏 (F stands for “for”)

It will still take in Flux neural networks, but convert them to Lux (because the two are interchangeable). That makes the code simpler and improves performance. We don’t plan to drop the Flux frontend, everything will still allow users to give us Flux models if they so choose. But, for documented reasons, our tutorials will not suggest that people use Flux, and we will convert Flux models to Lux models internally.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 9, 2023, 10:57am UTC](https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499/5 "2023-05-09T10:57:12Z")

</div>

🙂 I thought I was being original.

---

<div class="post-metadata">

**Author:** ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Post date:** [May 10, 2023, 6:44am UTC](https://discourse.julialang.org/t/flux-jl-versus-lux-jl/98499/6 "2023-05-10T06:44:13Z")

</div>

disclaimer: I’m a Flux’s maintainer and didn’t tinker much with Lux, so probably I’m a little biased.

I would pick Flux for any typical deep learning, and use Lux for NeuralODE-like tasks instead.  
Flux has been around for longer, is maintained by more people, and has a larger ecosystem of packages built on top of it, e.g.

> **[GitHub - chengchingwen/Transformers.jl: Julia Implementation of Transformer...](https://github.com/chengchingwen/Transformers.jl)**
>
> Julia Implementation of Transformer models. Contribute to chengchingwen/Transformers.jl development by creating an account on GitHub.

> **[GitHub - FluxML/Metalhead.jl: Computer vision models for Flux](https://github.com/FluxML/Metalhead.jl)**
>
> Computer vision models for Flux. Contribute to FluxML/Metalhead.jl development by creating an account on GitHub.

> **[GitHub - CarloLucibello/GraphNeuralNetworks.jl: Graph Neural Networks in Julia](https://github.com/CarloLucibello/GraphNeuralNetworks.jl)**
>
> Graph Neural Networks in Julia. Contribute to CarloLucibello/GraphNeuralNetworks.jl development by creating an account on GitHub.

> **[GitHub - FluxML/FastAI.jl: Repository of best practices for deep learning in...](https://github.com/FluxML/FastAI.jl)**
>
> Repository of best practices for deep learning in Julia, inspired by fastai - GitHub - FluxML/FastAI.jl: Repository of best practices for deep learning in Julia, inspired by fastai

The main difference with Lux is that Flux model has stateful layers (like pytorch) and Lux passes the state around instead (like Flax). I think you won’t find many other differences, Lux borrows heavily from Flux and both packages rely on the same package in the julia ecosystem, e.g. NNlib.jl, Optimisers.jl, Zygote.jl (all maintained by the Flux people) and then CUDA.jl etc…
