Giter Club home page Giter Club logo

Comments (8)

eeyrdkl avatar eeyrdkl commented on May 16, 2024

Your input,output,weights matrices aren't KnetArrays; calculations are being done on the CPU.

from knet.jl.

pevnak avatar pevnak commented on May 16, 2024

That means that whole package is optimized for GPU and slow on CPU?

from knet.jl.

eeyrdkl avatar eeyrdkl commented on May 16, 2024

Yes. GPUs are better at these type of calculations. Although I haven't tested your code, it should run much faster on a GPU.

from knet.jl.

denizyuret avatar denizyuret commented on May 16, 2024

from knet.jl.

pevnak avatar pevnak commented on May 16, 2024

Hi Dennis,
thanks for the answer. I think that the core issue is that weights of the model is vector of Any, which causes Julia to make ineffective code. I have copied that from example in ReadMe, but it is not something I am quite content. I have tried to change it to tuple, which should give it a rigid definition and julia can better optimize. Though I run into this error:

no method matching axpy!(::Float64, ::Tuple{Array{Float64,2},Array{Float64,1},Array{Float64,2},Array{Float64,1},Array{Float64,2},Float64}, ::Tuple{Array{Float64,2},Array{Float64,1},Array{Float64,2},Array{Float64,1},Array{Float64,2},Float64})

which I think is caused by missing overloaded function. But I was not able to find, where do you overload axpy! for lists of matrices or how to add handling of tuples such that it will work with update!

from knet.jl.

pevnak avatar pevnak commented on May 16, 2024

I have modified the code by replacing the array by tuple (which made the compiler aware of types) and removed the update!, because of the problem mentioned in my previous comment and it flies really nicely.

That said, the update! should be modified to handle tuples, especially if it is encouraged in the documentation to do so.

Tomas

from knet.jl.

ozanarkancan avatar ozanarkancan commented on May 16, 2024

Hi,
You can use a tuple to hold your weights, but update! accepts only one weight array. You should iterate over your weights to update them. Your initial examples works since julia can perform the minus operation on list of arrays (e.g. [rand(4,2), zeros(2)] - 0.1 * [rand(4,2), zeros(2)]). Optimization parameters should also be a list or tuple (if you do not use Sgd). Because, the optimization methods other than Sgd need to store some additional arrays to perform the update rule.

You can check this example .

from knet.jl.

pevnak avatar pevnak commented on May 16, 2024

Hi,
thanks for the answer. I was thinking about solution like that, but before writing that, I wanted to know if there is some machinery inside that makes this explicit.

Thank you very much for the answer.
I really appreciate it.

Tomas

from knet.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.