Skip to content

Commit

Permalink
Merge pull request #61 from maleadt/tb/1.0
Browse files Browse the repository at this point in the history
Fixes for 0.7 and 1.0.
  • Loading branch information
MikeInnes authored Aug 10, 2018
2 parents 97800cc + f527928 commit 0180656
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/impl/pool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function mean_pooling2d_bwd!(x::AbstractArray{T,4}, y::AbstractArray{T,4},
pooled_height::Int, kernel_w::Int, kernel_h::Int, pad_w::Int, pad_h::Int,
stride_w::Int, stride_h::Int) where T

x[:, :, :, :] = 0
x[:, :, :, :] .= 0
kernel_size = kernel_w * kernel_h

#pragma omp parallel for
Expand All @@ -112,7 +112,7 @@ function mean_pooling2d_bwd!(x::AbstractArray{T,4}, y::AbstractArray{T,4},
wstart = max(wstart, 0) + 1

oval = y[pw, ph, c, n] / kernel_size
x[wstart:wend, hstart:hend, c, n] += oval
x[wstart:wend, hstart:hend, c, n] .+= oval
end
end

Expand Down Expand Up @@ -263,7 +263,7 @@ function mean_pooling3d_bwd!(grad_input::AbstractArray{T,5}, grad_output::Abstra
hstart = max(hstart, 0) + 1
wstart = max(wstart, 0) + 1

grad_input[wstart:wend, hstart:hend, dstart:dend, c, n] += grad_output[pw, ph, pd, c, n] / kernel_size
grad_input[wstart:wend, hstart:hend, dstart:dend, c, n] .+= grad_output[pw, ph, pd, c, n] ./ kernel_size
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/softmax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ softmax!(xs) = softmax!(xs, xs)
softmax(xs) = softmax!(similar(xs), xs)

function ∇softmax!(out::AbstractVecOrMat, Δ::AbstractVecOrMat, xs::AbstractVecOrMat)
s = sum(exp, xs, 1)
out .= exp.(xs)./s.*.- sum.* exp.(xs), 1)./s)
s = sum(exp, xs, dims=1)
out .= exp.(xs)./s.*.- sum.* exp.(xs), dims=1)./s)
end

∇softmax!(Δ, xs) = ∇softmax!(Δ, Δ, xs)
Expand Down

0 comments on commit 0180656

Please sign in to comment.