Skip to content

Commit

Permalink
deal with Go defer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
unixpickle committed Mar 25, 2017
1 parent e555500 commit ec6ed89
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion anyrnn/feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ func (f *feedbackRes) Propagate(u anyvec.Vector, s StateGrad,
g anydiff.Grad) (anyvec.Vector, StateGrad) {
for _, p := range []*anydiff.Var{f.InPool, f.LastOutPool} {
g[p] = p.Vector.Creator().MakeVector(p.Vector.Len())
defer delete(g, p)
defer func(g anydiff.Grad, p *anydiff.Var) {
delete(g, p)
}(g, p)
}
var blockUpstream StateGrad
if s != nil {
Expand Down

0 comments on commit ec6ed89

Please sign in to comment.