lephong / lstm-rnn Goto Github PK
View Code? Open in Web Editor NEWlong short-term memory for recursive neural network model
License: Apache License 2.0
long short-term memory for recursive neural network model
License: Apache License 2.0
I wonder if you wrote a model using, for example, Keras that is equivalent to your C++ implementation. It is very interesting to look at the model written using frameworks such as Tensorflow. Would it be possible that you could have such implementation in your repository ?
Thanks
what is means dacc.first and dacc.second
I am learning, but I don't understand the function shown below. Could you please explain it in detail ?
Thank you,
void AbstractNN::checkGradient(Treebank* tb) {
real epsilon = 1e-4;
AbstractParam** grad = new AbstractParam*[nThreads];
for (int i = 0; i < nThreads; i++)
grad[i] = createGrad();
void** output = computeCostAndGrad(tb, 0, tb->size()-1, grad);
delete[] output;
vector<real> gradV;
vector<real> numGradV;
AbstractParam** otherGrad = new AbstractParam*[nThreads];
for (int i = 0; i < nThreads; i++)
otherGrad[i] = createGrad();
for (int i = 0; i < params->weights.size(); i++) {
Matrix* W = params->weights[i];
for (int r = 0; r < W->rows; r++)
for (int c = 0; c < W->cols; c++) {
gradV.push_back(grad[0]->weights[i]->get(r,c));
// plus
W->put(r, c, W->get(r,c)+epsilon);
output = computeCostAndGrad(tb, 0, tb->size()-1, otherGrad);
real pluscost = *(real*)output[0];
delete[] output;
// minus
W->put(r, c, W->get(r,c)-2*epsilon);
output = computeCostAndGrad(tb, 0, tb->size()-1, otherGrad);
real minuscost = *(real*)output[0];
delete[] output;
W->put(r, c, W->get(r,c)+epsilon);
numGradV.push_back((pluscost - minuscost) / (2*epsilon));
real diff = abs(numGradV.back() - gradV.back());
if (diff > 0 && abs(gradV.back()) < 1e-7)
cout << diff << " " << i << " " << r << " " << c << " : " << numGradV.back() << " " << gradV.back() << endl;
if (diff > 5e-9)
cout << diff << " " << i << " " << r << " " << c << " : " << numGradV.back() << " " << gradV.back() << endl;
}
}
Matrix* X = new Matrix((int)gradV.size(), &gradV[0]);
Matrix* Y = new Matrix((int)numGradV.size(), &numGradV[0]);
real diff = Matrix::nrm2(X->add(-1, Y)) / Matrix::nrm2(X->add(Y));
cout << diff << endl;
cout << "should be < 1e-9" << endl;
for (int i = 0; i < nThreads; i++) {
delete grad[i];
delete otherGrad[i];
}
delete[] grad;
delete[] otherGrad;
delete X;
delete Y;
}
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.