Closed nuclear718 closed 2 years ago
It's because this package is not registered, you need to provide the url to the repo to install it.
Thanks, I can installed it by "url". but.......many packages were pulled back to deprecate version, my work can not take this.
Anyway, thank you very much.
[052768ef] ↓ CUDA v1.3.3 ⇒ v0.1.0 [587475ba] ↓ Flux v0.11.1 ⇒ v0.10.4 [79e6a3ab] ↓ Adapt v2.3.0 ⇒ v1.1.0 [fa961155] ↓ CEnum v0.4.1 ⇒ v0.2.0 [052768ef] ↓ CUDA v1.3.3 ⇒ v0.1.0 [082447d4] ↓ ChainRules v0.7.22 ⇒ v0.6.5 [d360d2e6] ↓ ChainRulesCore v0.9.11 ⇒ v0.8.1 [587475ba] ↓ Flux v0.11.1 ⇒ v0.10.4 [0c68f7d7] ↓ GPUArrays v5.2.1 ⇒ v3.4.1 [61eb1bfa] ↓ GPUCompiler v0.6.1 ⇒ v0.3.0 [929cbde3] ↓ LLVM v2.0.0 ⇒ v1.7.0 [872c559c] ↓ NNlib v0.7.5 ⇒ v0.6.6 [e88e6eb3] ↓ Zygote v0.5.8 ⇒ v0.4.22
This package has not been updated for a while, it probably needs some updated compatibility bounds. Feel free to submit a pr!
If I can help to improve this repo., I will very happy. But I am still a beginner for julia, github......and everything about software engineering
Would you like provide me some hint for this "improve work"?
What is the first step?
1, Download source code of "FluxOptTools.jl".
2, Test the function in source code and modify some syntax if necessary.
3, Open a PR with modified code and waitting for you to review it?
No worries, to make it work, your summary is correct: you would need to
pkg> dev FluxOptTools
Project.toml
to later versions.Before I take the revise actions, I am trying to understand your code.
I guess that the most important part is function "optfuns()", I think that I can copy-past this function into my program and run it normally but I fail.....
My code as below, I set up a toy training data (x and sin(x)) and a little neural network model, train this model by "Flux" standard workflow quite well. But I can not produce "Optim" functions via optfuns().
using DataFrames,Optim,Flux,Zygote
xd=collect(-2:0.002:2); trainy(x)=sin.(x); yd=trainy(xd); trxx=[[xd[i]] for i in 1:1:size(xd)[1]]; tryy=[yd[i] for i in 1:1:size(yd)[1]]; randid=rand(1:1:size(xd)[1],size(xd)[1]); datary=zip(trxx[randid],tryy[randid])
NNmodel=Chain(Dense(1,3,sigmoid),Dense(3,1)); ps=Flux.params(NNmodel); opt_flux=ADAM(0.0001, (0.9, 0.8)); loss(x,y)=Flux.mse(NNmodel(x),y)
for i in 1:1:30
Flux.train!(loss, ps, datary, opt_flux);
end
The total loss value can be tuned to extreme low, the standard Flux work flow is success(no error in model or loss function) When I copy-past the optfun() code and try to handle this model training by Optim(BFGS)...
function optfuns(loss, pars::Union{Flux.Params, Zygote.Params})
grads = Zygote.gradient(loss, pars); p0 = copyto!(zeros(pars), pars); gradfun = function (g,w); copyto!(pars, w); grads = Zygote.gradient(loss, pars); copyto!(g, grads); end; lossfun = function (w); copyto!(pars, w); loss(); end; fg! = function (F,G,w); copyto!(pars, w); if G != nothing; l, back = Zygote.pullback(loss, pars); grads = back(1); copyto!(G, grads); return l; end; if F != nothing; return loss(); end; end; lossfun, gradfun, fg!, p0
end
optfuns(loss,ps)
grads = Zygote.gradient(loss, ps)
both last code are fail with same error messages: MethodError: no method matching loss() Closest candidates are: loss(!Matched::Any, !Matched::Any) at In[26]:4
If I totally copy the packages that you use in your source code and directly copy your demo code, I still can not repeat this program. I think that some mistakes were caused by me but I can not figure out it. Please correct me,thanks.
using DataFrames,CSV,Optim,Flux,Zygote
using LinearAlgebra,RecipesBase,Distributions, OnlineStats
m = Chain(Dense(1,3,tanh) , Dense(3,1))
x = LinRange(-pi,pi,100)'
y = sin.(x)
loss() = mean(abs2, m(x) .- y)
Zygote.refresh()
pars = Flux.params(m)
**lossfun, gradfun, fg!, p0 = optfuns(loss, pars)**
Error message: MethodError: no method matching zeros(::Params) Closest candidates are: zeros(!Matched::Union{Integer, AbstractUnitRange}...) at array.jl:520 zeros(!Matched::Type{StaticArrays.SArray{Tuple{N},T,1,N} where T}) where N at C:\Users\USER.julia\packages\StaticArrays\l7lu2\src\SVector.jl:31 zeros(!Matched::Type{StaticArrays.MArray{Tuple{N},T,1,N} where T}) where N at C:\Users\USER.julia\packages\StaticArrays\l7lu2\src\MVector.jl:24
I can not installed it.
Code:
using Pkg
Pkg.add("FluxOptTools")
Error Message: **The following package names could not be resolved:
My versioninfo(): Julia Version 1.5.1 Commit 697e782ab8 (2020-08-25 20:08 UTC) Platform Info: OS: Windows (x86_64-w64-mingw32) CPU: AMD Ryzen 5 3600X 6-Core Processor
WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-9.0.1 (ORCJIT, znver2) Environment: JULIA.EXECUTABLEPATH = C:\Users\USER\AppData\Local\Julia-1.3.1\bin\ & set JULIA_NUM_THREADS=12 & julia.exe JULIA_NUM_THREADS = 12