Closed xinsuinizhuan closed 5 years ago
BC::nn::MAPE returns an "expression object" (opposed to a primitive data type).
All operations/expressions with Tensors return expression objects.
Originally BC::sum
returned a scalar (double, float, or int) however this was inconsistent with the rest of the framework.
To get the value you can do something like....
double error = BC::Scalar<double>(BC::nn::MAPE(hyps, outputs)).data()[0]
BC::Scalar
What you could do if you just want to log the error would be.... std::cout << (BC::nn::MAPE(hyps, outputs[0]) / batch_size).to_string() << std::endl;
Oh, i see !Thank you!
BC::nn::MAPE returns an "expression object" (opposed to a primitive data type).
All operations/expressions with Tensors return
expression objects.
OriginallyBC::sum
returned a scalar (double, float, or int) however this was inconsistent with the rest of the framework.To get the value you can do something like....
double error = BC::Scalar<double>(BC::nn::MAPE(hyps, outputs)).data()[0]
BC::Scalar will evaluate the expression BC::nn::MAPE(hyps, outputs) .data() //returns the internal pointer (IE double*) [0] //gets the first value of the pointer
when i use the below, run it, it break:
double error = BC::Scalar
What you could do if you just want to log the error would be.... std::cout << (BC::nn::MAPE(hyps, outputs[0]) / batch_size).to_string() << std::endl;
this expression is ok!
What are you writing for this exactly:
double error = BC::Scalar(BC::nn::MAPE(hyps, outputs)).data()[0]
as it works on my setup without an issue.
If this works:
std::cout << (BC::nn::MAPE(hyps, outputs[0]) / batch_size).to_string() << std::endl;
this should work also:
BC::Scalar<double>(BC::nn::MAPE(hyps, outputs[0]) / batch_size).data()[0];
BC::Scalar
(BC::nn::MAPE(hyps, outputs[0]) / batch_size).data()[0];
OK.below three methods is ok:
std::cout << (BC::Scalar
std::cout << BC::Scalar
double error = (BC::Scalar
I believe you need to specify the BC::Scalar<double>(BC::nn::MAPE(hyps, outputs[0]) / batch_size).data()[0];
Though I would expect a compile error not a runtime error.
One new problem, the newest code, mnist_test_recurrent example, compile it, error as:
According to Microsoft:
"The C language allows implicit narrowing conversions in assignments and initialization, and C++ follows suit, even though unexpected narrowing is a cause of many code errors. To make code safer, the C++ standard requires a diagnostic message when a narrowing conversion occurs in an initialization list. In Visual C++, the diagnostic is Compiler Error C2397 when using the uniform initialization syntax supported beginning in Visual Studio 2015. The compiler generates Compiler Warning (level 1) C4838 when using the list or aggregate initialization syntax supported by Visual Studio 2013."
So this should actually be a warning, however Visual Studio treats it as an error.
This has been fixed as of: https://github.com/josephjaspers/blackcat_tensors/commit/34a189142a720c5a7ad37aa0b628c189658892c5
Oh,i see.
Yeah sorry about that, I'll try to add narrowing conversion as an error so I'll catch it next time. Thanks again
narrowing conversion again:
shoud be:
template
Good catch, thanks for that. I will make those changes soon
I print the average loss,but the BC can not implicit conversion to double?