|
3 | 3 | <img width="400px" src="https://raw.githubusercontent.com/FluxML/Flux.jl/master/docs/src/assets/logo-dark.png#gh-dark-mode-only"/>
|
4 | 4 | </p>
|
5 | 5 |
|
6 |
| -[![][action-img]][action-url] [](https://fluxml.github.io/Flux.jl/stable/) [](https://julialang.org/slack/) [](https://doi.org/10.21105/joss.00602) [](https://github.com/SciML/ColPrac) [![][codecov-img]][codecov-url] |
| 6 | +<div align="center"> |
| 7 | + |
| 8 | +[](https://fluxml.github.io/Flux.jl/stable/) [](https://doi.org/10.21105/joss.00602) [](https://pkgs.genieframework.com?packages=Flux) |
| 9 | +<br/> |
| 10 | +[![][action-img]][action-url] [![][codecov-img]][codecov-url] [](https://github.com/SciML/ColPrac) |
| 11 | + |
| 12 | +</div> |
7 | 13 |
|
8 | 14 | [action-img]: https://github.com/FluxML/Flux.jl/workflows/CI/badge.svg
|
9 | 15 | [action-url]: https://github.com/FluxML/Flux.jl/actions
|
|
12 | 18 |
|
13 | 19 | Flux is an elegant approach to machine learning. It's a 100% pure-Julia stack, and provides lightweight abstractions on top of Julia's native GPU and AD support. Flux makes the easy things easy while remaining fully hackable.
|
14 | 20 |
|
| 21 | +Works best with [Julia 1.8](https://julialang.org/downloads/) or later. Here's a simple example to try it out: |
15 | 22 | ```julia
|
16 |
| -] add Flux |
| 23 | +using Flux # should install everything for you, including CUDA |
| 24 | + |
| 25 | +x = hcat(digits.(0:3, base=2, pad=2)...) |> gpu # let's solve the XOR problem! |
| 26 | +y = Flux.onehotbatch(xor.(eachrow(x)...), 0:1) |> gpu |
| 27 | +data = ((Float32.(x), y) for _ in 1:100) # an iterator making Tuples |
| 28 | + |
| 29 | +model = Chain(Dense(2 => 3, sigmoid), BatchNorm(3), Dense(3 => 2)) |> gpu |
| 30 | +optim = Adam(0.1, (0.7, 0.95)) |
| 31 | +mloss(x, y) = Flux.logitcrossentropy(model(x), y) # closes over model |
| 32 | + |
| 33 | +Flux.train!(mloss, Flux.params(model), data, optim) # updates model & optim |
| 34 | + |
| 35 | +all((softmax(model(x)) .> 0.5) .== y) # usually 100% accuracy. |
17 | 36 | ```
|
18 | 37 |
|
19 |
| -See the [documentation](https://fluxml.github.io/Flux.jl/) or the [model zoo](https://github.com/FluxML/model-zoo/) for examples. |
| 38 | +See the [documentation](https://fluxml.github.io/Flux.jl/) for details, or the [model zoo](https://github.com/FluxML/model-zoo/) for examples. Ask questions on the [Julia discourse](https://discourse.julialang.org/) or [slack](https://discourse.julialang.org/t/announcing-a-julia-slack/4866). |
20 | 39 |
|
21 | 40 | If you use Flux in your research, please [cite](CITATION.bib) our work.
|
0 commit comments