Skip to content
Snippets Groups Projects
Commit 0a88e965 authored by Kim Albertsson's avatar Kim Albertsson Committed by Lorenzo Moneta
Browse files

[TMVA] ROOT-9444 -- Also update call sites

parent 6ab3880e
No related branches found
No related tags found
No related merge requests found
...@@ -316,8 +316,8 @@ auto TConvLayer<Architecture_t>::Forward(std::vector<Matrix_t> &input, bool /*ap ...@@ -316,8 +316,8 @@ auto TConvLayer<Architecture_t>::Forward(std::vector<Matrix_t> &input, bool /*ap
// printf("Layer parameters : %d x %d , filter %d x %d , stride %d %d , pad %d %d \n",this->GetInputHeight(), this->GetInputWidth(), this->GetFilterHeight(), // printf("Layer parameters : %d x %d , filter %d x %d , stride %d %d , pad %d %d \n",this->GetInputHeight(), this->GetInputWidth(), this->GetFilterHeight(),
// this->GetFilterWidth(), this->GetStrideRows(), this->GetStrideCols(), // this->GetFilterWidth(), this->GetStrideRows(), this->GetStrideCols(),
// this->GetPaddingHeight(), this->GetPaddingWidth() ); // this->GetPaddingHeight(), this->GetPaddingWidth() );
// // PrintMatrix(inputTr); // // TMVA_DNN_PrintTCpuMatrix(inputTr);
// //PrintMatrix(inputTr2); // // TMVA_DNN_PrintTCpuMatrix(inputTr2);
// } // }
// R__ASSERT(!diff); // R__ASSERT(!diff);
Architecture_t::MultiplyTranspose(this->GetOutputAt(i), this->GetWeightsAt(0), inputTr); Architecture_t::MultiplyTranspose(this->GetOutputAt(i), this->GetWeightsAt(0), inputTr);
......
...@@ -142,7 +142,7 @@ void TCpu<AFloat>::Im2col(TCpuMatrix<AFloat> &A, const TCpuMatrix<AFloat> &B, si ...@@ -142,7 +142,7 @@ void TCpu<AFloat>::Im2col(TCpuMatrix<AFloat> &A, const TCpuMatrix<AFloat> &B, si
currLocalView++; currLocalView++;
} }
} }
//PrintMatrix(A,"FromIm2Col"); //TMVA_DNN_PrintTCpuMatrix(A,"FromIm2Col");
} }
//____________________________________________________________________________ //____________________________________________________________________________
...@@ -234,8 +234,8 @@ void TCpu<AFloat>::Im2colFast(TCpuMatrix<AFloat> &A, const TCpuMatrix<AFloat> &B ...@@ -234,8 +234,8 @@ void TCpu<AFloat>::Im2colFast(TCpuMatrix<AFloat> &A, const TCpuMatrix<AFloat> &B
} }
#endif #endif
// PrintMatrix(A,"FromFastIm2Col"); // TMVA_DNN_PrintTCpuMatrix(A,"FromFastIm2Col");
// PrintMatrix(B,"input to Im2Col"); // TMVA_DNN_PrintTCpuMatrix(B,"input to Im2Col");
// std::cout << "V vector " << V.size() << std::endl; // std::cout << "V vector " << V.size() << std::endl;
// for ( int i = 0; i < n; ++i) { // for ( int i = 0; i < n; ++i) {
// std::cout << V[i] << " "; // std::cout << V[i] << " ";
...@@ -386,11 +386,11 @@ void TCpu<AFloat>::CalculateConvActivationGradients(std::vector<TCpuMatrix<AFloa ...@@ -386,11 +386,11 @@ void TCpu<AFloat>::CalculateConvActivationGradients(std::vector<TCpuMatrix<AFloa
// Transform the weights // Transform the weights
//PrintMatrix(weights,"weights"); //TMVA_DNN_PrintTCpuMatrix(weights,"weights");
// filter depth must be same as input depth // filter depth must be same as input depth
TCpuMatrix<AFloat> rotWeights(filterDepth, depth * filterHeight * filterWidth); TCpuMatrix<AFloat> rotWeights(filterDepth, depth * filterHeight * filterWidth);
RotateWeights(rotWeights, weights, filterDepth, filterHeight, filterWidth, weights.GetNrows()); RotateWeights(rotWeights, weights, filterDepth, filterHeight, filterWidth, weights.GetNrows());
//PrintMatrix(rotWeights,"rot-weights"); //TMVA_DNN_PrintTCpuMatrix(rotWeights,"rot-weights");
// Calculate the zero paddings // Calculate the zero paddings
size_t tempZeroPaddingHeight = (size_t)(floor((inputHeight - height + filterHeight - 1) / 2)); size_t tempZeroPaddingHeight = (size_t)(floor((inputHeight - height + filterHeight - 1) / 2));
...@@ -426,12 +426,12 @@ void TCpu<AFloat>::CalculateConvActivationGradients(std::vector<TCpuMatrix<AFloa ...@@ -426,12 +426,12 @@ void TCpu<AFloat>::CalculateConvActivationGradients(std::vector<TCpuMatrix<AFloa
Im2colFast(dfTr, df[i], vIndices); Im2colFast(dfTr, df[i], vIndices);
//PrintMatrix(df[i],"df[i]"); //TMVA_DNN_PrintTCpuMatrix(df[i],"df[i]");
//PrintMatrix(dfTr,"dfTr"); //TMVA_DNN_PrintTCpuMatrix(dfTr,"dfTr");
MultiplyTranspose(activationGradientsBackward[i], rotWeights, dfTr); MultiplyTranspose(activationGradientsBackward[i], rotWeights, dfTr);
//PrintMatrix(activationGradientsBackward[i],"activGrad-result"); //TMVA_DNN_PrintTCpuMatrix(activationGradientsBackward[i],"activGrad-result");
}; };
...@@ -475,14 +475,14 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie ...@@ -475,14 +475,14 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie
std::vector< TCpuMatrix<AFloat> > vres;//(batchSize); std::vector< TCpuMatrix<AFloat> > vres;//(batchSize);
for (size_t i = 0; i < batchSize; i++) { for (size_t i = 0; i < batchSize; i++) {
vres.emplace_back(depth, nLocalViewPixels); vres.emplace_back(depth, nLocalViewPixels);
//PrintMatrix(df[i],"df"); //TMVA_DNN_PrintTCpuMatrix(df[i],"df");
//PrintMatrix(activationsBackward[i],"df"); //TMVA_DNN_PrintTCpuMatrix(activationsBackward[i],"df");
} }
auto fmap = [&](int i) { auto fmap = [&](int i) {
//PrintMatrix(df[i],"df-i"); //TMVA_DNN_PrintTCpuMatrix(df[i],"df-i");
TCpuMatrix<AFloat> xTr(nLocalViews, nLocalViewPixels); TCpuMatrix<AFloat> xTr(nLocalViews, nLocalViewPixels);
TCpuMatrix<AFloat> res(depth, nLocalViewPixels); TCpuMatrix<AFloat> res(depth, nLocalViewPixels);
...@@ -495,10 +495,10 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie ...@@ -495,10 +495,10 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie
Im2colFast(xTr, activationsBackward[i], vIndices); Im2colFast(xTr, activationsBackward[i], vIndices);
//std::cout << "doing im2colfast" << std::endl; //std::cout << "doing im2colfast" << std::endl;
//PrintMatrix(xTr,"xTr-i"); //TMVA_DNN_PrintTCpuMatrix(xTr,"xTr-i");
//PrintMatrix(activationsBackward[i],"actbackward-i"); //TMVA_DNN_PrintTCpuMatrix(activationsBackward[i],"actbackward-i");
Multiply(vres[i], df[i], xTr); Multiply(vres[i], df[i], xTr);
//PrintMatrix(vres[i],"res_ofMT"); //TMVA_DNN_PrintTCpuMatrix(vres[i],"res_ofMT");
return; return;
//return res; //return res;
...@@ -509,7 +509,7 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie ...@@ -509,7 +509,7 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie
// auto freduce = [&](const std::vector<TCpuMatrix<AFloat>> & vres) { // auto freduce = [&](const std::vector<TCpuMatrix<AFloat>> & vres) {
R__ASSERT(vres.size() == batchSize); R__ASSERT(vres.size() == batchSize);
for (size_t i = 0; i < batchSize; i++) { for (size_t i = 0; i < batchSize; i++) {
//PrintMatrix(vres[i],"res"); //TMVA_DNN_PrintTCpuMatrix(vres[i],"res");
for (size_t j = 0; j < depth; j++) { for (size_t j = 0; j < depth; j++) {
for (size_t k = 0; k < filterDepth; k++) { for (size_t k = 0; k < filterDepth; k++) {
size_t kOffset = k * filterSize; size_t kOffset = k * filterSize;
...@@ -519,12 +519,12 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie ...@@ -519,12 +519,12 @@ void TCpu<AFloat>::CalculateConvWeightGradients(TCpuMatrix<AFloat> &weightGradie
} }
} }
} }
// PrintMatrix(weightGradients,"weights_i"); // TMVA_DNN_PrintTCpuMatrix(weightGradients,"weights_i");
} }
// }; // };
//TCpuMatrix<AFloat>::GetThreadExecutor().MapReduce(fmap, ROOT::TSeqI( batchSize ) , freduce); //TCpuMatrix<AFloat>::GetThreadExecutor().MapReduce(fmap, ROOT::TSeqI( batchSize ) , freduce);
//PrintMatrix(weightGradients,"W-Grad"); //TMVA_DNN_PrintTCpuMatrix(weightGradients,"W-Grad");
} }
//____________________________________________________________________________ //____________________________________________________________________________
......
...@@ -39,11 +39,11 @@ auto TCpu<AFloat>::RecurrentLayerBackward(TCpuMatrix<AFloat> & state_gradients_b ...@@ -39,11 +39,11 @@ auto TCpu<AFloat>::RecurrentLayerBackward(TCpuMatrix<AFloat> & state_gradients_b
{ {
// std::cout << "Recurrent Propo" << std::endl; // std::cout << "Recurrent Propo" << std::endl;
// PrintMatrix(df,"DF"); // TMVA_DNN_PrintTCpuMatrix(df,"DF");
// PrintMatrix(state_gradients_backward,"State grad"); // TMVA_DNN_PrintTCpuMatrix(state_gradients_backward,"State grad");
// PrintMatrix(input_weight_gradients,"input w grad"); // TMVA_DNN_PrintTCpuMatrix(input_weight_gradients,"input w grad");
// PrintMatrix(state,"state"); // TMVA_DNN_PrintTCpuMatrix(state,"state");
// PrintMatrix(input,"input"); // TMVA_DNN_PrintTCpuMatrix(input,"input");
// Compute element-wise product. // Compute element-wise product.
Hadamard(df, state_gradients_backward); // B x H Hadamard(df, state_gradients_backward); // B x H
...@@ -73,10 +73,10 @@ auto TCpu<AFloat>::RecurrentLayerBackward(TCpuMatrix<AFloat> & state_gradients_b ...@@ -73,10 +73,10 @@ auto TCpu<AFloat>::RecurrentLayerBackward(TCpuMatrix<AFloat> & state_gradients_b
//std::cout << "RecurrentPropo: end " << std::endl; //std::cout << "RecurrentPropo: end " << std::endl;
// PrintMatrix(state_gradients_backward,"State grad"); // TMVA_DNN_PrintTCpuMatrix(state_gradients_backward,"State grad");
// PrintMatrix(input_weight_gradients,"input w grad"); // TMVA_DNN_PrintTCpuMatrix(input_weight_gradients,"input w grad");
// PrintMatrix(bias_gradients,"bias grad"); // TMVA_DNN_PrintTCpuMatrix(bias_gradients,"bias grad");
// PrintMatrix(input_gradient,"input grad"); // TMVA_DNN_PrintTCpuMatrix(input_gradient,"input grad");
return input_gradient; return input_gradient;
} }
......
...@@ -454,7 +454,7 @@ auto testConvBackwardPass(size_t batchSize, size_t imgDepth, size_t imgHeight, s ...@@ -454,7 +454,7 @@ auto testConvBackwardPass(size_t batchSize, size_t imgDepth, size_t imgHeight, s
// std::cout << "Netwrok weights for Layer 0 " << std::endl; // std::cout << "Netwrok weights for Layer 0 " << std::endl;
// std::cout << "weight depth = " << w0.size() << std::endl; // std::cout << "weight depth = " << w0.size() << std::endl;
// for (size_t i = 0; i < w0.size(); ++i) // for (size_t i = 0; i < w0.size(); ++i)
// PrintMatrix(w0[i],"weight-layer0"); // TMVA_DNN_PrintTCpuMatrix(w0[i],"weight-layer0");
// #endif // #endif
std::vector<Matrix_t> X; std::vector<Matrix_t> X;
...@@ -465,7 +465,7 @@ auto testConvBackwardPass(size_t batchSize, size_t imgDepth, size_t imgHeight, s ...@@ -465,7 +465,7 @@ auto testConvBackwardPass(size_t batchSize, size_t imgDepth, size_t imgHeight, s
// print input // print input
#ifdef DEBUGH #ifdef DEBUGH
std::cout << "INPUT - batch " << i << std::endl; std::cout << "INPUT - batch " << i << std::endl;
PrintMatrix(X[i],"input"); TMVA_DNN_PrintTCpuMatrix(X[i],"input");
#endif #endif
} }
...@@ -487,7 +487,7 @@ auto testConvBackwardPass(size_t batchSize, size_t imgDepth, size_t imgHeight, s ...@@ -487,7 +487,7 @@ auto testConvBackwardPass(size_t batchSize, size_t imgDepth, size_t imgHeight, s
auto & df = convLayer->GetDerivatives(); auto & df = convLayer->GetDerivatives();
std::cout << "Derivatives - size " << df.size() << std::endl; std::cout << "Derivatives - size " << df.size() << std::endl;
for (size_t ii=0; ii< df.size(); ++ii) for (size_t ii=0; ii< df.size(); ++ii)
PrintMatrix(df[ii],"Derivatives"); TMVA_DNN_PrintTCpuMatrix(df[ii],"Derivatives");
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment