From 9643f52aa5dae8f9c1d8435b777ceeaaeb76ea57 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Wed, 14 Sep 2016 14:30:23 +0200 Subject: [PATCH] debug --- src/tensor.h | 6 ++++-- src/test.cu | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/tensor.h b/src/tensor.h index 02e1645f..499e1ae0 100644 --- a/src/tensor.h +++ b/src/tensor.h @@ -172,11 +172,13 @@ class TensorImpl { strm << "shape=" << marian::Debug(shape_) << std::endl; // values - /* size_t totSize = GetTotalSize(shape()); std::vector values(totSize); thrust::copy(data_.begin(), data_.end(), values.begin()); - */ + + for (size_t i = 0; i < totSize; ++i) { + strm << values[i] << " "; + } return strm.str(); } }; diff --git a/src/test.cu b/src/test.cu index 6a4ef4bf..dec93919 100644 --- a/src/test.cu +++ b/src/test.cu @@ -21,10 +21,10 @@ int main(int argc, char** argv) { Expr w = param(shape={IMAGE_SIZE, LABEL_SIZE}, name="W0"); Expr b = param(shape={1, LABEL_SIZE}, name="b0"); - auto scores = dot(x, w) + b; - auto lr = softmax(scores, axis=1, name="pred"); - auto graph = -mean(sum(y * log(lr), axis=1), axis=0, name="cost"); - cerr << "lr=" << lr.Debug() << endl; + Expr scores = dot(x, w) + b; + Expr lr = softmax(scores, axis=1, name="pred"); + Expr graph = -mean(sum(y * log(lr), axis=1), axis=0, name="cost"); + cerr << "lr=" << Debug(lr.val().shape()) << endl; int numofdata; vector images = datasets::mnist::ReadImages("../examples/mnist/t10k-images-idx3-ubyte", numofdata, IMAGE_SIZE); @@ -38,8 +38,8 @@ int main(int argc, char** argv) { tx.Load(images); ty.Load(labels); - cerr << "tx=" << tx.Debug() << endl; - cerr << "ty=" << ty.Debug() << endl; + cerr << "tx=" << Debug(tx.shape()) << endl; + cerr << "ty=" << Debug(ty.shape()) << endl; x = tx; y = ty; @@ -50,6 +50,8 @@ int main(int argc, char** argv) { std::cerr << "lr: " << Debug(lr.val().shape()) << endl; std::cerr << "Log-likelihood: " << Debug(graph.val().shape()) << endl ; + std::cerr << "scores=" << scores.val().Debug() << endl; + graph.backward(); //std::cerr << graph["pred"].val()[0] << std::endl;