Comments (6)
The scan is mostly used to construct then tensor variable that has recursive behavior. The usual shared variable update is still done by setting "update" option
from deeplearningresearch.
Verification Test:
Construct a variable that add up through the dataset, so y_t = y_tm1 + ax_t + b,
Then calculate the gradient of x at each step, this should gives:
g_b = 1
g_a = x_t + x_tm-1 + ... + x_0
from deeplearningresearch.
Test program:
1 import theano
2 import theano.tensor as T
3
4 inputData = [1,2,3,4,5]
5 x = T.vector("x")
6 y = T.scalar("y")
7 a = T.scalar("a")
8 b = T.scalar("b")
9
10 def recurrent(x_t, y_tm1):
11 y_t = y_tm1 + a * x_t + b
12 return y_t
13
14 y0 = T.vector()
15 result, update = theano.scan(fn = recurrent,
16 outputs_info = y0,
17 sequences = x,
18 truncate_gradient=2,
19 non_sequences= None)
20 index = T.iscalar("i")
21 g_result = T.grad(result[index][0], a)
22
23 sum_all = theano.function(inputs=[y0, x, a, b], outputs=result)
24 grad_all = theano.function(inputs=[y0, x, a, b, index], outputs=g_result)
25
26
27 print "result:"
28 print sum_all([100.0], inputData, 1, 0)
29
30 print "gradient:"
31 for i in range(len(inputData)):
32 print grad_all([100.0], inputData, 1, 0, i)
from deeplearningresearch.
output:
result:
[[ 101.]
[ 103.]
[ 106.]
[ 110.]
[ 115.]]
gradient:
0.0
0.0
0.0
4.0
9.0
from deeplearningresearch.
This shows that:
- result is always encapsulate in a 2d array, first dimension is for each input sequence, second dimension is for the output arrays
- The truncated gradient is work in a way from the last instance, so we should probably always use full unfold. so NO TRUNCATED GRADIENT. (rather, we should have ceiling for gradient)
from deeplearningresearch.
Done
from deeplearningresearch.
Related Issues (19)
- Separate training and testing phase HOT 1
- Multi-layer Perceptron HOT 2
- Recurrent Neural Network HOT 1
- Restrict Boltzmann Machine HOT 2
- Convolutional Neural Net
- Use logistic regression to predict stock change
- Use multi-thread and queue to increase the speed of upload and download the data. HOT 1
- RBM: Why we must not compute the gradient through the gibbs sampling HOT 1
- Add clipping gradient to replace normal gradient
- Review pylearn2 and add necessary improvement.
- Use cPickle to speed up serialization
- Build Data Loader and Data Loader's DB HOT 2
- Build Model Loader and Model Saver HOT 4
- Build Trainer Class HOT 1
- Build Online tester HOT 1
- Store data's meta data for each data set HOT 2
- Rewrite logistic regression model to use DataLoader interface to load data. HOT 4
- Upload standard MNIST data set to database HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deeplearningresearch.