Skip to content

Commit

Permalink
Merge pull request #12 from JuliaTrustworthyAI/update-deps
Browse files Browse the repository at this point in the history
Updates Flux and Optimisers dependencies
  • Loading branch information
pat-alt authored Dec 19, 2024
2 parents 063f74e + 0132995 commit 01f24a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version [1.0.3] - 2024-12-19

## Version [1.0.2] - 2024-11-13

### Added
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "EnergySamplers"
uuid = "f446124b-5d5e-4171-a6dd-a1d99768d3ce"
authors = ["Patrick Altmeyer and contributors"]
version = "1.0.2"
version = "1.0.3"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand All @@ -16,9 +16,9 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
Aqua = "0.8"
CategoricalArrays = "0.10"
Distributions = "0.25"
Flux = "0.14"
Flux = "0.14, 0.15, 0.16"
MLUtils = "0.4"
Optimisers = "0.3"
Optimisers = "0.3, 0.4"
StatsBase = "0.33, 0.34"
Tables = "1.12"
Test = "1"
Expand Down
22 changes: 11 additions & 11 deletions docs/src/_intro.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ for feature in numerics
rescale!(test[!, feature], μ, σ; obsdim=1)
end
prep_X(x) = gpu(Matrix(x)')
prep_y(y) = gpu(reshape(y, 1, :))
prep_X(x) = Matrix(x)'
prep_y(y) = reshape(y, 1, :)
train_X, test_X = prep_X.((train[:, features], test[:, features]))
train_y, test_y = prep_y.((train[:, target], test[:, target]))
train_set = Flux.DataLoader((train_X, train_y); batchsize=100, shuffle=false)
Expand All @@ -68,22 +68,22 @@ Finally, we create a small helper function that runs the training loop for a giv
function train_logreg(; steps::Int=1000, opt=Flux.Descent(2))
Random.seed!(1)
paramvec(θ) = reduce(hcat, cpu(θ))
model = gpu(Dense(length(features), 1, sigmoid))
paramvec(θ) = reduce(hcat, θ)
model = Dense(length(features), 1, sigmoid)
θ = Flux.params(model)
θ₀ = paramvec(θ)
predict(x; thres=0.5) = model(x) .> thres
accuracy(x, y) = mean(cpu(predict(x)) .== cpu(y))
accuracy(x, y) = mean(predict(x) .== y)
loss(yhat, y) = Flux.binarycrossentropy(yhat, y)
avg_loss(yhat, y) = mean(loss(yhat, y))
trainloss() = avg_loss(model(train_X), train_y)
testloss() = avg_loss(model(test_X), test_y)
trainlosses = [cpu(trainloss()); zeros(steps)]
testlosses = [cpu(testloss()); zeros(steps)]
weights = [cpu(θ₀); zeros(steps, length(θ₀))]
trainlosses = [trainloss(); zeros(steps)]
testlosses = [testloss(); zeros(steps)]
weights = [θ₀; zeros(steps, length(θ₀))]
opt_state = Flux.setup(opt, model)
Expand All @@ -102,9 +102,9 @@ function train_logreg(; steps::Int=1000, opt=Flux.Descent(2))
end
# Bookkeeping
weights[t + 1, :] = cpu(paramvec(θ))
trainlosses[t + 1] = cpu(trainloss())
testlosses[t + 1] = cpu(testloss())
weights[t + 1, :] = paramvec(θ)
trainlosses[t + 1] = trainloss()
testlosses[t + 1] = testloss()
end
println("Final parameters are $(paramvec(θ))")
Expand Down

2 comments on commit 01f24a3

@pat-alt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/121656

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.3 -m "<description of version>" 01f24a33ae0c2938ad03bbf31e1f6e00130dd960
git push origin v1.0.3

Please sign in to comment.