Comments (10)
from autograd.jl.
from autograd.jl.
yeah, full
works for me! Though, the problematic thing about this interface is that you don't know what will your gradient type be in advance.
from autograd.jl.
from autograd.jl.
I realize that it has broken the Knet. When you have Adam optimizer with gclip and you get a Sparse gradient, the gclip fails in this case.
from autograd.jl.
I can't replicate, the following works fine. Please provide a minimal example.
using Knet
# Load data (mnistdata basically replicates mnist.ipynb)
include(Knet.dir("data","mnist.jl"))
dtrn,dtst = mnistdata(xsize=(784,:),xtype=Array)
struct Foo; w; end
model = Foo(param(10,784))
# We turn Linear instances into callable objects for prediction:
(m::Foo)(x) = (I = (a->a[1]).(vec(argmax(x,dims=1))); m.w[:,I])
# model(x) gives predictions, let model(x,y) give the loss
(m::Foo)(x, y) = nll(m(x), y)
@info "training..."
@time Knet.minimize!(model, dtst, Adam(lr=0.0001,gclip=0.1))
from autograd.jl.
dy/sparsebugs branch has implemented + for two Sparse values, please test.
from autograd.jl.
Although, I didn't run your example, I believe you didn't get the error because your gradients doesn't exceed the gclip value. Here is a simpler example you can replicate without downloading anything.
julia> using Knet
julia> function foo(w)
s = 0.0
for i=1:length(w); s+=w[i]; end
return s
end
foo (generic function with 1 method)
julia> w = Param(randn(2,2))
2×2 Param{Array{Float64,2}}:
0.427868 0.657678
-0.332868 -1.50003
julia> J = @diff foo(w)
T(-0.7473544438700652)
julia> update!(value(w), grad(J,w), Adam(gclip=0.1))
ERROR: MethodError: lmul!(::Float64, ::AutoGrad.Sparse{Float64,2}) is ambiguous. Candidates:
lmul!(a, x::AutoGrad.Sparse{T,N}) where {T, N} in AutoGrad at /kuacc/users/eakyurek13/.julia/packages/AutoGrad/9MrCC/src/sparse.jl:51
lmul!(s::Number, X::AbstractArray) in LinearAlgebra at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.2/LinearAlgebra/src/generic.jl:100
Possible fix, define
lmul!(::Number, ::AutoGrad.Sparse{T,N})
Stacktrace:
[1] gclip!(::AutoGrad.Sparse{Float64,2}, ::Float64) at /kuacc/users/eakyurek13/.julia/packages/Knet/IIjk8/src/update.jl:613
[2] update!(::Array{Float64,2}, ::AutoGrad.Sparse{Float64,2}, ::Adam) at /kuacc/users/eakyurek13/.julia/packages/Knet/IIjk8/src/update.jl:537
[3] top-level scope at REPL[6]:1
from autograd.jl.
You are right, it was an ambiguity issue. I will create a PR now.
from autograd.jl.
Fixed in current master.
from autograd.jl.
Related Issues (20)
- grad doesn't work on trivial identity HOT 6
- Copy of param is value of param HOT 3
- bug in gradient with broadcast HOT 3
- cannot take derivative of a scalar function HOT 6
- Atom can’t evaluate a line which the regular REPL can
- Inside `@diff`, shouldn't `similar(Result{Array})` return `Result{Array}`? HOT 1
- mapslices and Param wrapped arrays
- Extend UngetIndex to multiple indices, values for efficiency HOT 1
- getindex gradient collection bug
- Cannot `convert` an object of type UnitRange{Int64} to an object of type Colon
- Multiple functions sharing some gradients HOT 1
- Problems with grad after grad HOT 2
- Alkan bias add problem? HOT 1
- TagBot trigger issue HOT 2
- how to calculate gradient without calculating function outputs
- keyword args in broadcasted funcs not supported
- Param(x) as AbstractArray? HOT 1
- Incorrect derivatives when new arrays are constructed in computation
- AutoGrad and CUDA kernels HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autograd.jl.