From a6060ddd175486f11719e03669326f3fad62e679 Mon Sep 17 00:00:00 2001 From: Emmanuel Lujan Date: Tue, 4 Jun 2024 22:37:15 -0400 Subject: [PATCH 1/2] Addressing dependency issues and small fix in test. --- Project.toml | 5 +-- examples/Ar/Project.toml | 7 ++++ examples/Ar/plot-lennard-jones-ar.jl | 5 +-- examples/DFT-subsampling/Project.toml | 16 ++++++++ examples/DFT-subsampling/subsampling_dpp.jl | 16 +++----- examples/Na/Project.toml | 7 ++++ examples/Na/fit-dpp-ace-na.jl | 8 +--- examples/Project.toml | 41 ------------------- examples/README.md | 2 +- examples/aHfO2/build_dpp.jl | 12 +++--- examples/aHfO2/build_multiple_dpp.jl | 12 +++--- src/Learning/linear-learn.jl | 2 +- src/PotentialLearning.jl | 2 - src/interface.jl | 2 +- test/Project.toml | 6 --- .../dimension_reduction_tests.jl | 6 +-- 16 files changed, 57 insertions(+), 92 deletions(-) create mode 100644 examples/Ar/Project.toml create mode 100644 examples/DFT-subsampling/Project.toml create mode 100644 examples/Na/Project.toml delete mode 100644 examples/Project.toml diff --git a/Project.toml b/Project.toml index 8abd6c86..a0dd090c 100644 --- a/Project.toml +++ b/Project.toml @@ -12,9 +12,7 @@ Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04" IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Optim = "429524aa-4258-5aef-a3af-852621145aeb" Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" -OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e" OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" @@ -28,5 +26,4 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [compat] -julia = ">= 1.9" -InteratomicPotentials = ">= 0.2.9" +s diff --git a/examples/Ar/Project.toml b/examples/Ar/Project.toml new file mode 100644 index 00000000..e76dfa7c --- /dev/null +++ b/examples/Ar/Project.toml @@ -0,0 +1,7 @@ +[deps] +AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a" +CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a" diff --git a/examples/Ar/plot-lennard-jones-ar.jl b/examples/Ar/plot-lennard-jones-ar.jl index 6946baba..ec8ce9fb 100644 --- a/examples/Ar/plot-lennard-jones-ar.jl +++ b/examples/Ar/plot-lennard-jones-ar.jl @@ -1,8 +1,7 @@ push!(Base.LOAD_PATH, "../../") -using AtomsBase + using Unitful, UnitfulAtomic -using InteratomicPotentials -using PotentialLearning +using AtomsBase, InteratomicPotentials, PotentialLearning using LinearAlgebra, CairoMakie # Load dataset: Lennard-Jones + Argon diff --git a/examples/DFT-subsampling/Project.toml b/examples/DFT-subsampling/Project.toml new file mode 100644 index 00000000..d0cd319b --- /dev/null +++ b/examples/DFT-subsampling/Project.toml @@ -0,0 +1,16 @@ +[deps] +AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a" +CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" +CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +Determinantal = "2673d5e8-682c-11e9-2dfd-471b09c6c819" +Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" +InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04" +InvertedIndices = "41ab1584-1d38-5bbf-9106-f11c6c58b48f" +JLD = "4138dd39-2aa7-5051-a626-17a0bb65d9c8" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" +Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a" diff --git a/examples/DFT-subsampling/subsampling_dpp.jl b/examples/DFT-subsampling/subsampling_dpp.jl index 24569f9b..72f0c754 100644 --- a/examples/DFT-subsampling/subsampling_dpp.jl +++ b/examples/DFT-subsampling/subsampling_dpp.jl @@ -1,15 +1,11 @@ push!(Base.LOAD_PATH, "../../") -using PotentialLearning -using LinearAlgebra, Random, Statistics, StatsBase, Distributions -using AtomsBase, Unitful, UnitfulAtomic -using InteratomicPotentials -using Determinantal +using LinearAlgebra, Random, InvertedIndices +using Statistics, StatsBase, Distributions, Determinantal +using Unitful, UnitfulAtomic +using AtomsBase, InteratomicPotentials, PotentialLearning +using CSV, JLD, DataFrames using CairoMakie -using InvertedIndices -using CSV -using JLD -using DataFrames include("subsampling_utils.jl") @@ -60,7 +56,7 @@ ds = DataSet(confs .+ e_descr .+ f_descr) ndata = length(ds) # Compute cross validation error from training --------------------------------- -batch_size = [80, 40, 20] +batch_size = [80, 40] sel_ind = Dict{Int64, Vector}() cond_num = Dict{Int64, Vector}() diff --git a/examples/Na/Project.toml b/examples/Na/Project.toml new file mode 100644 index 00000000..e76dfa7c --- /dev/null +++ b/examples/Na/Project.toml @@ -0,0 +1,7 @@ +[deps] +AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a" +CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a" diff --git a/examples/Na/fit-dpp-ace-na.jl b/examples/Na/fit-dpp-ace-na.jl index aa9971d4..b9e3395c 100644 --- a/examples/Na/fit-dpp-ace-na.jl +++ b/examples/Na/fit-dpp-ace-na.jl @@ -1,12 +1,8 @@ push!(Base.LOAD_PATH, "../../") -using AtomsBase -using InteratomicPotentials -using PotentialLearning using Unitful, UnitfulAtomic -using LinearAlgebra -using CairoMakie -#using JLD +using AtomsBase, InteratomicPotentials, PotentialLearning +using LinearAlgebra, CairoMakie # Load dataset confs, thermo = load_data("data/liquify_sodium.yaml", YAML(:Na, u"eV", u"Å")) diff --git a/examples/Project.toml b/examples/Project.toml deleted file mode 100644 index f6f6561c..00000000 --- a/examples/Project.toml +++ /dev/null @@ -1,41 +0,0 @@ -[deps] -ACE1pack = "8c4e8d19-0bd6-4234-8309-7210652e3178" -AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a" -CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" -CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" -DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -Determinantal = "2673d5e8-682c-11e9-2dfd-471b09c6c819" -Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" -FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" -Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" -GaussianProcesses = "891a1506-143c-57d2-908e-e1f8e92e6de9" -GeometricFlux = "7e08b658-56d3-11e9-2997-919d5b31e4ea" -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" -InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04" -InvertedIndices = "41ab1584-1d38-5bbf-9106-f11c6c58b48f" -JLD = "4138dd39-2aa7-5051-a626-17a0bb65d9c8" -JuLIP = "945c410c-986d-556a-acb1-167a618e0462" -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -NPZ = "15e1cf62-19b3-5cfa-8e77-841668bca605" -Optim = "429524aa-4258-5aef-a3af-852621145aeb" -Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" -OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e" -OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1" -OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" -ProgressBars = "49802e3a-d2f1-5c88-81d8-b72133a6f568" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" -SpecialPolynomials = "a25cea48-d430-424a-8ee7-0d3ad3742e9e" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" -UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a" -YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" -Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" - -[compat] -julia = "1.9" diff --git a/examples/README.md b/examples/README.md index 1658de0f..05c94990 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,7 +7,7 @@ $ cd PotentialLearning.jl/examples/Na Open Julia REPL, activate ```Project.toml``` file in folder ```examples```, and chose the number of threads. E.g. ```bash -$ julia --project=.. --threads=4 +$ julia --project=. --threads=4 ``` Type ```]``` in Julia REPL, and then run ```instantiate```. diff --git a/examples/aHfO2/build_dpp.jl b/examples/aHfO2/build_dpp.jl index cc82bfd2..c2572334 100644 --- a/examples/aHfO2/build_dpp.jl +++ b/examples/aHfO2/build_dpp.jl @@ -1,12 +1,10 @@ push!(Base.LOAD_PATH, "../../") -using LinearAlgebra, Random, Statistics, StatsBase, Distributions -using AtomsBase, Unitful, UnitfulAtomic -using InteratomicPotentials -using CairoMakie -using JLD -using Determinantal -using PotentialLearning +using LinearAlgebra, Random +using Statistics, StatsBase, Distributions, Determinantal +using Unitful, UnitfulAtomic +using AtomsBase, InteratomicPotentials, PotentialLearning +using JLD, CairoMakie #################### Importing Data ################### # Import Raw Data diff --git a/examples/aHfO2/build_multiple_dpp.jl b/examples/aHfO2/build_multiple_dpp.jl index d95baa26..389bbf96 100644 --- a/examples/aHfO2/build_multiple_dpp.jl +++ b/examples/aHfO2/build_multiple_dpp.jl @@ -1,12 +1,10 @@ push!(Base.LOAD_PATH, "../../") -using LinearAlgebra, Random, Statistics, StatsBase, Distributions -using AtomsBase, Unitful, UnitfulAtomic -using InteratomicPotentials, InteratomicBasisPotentials -using CairoMakie -using JLD -using Determinantal -using PotentialLearning +using LinearAlgebra, Random +using Statistics, StatsBase, Distributions, Determinantal +using Unitful, UnitfulAtomic +using AtomsBase, InteratomicPotentials, PotentialLearning +using JLD, CairoMakie #################### Importing Data ################### # Import Raw Data diff --git a/src/Learning/linear-learn.jl b/src/Learning/linear-learn.jl index b4950569..a02c4c38 100644 --- a/src/Learning/linear-learn.jl +++ b/src/Learning/linear-learn.jl @@ -56,7 +56,7 @@ function learn!( x0 = [log(lp.σe[1]), log(lp.σf[1]), lp.β...] p = [AtAe, Atbe, AtAf, Atbf, α] prob = Optimization.OptimizationProblem(g, x0, p) - sol = Optimization.solve(prob, Optim.BFGS()) + sol = Optimization.solve(prob, OptimizationOptimisers.Adam(), maxiters = 1000) lp.σe .= exp(sol.u[1]) lp.σf .= exp(sol.u[2]) lp.β .= sol.u[3:end] diff --git a/src/PotentialLearning.jl b/src/PotentialLearning.jl index f2dfe28a..3c2fd79e 100644 --- a/src/PotentialLearning.jl +++ b/src/PotentialLearning.jl @@ -9,8 +9,6 @@ using OrderedCollections using Flux using Zygote using Optimization -using Optim -using OptimizationOptimJL using OptimizationOptimisers using Printf diff --git a/src/interface.jl b/src/interface.jl index fec8216e..f0c37a89 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -12,7 +12,7 @@ using LinearAlgebra using StaticArrays using Statistics using Optimization -using OptimizationOptimJL +using OptimizationOptimisers using UnitfulAtomic using Unitful using Flux diff --git a/test/Project.toml b/test/Project.toml index a3c586d9..4b3e43e9 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -4,10 +4,7 @@ Determinantal = "2673d5e8-682c-11e9-2dfd-471b09c6c819" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Optim = "429524aa-4258-5aef-a3af-852621145aeb" Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" -OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e" -OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" @@ -19,6 +16,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a" YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" - -[compat] -julia = "1.9" diff --git a/test/dimension_reduction/dimension_reduction_tests.jl b/test/dimension_reduction/dimension_reduction_tests.jl index bba24d20..39a81087 100644 --- a/test/dimension_reduction/dimension_reduction_tests.jl +++ b/test/dimension_reduction/dimension_reduction_tests.jl @@ -26,16 +26,16 @@ pca = PCA(num_dim) @test typeof(as) <: DimensionReducer @test typeof(pca) <: DimensionReducer -λ_as, W_as = fit(ds, as) +λ_as, W_as = PotentialLearning.fit(ds, as) @test typeof(λ_as) <: Vector{Float64} @test typeof(W_as) <: Matrix{Float64} @test size(W_as, 1) == d @test size(W_as, 2) == num_dim -λ_pca, W_pca = fit(ds, pca) +λ_pca, W_pca = PotentialLearning.fit(ds, pca) @test typeof(λ_pca) <: Vector{Float64} @test typeof(W_pca) <: Matrix{Float64} @test size(W_pca, 1) == d @test size(W_pca, 2) == num_dim -@test all(λ_as .≈ λ_pca) \ No newline at end of file +@test all(λ_as .≈ λ_pca) From a7eec3a731e33d4e2ff22ee1a7cadbc0f63647ec Mon Sep 17 00:00:00 2001 From: Emmanuel Lujan Date: Tue, 4 Jun 2024 22:40:25 -0400 Subject: [PATCH 2/2] Fix Project.toml. --- Project.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a0dd090c..e2a3643d 100644 --- a/Project.toml +++ b/Project.toml @@ -26,4 +26,5 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [compat] -s +julia = ">= 1.9" +InteratomicPotentials = ">= 0.2.9"