Closed xinsuinizhuan closed 4 years ago
Seems good for now. The only issue I can think of is that it won't work for non-continuous tensors. Feel free to make a pull-request on any features you want to add.
Looks good to me! It seems that it won't work for non-continuous tensors (thought I will an nd-iterator to handle this later).
It seems you are trying to assign a slice of a matrix to a std::vector.
You can assign element-by-element though.
BC::Cube<float> data_cube(4,2,1);
std::vector<std::vector<float>> data = { {1,2,3,4}, {1,2,3,4}};
for (std::size_t i = 0; i < data.size(); ++i) {
for (std::size_t j = 0; j < data[i].size(); ++j) {
data_cube[0][i][j] = data[i][j];
}
}
In addition, when i get the forward_propagation data, how could i put them into my vector?
mat hyps = network->m_pnetwork.forward_propagation(inputs[0]);
I want get the data from hyps to my vector and array? How should i do? Is it ok?
std::vector
You can use BC's algorithms to copy data (include/algorithms/Algorithms.h)
outputvec = std::vector(hyps.size());
BC::copy(hyps.get_stream(), outputvec.begin(), outputvec.end(), hyps.cw_begin());
Its nearly identical to std::copy if you are only using host_tensors though it is data-safe if you ever want to switch to GPU mode (cuda).
The differences between cw.begin() and begin() is that cw_begin returns the coefficientwise iterator (element by element) while begin returns the 'multi-dimensional' iterator.
Here's the (rather brief) documentation on this https://github.com/josephjaspers/blackcat_tensors/blob/master/docs/algorithms.md
Yes, when i use :
std::vector
I read my txt'file data to the vector, then when i put my vectror data to the model, compile, it error:
I add the under function to Tensor_Utility.h, and it compile normal, is it ok? void data_format_convers(std::vector & maxmindata) {
std::vector file_data;