This commit is contained in:
Hieu Hoang 2016-09-19 17:39:40 +01:00
parent 2a9d3de35a
commit bcba5e171c
3 changed files with 25 additions and 12 deletions

View File

@ -13,7 +13,17 @@ struct BinaryNodeOp : public Node {
: Node(args...), a_(a), b_(b) {}
void backward_numeric() {
using namespace std;
cerr << "BinaryNodeOp::" << typeid(*this).name() << "::backward_numeric" << endl;
cerr << "BEFORE:" << endl;
cerr << "a_->grad()=" << a_->grad().Debug() << endl;
cerr << "b_->grad()=" << b_->grad().Debug() << endl;
cerr << "adj_=" << adj_.Debug() << endl;
backward();
cerr << "AFTER:" << endl;
cerr << "a_->grad()=" << a_->grad().Debug() << endl;
cerr << "b_->grad()=" << b_->grad().Debug() << endl;
cerr << "adj_=" << adj_.Debug() << endl;
}
};

View File

@ -12,7 +12,15 @@ struct UnaryNodeOp : public Node {
args...), a_(a) {}
void backward_numeric() {
using namespace std;
cerr << "BinaryNodeOp::" << typeid(*this).name() << "::backward_numeric" << endl;
cerr << "BEFORE:" << endl;
cerr << "a_->grad()=" << a_->grad().Debug() << endl;
cerr << "adj_=" << adj_.Debug() << endl;
backward();
cerr << "AFTER:" << endl;
cerr << "a_->grad()=" << a_->grad().Debug() << endl;
cerr << "adj_=" << adj_.Debug() << endl;
}
};

View File

@ -405,17 +405,12 @@ class Tensor {
*/
std::string Debug() const
{
if (!pimpl_) {
return "Not yet set";
}
else {
return pimpl_->Debug();
}
/**
* @brief Print Tensor data on CPU (?) (const).
*/
void Print() const {
for (int i = 0; i < size(); ++i) {
std::cerr << (*this)[i] << " ";
}
std::cerr << std::endl;
}
//void Load(const std::string &path);