yanji84 / deep-recurrent-attention-model Goto Github PK
View Code? Open in Web Editor NEWApply reinforcement learning to visual attention
Apply reinforcement learning to visual attention
Hi @yanji84,
first of all compliments on your code, the clear structure makes it easy to understand. However, I think there are two issues with how you compute the policy gradients in the backward
method of the LocationNet
class:
you define a training operator locationNetTrainOp
to optimize the parameters of the location network by REINFORCE (here). You add it to the CoreRNN
here but never execute it as far as I can see (neither in CoreRNN
nor in Main
).
you collect all policy gradients and the parameters in a list.
gradsAndVarsAllSteps = [zip(g, params) for g in policyGradients]
for gradsAndVars in gradsAndVarsAllSteps:
locationNetTrainOp = optimize.apply_gradients(gradsAndVars)
optimize.apply_gradients(gradsAndVars)
does not actually perform gradient updates (it's just an operator) and locationNetTrainOp
is overwritten on every iteration. Thus, the training operator you return in the end would only apply the updates using gradients of the last time step (i.e. the last element in the list gradsAndVarsAllSteps
. I think instead of the loop it should simply be:
gradsAndVarsAllSteps = [zip(g, params) for g in policyGradients]
locationNetTrainOp = optimize.apply_gradients(gradsAndVarsAllSteps)
Maybe I'm missing something but this should fix things.
Edit: since @tianyu-tristan has worked with your code as well I'm mentioning him as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.