Giter Site home page Giter Site logo

Using AutoGrad with CuArray about autograd.jl HOT 2 OPEN

ngphuoc avatar ngphuoc commented on May 18, 2024
Using AutoGrad with CuArray

from autograd.jl.

Comments (2)

ngphuoc avatar ngphuoc commented on May 18, 2024

I have checked that AutoGrad can work with ArrayFire: JuliaGPU/ArrayFire.jl#183

PS: if my benchmark was correct then KnetArray is about 3-4 times faster.

from autograd.jl.

CarloLucibello avatar CarloLucibello commented on May 18, 2024

autograd gradient is working now (julia 0.7 and CuArrays master) but it is of the wrong type (standard array)

julia> using Knet,CuArrays, Statistics

julia> x,y = rand(13,10), randn(1,10)
([0.774427 0.275647  0.452615 0.09355; 0.411376 0.765637  0.527263 0.839156;  ; 0.650629 0.404082  0.520125 0.279594; 0.743382 0.192372  0.756798 0.457104], [-0.816243 -0.606755  1.3648 -0.116751])

julia> w = Any[ 0.1f0*cu(randn(Float32,1,13)), 0.0f0 ]
2-element Array{Any,1}:
  Float32[-0.092651 -0.0714096  -0.102493 0.080609]
 0.0f0                                              

julia> w[1] |> typeof
CuArray{Float32,2}

julia> predict(w,x) = w[1]*x .+ w[2]
predict (generic function with 1 method)

julia> loss(w,x,y) = mean(abs2, y.- predict(w,x))
loss (generic function with 1 method)

julia> loss(w,x,y)
0.7325428950542855

julia> grad(loss)(w,x,y)  
2-element Array{Any,1}:
  [0.215699 0.272719  0.196543 0.123026]
 0.4017888307995154                      

julia> grad(loss)(w,x,y)[1] |> typeof
Array{Float64,2}

from autograd.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.