torfjelde / batching.jl Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
On Julia 1.8 we have
julia> slices = eachslice(ones(2, 3, 4); dims=2)
Base.Generator{Base.OneTo{Int64}, Base.var"#245#246"{Array{Float64, 3}, Tuple{Colon}, Tuple{Colon}}}(Base.var"#245#246"{Array{Float64, 3}, Tuple{Colon}, Tuple{Colon}}([1.0 1.0 1.0; 1.0 1.0 1.0;;; 1.0 1.0 1.0; 1.0 1.0 1.0;;; 1.0 1.0 1.0; 1.0 1.0 1.0;;; 1.0 1.0 1.0; 1.0 1.0 1.0], (Colon(),), (Colon(),)), Base.OneTo(3))
julia> eltype(slices)
Any
julia> slices[1]
ERROR: MethodError: no method matching getindex(::Base.Generator{Base.OneTo{Int64}, Base.var"#245#246"{Array{Float64, 3}, Tuple{Colon}, Tuple{Colon}}}, ::Int64)
Stacktrace:
[1] top-level scope
@ REPL[23]:1
while on Julia 1.9, we have
julia> slices = eachslice(ones(2, 3, 4); dims=2)
3-element Slices{Array{Float64, 3}, Tuple{Colon, Int64, Colon}, Tuple{Base.OneTo{Int64}}, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Base.Slice{Base.OneTo{Int64}}}, false}, 1}:
[1.0 1.0 1.0 1.0; 1.0 1.0 1.0 1.0]
[1.0 1.0 1.0 1.0; 1.0 1.0 1.0 1.0]
[1.0 1.0 1.0 1.0; 1.0 1.0 1.0 1.0]
julia> eltype(slices)
SubArray{Float64, 2, Array{Float64, 3}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Base.Slice{Base.OneTo{Int64}}}, false}
julia> slices[1]
2×4 view(::Array{Float64, 3}, :, 1, :) with eltype Float64:
1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0
That is, Slices
are basically like our ArrayBatch
.
As a result, once ≥1.9 becomes standard we can probably just have ArrayBatch
wrap a Base.Slices
and defer all the functionality to this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.