Comments (3)
Also thinking about modifying the API for hadamard_*
to reflect the tuple nature of the fluxes - right now, if you have multiple fluxes F_i(x,y)
and multiple operators A_i
, the API makes you compute contributions A_i.*F_i
separately.
A prototype which seems to work for computing a Hadamard sum - should accommodate fluxes which output tuple values so long as ATr_list is a tuple of operators of the same length.
unzip(a) = map(x->getfield.(a, x), fieldnames(eltype(a)))
bmult(a,b) = a.*b # broadcasted multiplication
function hadamard_sum!(rhs, ATr_list::NTuple{N,Array{T,2}}, F, u) where {N,T}
n = size(first(ATr_list),2)
val_i = zeros(eltype(first(rhs)),length(rhs))
for i = 1:n
ui = getindex.(u,i)
fill!(val_i,zero(eltype(first(rhs))))
for j = 1:n
uj = getindex.(u,j)
val_i .+= sum.(unzip(bmult.(getindex.(ATr_list,j,i),F(ui...,uj...))))
end
setindex!.(rhs,val_i,i)
end
end
Thoughts on API?
from fluxdiffutils.jl.
Also, not sure what "compatible" with tuple of vectors u
would be. Tuple of tuples of arrays? e.g., Jac[i][j] would be typeof(ATr)?
from fluxdiffutils.jl.
API is now consistent, and also works with tuples of operators (e.g., if flux outputs Fx,Fy and you provide (Ax,Ay), will compute sum(Ax.*Fx + Ay.*Fy,dims=2)
automatically.
from fluxdiffutils.jl.
Related Issues (8)
- Name change
- Remove "scale" argument HOT 1
- TagBot trigger issue HOT 2
- Loss of sparsity in hadamard_sum HOT 2
- Large number of allocations for sparse operators HOT 3
- specialize `hadamard_jacobian` writing to sparse matrices
- Type instability in `hadamard_jacobian` from construction of block matrix HOT 2
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 fluxdiffutils.jl.