Git Product home page Git Product logo

Comments (5)

MikeInnes avatar MikeInnes commented on May 23, 2024

You may want to mention it to @alha02 who's implementing a lot of tf ops in #28. It's pretty easy to do. I should add some docs for this.

from flux.jl.

 avatar commented on May 23, 2024

@pevnak I added segment_sum op to my TODO-list in #28

from flux.jl.

pevnak avatar pevnak commented on May 23, 2024

Thanks a lot. I am curious how flux will look like with it.

from flux.jl.

pevnak avatar pevnak commented on May 23, 2024

For those interested in, it can be easily added as multiplication with sparse vector:

function sparse_segmented_mean(x,segments::Vector{UnitRange{Int64}})
s = zeros(eltype(x),size(x,2),length(segments))
for (i,segment) in enumerate(segments)
s[segment,i]=1./length(segment)
end
x*sparse(s)
end

or slightly faster version

function fast_segmented_mean(x,segments::Vector{UnitRange{Int64}})
rowval = collect(1:size(x,2))
nzval = zeros(eltype(x),size(x,2))
colptr = zeros(Int,length(segments)+1)
colptr[end] = size(x,2)+1
for (i,segment) in enumerate(segments)
colptr[i] = segment.start
nzval[segment] = 1./length(segment)
end
m = size(x,2)
n = length(segments)
x*SparseMatrixCSC(m,n,colptr,rowval,nzval)
end

from flux.jl.

MikeInnes avatar MikeInnes commented on May 23, 2024

FWIW, while I don't know your use case exactly, this seems like a fairly strange construction to me. Often TensorFlow has things like this because it can't handle things like variable-length lists of tensors. So in Flux it might be possible to just use an array of matrices, and map the appropriate function over that list.

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