mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-11 06:15:56 +03:00
output tensors in shape
This commit is contained in:
parent
04a620db19
commit
f05d17e7ae
@ -176,8 +176,13 @@ class TensorImpl {
|
||||
std::vector<Float> values(totSize);
|
||||
thrust::copy(data_.begin(), data_.end(), values.begin());
|
||||
|
||||
for (size_t i = 0; i < totSize; ++i) {
|
||||
strm << values[i] << " ";
|
||||
size_t ind = 0;
|
||||
for (size_t i = 0; i < shape()[0]; ++i) {
|
||||
for (size_t j = 0; j < shape()[1]; ++j) {
|
||||
strm << values[ind] << " ";
|
||||
++ind;
|
||||
}
|
||||
strm << std::endl;
|
||||
}
|
||||
return strm.str();
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ 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");
|
||||
|
||||
Expr scores = dot(x, w) + b;
|
||||
Expr lr = softmax(scores, axis=1, name="pred");
|
||||
Expr z = dot(x, w) + b;
|
||||
Expr lr = softmax(z, axis=1, name="pred");
|
||||
Expr graph = -mean(sum(y * log(lr), axis=1), axis=0, name="cost");
|
||||
//cerr << "lr=" << Debug(lr.val().shape()) << endl;
|
||||
|
||||
@ -46,7 +46,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
graph.forward(500);
|
||||
|
||||
std::cerr << "scores: " << Debug(scores.val().shape()) << endl;
|
||||
std::cerr << "z: " << Debug(z.val().shape()) << endl;
|
||||
std::cerr << "lr: " << Debug(lr.val().shape()) << endl;
|
||||
std::cerr << "Log-likelihood: " << Debug(graph.val().shape()) << endl ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user