mirror of
https://github.com/marian-nmt/marian.git
synced 2024-11-03 20:13:47 +03:00
delete StoreTensorInVec(), Use <<
This commit is contained in:
parent
c138c68e6a
commit
451d7cda81
@ -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();
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user