Skip to content
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

Eliminate double dataload loop learning status #105

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/learning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ end
function learning_status(tr::Trainer, samples)
# As done now, this is slighly inefficient as we solve the
# same neural network inference problem twice
samples = Network.convert_input_tuple(tr.network, samples)
W, X, A, P, V = samples
regws = Network.regularized_params(tr.network)
Ls = losses(tr.network, regws, tr.params, tr.Wmean, tr.Hp, samples)
Expand All @@ -167,11 +168,12 @@ end
function learning_status(tr::Trainer)
batchsize = min(tr.params.loss_computation_batch_size, num_samples(tr))
batches = Flux.Data.DataLoader(tr.data; batchsize, partial=true)
reports = map(batches) do batch
batch = Network.convert_input_tuple(tr.network, batch)
return learning_status(tr, batch)
reports = []
ws = []
for batch in batches
push!(reports, learning_status(tr, batch))
push!(ws, sum(batch.W))
end
ws = [sum(batch.W) for batch in batches]
return mean_learning_status(reports, ws)
end

Expand Down