Skip to content

Commit

Permalink
Use a package-local squeeze function instead of extending Base
Browse files Browse the repository at this point in the history
  • Loading branch information
tkelman committed May 22, 2017
1 parent 5cbb47a commit 41ea071
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const AArray = AbstractArray
initn(dims...) = randn(dims...)/100

unsqueeze(xs, dim = 1) = reshape(xs, (size(xs)[1:dim-1]..., 1, size(xs)[dim:end]...))
squeeze(xs, dim = 1) = Base.squeeze(xs, dim)

stack(xs, dim = 1) = cat(dim, unsqueeze.(xs, dim)...)
unstack(xs, dim = 1) = [slicedim(xs, dim, i) for i = 1:size(xs, dim)]
Expand Down
2 changes: 1 addition & 1 deletion test/recurrent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ end
_, ys = apply(unroll1(r).model, xs, (r.y.x,))
@test ys[1] == tanh(xs[1] * r.Wxy.x .+ r.y.x * r.Wyy.x .+ r.by.x)
ru = unroll(r, 3)
ru(batchone(Seq(squeeze.(xs, 1))))[1] == squeeze.(ys, 1)
ru(batchone(Seq(squeeze.(xs))))[1] == squeeze.(ys)
end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Flux, DataFlow, MacroTools, Base.Test
using Flux: graph, Param, unsqueeze
using Flux: graph, Param, squeeze, unsqueeze
using DataFlow: Line, Frame

macro mxonly(ex)
Expand Down

0 comments on commit 41ea071

Please sign in to comment.