Skip to content

Commit

Permalink
Merge pull request FluxML#57 from FluxML/julia-0.7
Browse files Browse the repository at this point in the history
Julia 1.0
  • Loading branch information
MikeInnes authored Sep 14, 2018
2 parents 9520e3e + 1dfa74e commit f0a0d97
Show file tree
Hide file tree
Showing 30 changed files with 2,562 additions and 45 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,35 @@
This repository contains various demonstrations of the [Flux](http://fluxml.github.io/) machine learning library. Any of these may freely be used as a starting point for your own models.

The models are broadly categorised into the folders [vision](/vision) (e.g. large convnets), [text](/text) (e.g. various RNNs and NLP models), [games](/games) (reinforcement learning). See the READMEs of respective models for more information.

## Usage

Each folder is its own [Julia project](https://julialang.github.io/Pkg.jl/latest/#Using-someone-else's-project-1), which lists the packages you need to run the models. You can run the models by opening Julia in the project folder and running

```
]activate .; instantiate
```

to install all needed packages. Then you can run the model code with `include("script.jl")` or by running the script line-by-line. More details are available in the README for each model.

## Contributing

We welcome contributions of new models. They should be in a folder with a project and manifest file, to pin all relevant packages, as well as a README to explain what the model is about, how to run it, and what results it acheives (if applicable). If possible models should not depend directly on GPU functionality, but ideally should be CPU/GPU agnostic.

## Model Listing

* Vision
* MNIST
* [Simple multi-layer perceptron](vision/mnist/mlp.jl)
* [Simple ConvNet](vision/mnist/conv.jl)
* [Simple Auto-Encoder](vision/mnist/autoencoder.jl)
* [Variational Auto-Encoder](vision/mnist/vae.jl)
* [VGG 16/19 on CIFAR10](vision/cifar10)
* Text
* [CharRNN](text/char-rnn)
* [Character-level language detection](text/lang-detection)
* [Seq2Seq phoneme detection on CMUDict](text/phonemes)
* [Recursive net on IMDB sentiment treebank](text/treebank)
* Other
* [BitString Parity Challenge](other/bitstring-parity)
* [MLP on housing data](other/housing) (low level API)
270 changes: 270 additions & 0 deletions other/bitstring-parity/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
[[AbstractTrees]]
deps = ["Markdown", "Test"]
git-tree-sha1 = "feb8b2c99359901e295443c9d0c7e711604acf39"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.2.0"

[[Adapt]]
deps = ["LinearAlgebra", "Test"]
git-tree-sha1 = "036ce44a518b912c43df728bfae274f8d8de9059"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "0.3.1"

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BinDeps]]
deps = ["Compat", "Libdl", "SHA", "URIParser"]
git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9"
uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
version = "0.8.10"

[[BinaryProvider]]
deps = ["Libdl", "Pkg", "SHA", "Test"]
git-tree-sha1 = "b530fbeb6f41ab5a83fbe3db1fcbe879334bcd2d"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.4.2"

[[CodecZlib]]
deps = ["BinaryProvider", "Libdl", "Pkg", "Test", "TranscodingStreams"]
git-tree-sha1 = "83cb3d65c37ea1364c2d5bf7bcea41843ba645dc"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.5.0"

[[ColorTypes]]
deps = ["FixedPointNumbers", "Random", "Test"]
git-tree-sha1 = "0e3209ba7418aed732e5c3818076b4400ee36c08"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.7.4"

[[Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Pkg", "Printf", "Reexport", "Test"]
git-tree-sha1 = "8c89e0a9a583954eae3efcf6a531e51c02b38cee"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.9.4"

[[CommonSubexpressions]]
deps = ["Test"]
git-tree-sha1 = "efdaf19ab11c7889334ca247ff4c9f7c322817b0"
uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
version = "0.2.0"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "ae262fa91da6a74e8937add6b613f58cd56cdad4"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "1.1.0"

[[DataStructures]]
deps = ["InteractiveUtils", "REPL", "Random", "Serialization", "Test"]
git-tree-sha1 = "5162c360c52e9265e0bfafb71415c31f746f7e04"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.12.0"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[DiffResults]]
deps = ["Compat", "StaticArrays"]
git-tree-sha1 = "db8acf46717b13d6c48deb7a12007c7f85a70cf7"
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
version = "0.0.3"

[[DiffRules]]
deps = ["Random", "Test"]
git-tree-sha1 = "c49ec69428ffea0c1d1bbdc63d1a70f5df5860ad"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "0.0.7"

[[Distributed]]
deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[FixedPointNumbers]]
deps = ["Pkg", "Test"]
git-tree-sha1 = "b8045033701c3b10bf2324d7203404be7aef88ba"
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
version = "0.5.3"

[[Flux]]
deps = ["AbstractTrees", "Adapt", "CodecZlib", "Colors", "DiffRules", "ForwardDiff", "Juno", "LinearAlgebra", "MacroTools", "NNlib", "NaNMath", "Pkg", "Printf", "Random", "Reexport", "Requires", "SpecialFunctions", "Statistics", "StatsBase", "Test", "ZipFile"]
git-tree-sha1 = "b9fc47f3eeb8062c9dac3a74bca9fd83f7e0fbf5"
uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c"
version = "0.6.7"

[[ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "InteractiveUtils", "LinearAlgebra", "NaNMath", "Pkg", "Random", "SparseArrays", "SpecialFunctions", "StaticArrays", "Test"]
git-tree-sha1 = "8425a7d4e060bc2ded32d090bce910a187d6cce7"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.9.0"

[[InteractiveUtils]]
deps = ["LinearAlgebra", "Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Juno]]
deps = ["Base64", "Logging", "Media", "Profile", "Test"]
git-tree-sha1 = "3c29a199713e7ec62cfdc11f44d7760219d5f658"
uuid = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
version = "0.5.3"

[[LibGit2]]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[MacroTools]]
deps = ["Compat"]
git-tree-sha1 = "c443e1c8d58a4e9f61b708ad0a88286c7042145b"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.4.4"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Media]]
deps = ["MacroTools", "Test"]
git-tree-sha1 = "9f390271c9a43dcbe908a10b5b9632cf58cbab5b"
uuid = "e89f7d12-3494-54d1-8411-f7d8b9ae1f27"
version = "0.4.1"

[[Missings]]
deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"]
git-tree-sha1 = "196528fa1df03df435025f52f9c1ff8356f94738"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "0.3.0"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[NNlib]]
deps = ["Libdl", "LinearAlgebra", "MacroTools", "Requires", "Test"]
git-tree-sha1 = "d7f65ad9734adea3c5a4c473bc65b365f8afbb2b"
uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
version = "0.4.2"

[[NaNMath]]
deps = ["Compat"]
git-tree-sha1 = "ce3b85e484a5d4c71dd5316215069311135fa9f2"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.2"

[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[Profile]]
deps = ["Printf"]
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Reexport]]
deps = ["Pkg"]
git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "0.2.0"

[[Requires]]
deps = ["Test"]
git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "0.5.2"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SortingAlgorithms]]
deps = ["DataStructures", "Random", "Test"]
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "0.3.1"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[SpecialFunctions]]
deps = ["BinDeps", "BinaryProvider", "Compat", "Libdl"]
git-tree-sha1 = "d12f8917be3782f4b800ba16003b8d0d4858c2e5"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "0.7.0"

[[StaticArrays]]
deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"]
git-tree-sha1 = "d432c79bef174a830304f8601427a4357dfdbfb7"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "0.8.3"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[StatsBase]]
deps = ["DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "Test"]
git-tree-sha1 = "723193a13e8078cec6dcd0b8fe245c8bfd81690e"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.25.0"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TranscodingStreams]]
deps = ["DelimitedFiles", "Pkg", "Random", "Test"]
git-tree-sha1 = "a34a2d588e2d2825602bf14a24216d5c8b0921ec"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.8.1"

[[URIParser]]
deps = ["Test", "Unicode"]
git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69"
uuid = "30578b45-9adc-5946-b283-645ec420af67"
version = "0.4.0"

[[UUIDs]]
deps = ["Random"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[ZipFile]]
deps = ["Printf", "Test"]
git-tree-sha1 = "c191e56c849b1784cacbf7cd5e52cc672f1ae2db"
uuid = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"
version = "0.7.0"
4 changes: 4 additions & 0 deletions other/bitstring-parity/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[deps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3 changes: 2 additions & 1 deletion other/bitstring-parity/data.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Flux: onehot, onehotbatch
using Random

const alphabet = [false, true] # 0, 1

parity(x) = reduce(xor, x)

gendata(n::Int, k::Int) = gendata(n, k:k)
function gendata(n::Int, k::UnitRange{Int})
function gendata(n::Int, k::UnitRange{Int})
X = bitrand.(rand(k, n))
return [(onehotbatch(x, alphabet), onehot(y, alphabet)) for (x, y) in zip(X, parity.(X))]
end
6 changes: 3 additions & 3 deletions other/bitstring-parity/xor1.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include("data.jl")
using Flux
using Flux: onehot, onehotbatch, throttle, crossentropy, reset!, argmax
using Flux, Statistics
using Flux: onehot, onehotbatch, throttle, crossentropy, reset!, onecold

const epochs = 20

Expand Down Expand Up @@ -32,4 +32,4 @@ tx = map(c -> onehotbatch(c, alphabet), [
[true, false], # 10 -> 1
[false, false], # 00 -> 0
[true, true]]) # 11 -> 0
[argmax(model(x)) - 1 for x in tx] |> println
[onecold(model(x)) - 1 for x in tx] |> println
8 changes: 4 additions & 4 deletions other/bitstring-parity/xor2.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include("data.jl")
using Flux
using Flux: onehot, onehotbatch, throttle, crossentropy, reset!, argmax
using Flux, Statistics
using Flux: onehot, onehotbatch, throttle, crossentropy, reset!, onecold

const epochs = 30

Expand Down Expand Up @@ -34,7 +34,7 @@ tx = map(c -> onehotbatch(c, alphabet), [
[true, false], # 10 -> 1
[false, false], # 00 -> 0
[true, true]]) # 11 -> 0
[argmax(model(x)) - 1 for x in tx] |> println
[onecold(model(x)) - 1 for x in tx] |> println

# Try running the model on strings of length 50.
#
Expand All @@ -44,4 +44,4 @@ tx = map(c -> onehotbatch(c, alphabet), [
function t50()
l = batch_loss(gendata(1000, 50))
println(l)
end
end
6 changes: 3 additions & 3 deletions other/bitstring-parity/xor3.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include("data.jl")
using Flux
using Flux: onehot, onehotbatch, throttle, crossentropy, reset!, argmax
using Flux, Statistics
using Flux: onehot, onehotbatch, throttle, crossentropy, reset!, onecold

const epochs = 30

Expand Down Expand Up @@ -34,4 +34,4 @@ tx = map(c -> onehotbatch(c, alphabet), [
[true, false], # 10 -> 1
[false, false], # 00 -> 0
[true, true]]) # 11 -> 0
[argmax(model(x)) - 1 for x in tx] |> println
[onecold(model(x)) - 1 for x in tx] |> println
1 change: 1 addition & 0 deletions other/housing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
housing.data
Loading

0 comments on commit f0a0d97

Please sign in to comment.