-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove gpu call #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ function extract_bboxes(mask) | |
end | ||
boxes[i,:] = [y1, x1, y2, x2] | ||
end | ||
boxes | ||
return boxes | ||
end | ||
|
||
function extract_bboxes(masks::AbstractArray{T,4}) where T | ||
|
@@ -26,7 +26,7 @@ function extract_bboxes(masks::AbstractArray{T,4}) where T | |
b = extract_bboxes(masks[:,:,:,i]) | ||
push!(bs, b) | ||
end | ||
reduce(vcat, bs) | ||
return reduce(vcat, bs) | ||
end | ||
|
||
expand_dims(x,n::Int) = reshape(x,ones(Int64,n)...,size(x)...) | ||
|
@@ -40,13 +40,13 @@ function squeeze(x) | |
end | ||
end | ||
|
||
function bce(ŷ, y; ϵ=gpu(fill(eps(first(ŷ)), size(ŷ)...))) | ||
function bce(ŷ, y; ϵ=eps(first(ŷ))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you confirm that it works on the GPU as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No issues on cpu. Does not work on gpu for me. but the error seems to be from somewhere else. with u = Unet()
w = rand(Float32, 256,256,1,1);
wp = rand(Float32, 256,256,1,1);
u = u |> gpu
w = w |> gpu
wp = wp |> gpu
function loss(x, y)
op = clamp.(u(x), 0.001f0, 1.f0)
return mean(bce(op, y))
end
rep = Iterators.repeated((w, wp), 10);
opt = Momentum()
Flux.train!(loss, Flux.params(u), rep, opt) I get the following error.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just backprop through |
||
l1 = -y.*log.(ŷ .+ ϵ) | ||
l2 = (1 .- y).*log.(1 .- ŷ .+ ϵ) | ||
l1 .- l2 | ||
return l1 .- l2 | ||
end | ||
|
||
function loss(x, y) | ||
op = clamp.(u(x), 0.001f0, 1.f0) | ||
mean(bce(op, y)) | ||
return mean(bce(op, y)) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably could do without the
return
keyword