delete StoreTensorInVec(), Use <<

This commit is contained in:
Hieu Hoang 2016-09-22 15:03:46 +01:00
parent c138c68e6a
commit 451d7cda81
4 changed files with 6 additions and 12 deletions

View File

@ -114,14 +114,6 @@ float Node::L2Norm(const std::vector<float> &vec) const
return sqrt(ret);
}
std::vector<float> Node::StoreTensorInVec(Tensor tensor)
{
size_t totSize = GetTotalSize(tensor.shape());
std::vector<float> vec(totSize);
thrust::copy(tensor.begin(), tensor.end(), vec.begin());
return vec;
}
void Node::broadcast(const std::vector<float> &largeVec, std::vector<float> &smallVec)
{
size_t largeSize = largeVec.size();

View File

@ -122,7 +122,6 @@ class Node : public Chainable<Tensor>,
std::cerr << std::endl;
}
std::vector<float> StoreTensorInVec(Tensor tensor);
void calc_numeric_grad(
Float delta,
Tensor input,

View File

@ -17,10 +17,12 @@ struct BinaryNodeOp : public Node {
cerr << "BinaryNodeOp::" << typeid(*this).name() << "::backward_debug()" << endl;
std::vector<float> preCalcGradA = StoreTensorInVec(a_->grad());
std::vector<float> preCalcGradA;
preCalcGradA << a_->grad();
//output("preCalcGradA", preCalcGradA);
std::vector<float> preCalcGradB = StoreTensorInVec(b_->grad());
std::vector<float> preCalcGradB;
preCalcGradB << b_->grad();
//output("preCalcGradB", preCalcGradB);
// use df/dx to calc grad

View File

@ -17,7 +17,8 @@ struct UnaryNodeOp : public Node {
cerr << "UnaryNodeOp::" << typeid(*this).name() << "::backward_numeric()" << endl;
std::vector<float> preCalcGradA = StoreTensorInVec(a_->grad());
std::vector<float> preCalcGradA;
preCalcGradA << a_->grad();
//output("preCalcGradA", preCalcGradA);
// use df/dx to calc grad