josephjaspers / blackcat_tensors

Matrix-Vector Library Designed for Neural Network Construction. cuda (gpu) support, openmp (multithreaded cpu) support, partial support of BLAS, expression template based implementation PTX code generation identical to hand written kernels, and support for auto-differentiation
12 stars 4 forks source link

data conver precision problem! #42

Closed xinsuinizhuan closed 4 years ago

xinsuinizhuan commented 4 years ago

I use this way to inputdata to system: 图片

my original double data: 图片 when i conver it to inner: 图片 my convered double data precision is %1f. How should i do?

josephjaspers commented 4 years ago

Are you sure the data is losing precision or is it just being printed with a lower precision?

You can use

int precision = 5;
tensor.print(precision); 

To change the output precision.

Likewise to copy data from a vector you could even just do... (assuming no cuda) for (int i = 0; i < vector.size(); ++i) { tensor.data()[i] = vector[i]; }

Or better yet:

BC::copy(BC::Stream<system_tag>(), vector.begin(), vector.end(), tensor.cw_begin()); 
xinsuinizhuan commented 4 years ago

BC::copy(BC::Stream(), vector.begin(), vector.end(), tensor.cw_begin());

OK. I am so sorry.Data conver precision is ok,i am use the "print(3)".

josephjaspers commented 4 years ago

No problem!