示例#1
0
std::complex<double> CuBlasMatrix::get(int row, int col)
{
    Q_ASSERT(row < rows);
    Q_ASSERT(col < cols);
    if(deviceDataChanged)
        updateHostData();
    return std::complex<double>(hostRaw[col * rows + row].x, hostRaw[col * rows + row].y);
}
示例#2
0
void CuBlasMatrix::set(int row, int col, std::complex<double> e)
{
    Q_ASSERT(row < rows);
    Q_ASSERT(col < cols);
    if(deviceDataChanged)
        updateHostData();
    cuDoubleComplex tmp = make_cuDoubleComplex(e.real(), e.imag());
    hostRaw[col * rows + row] = tmp;
    hostDataChanged = true;
}
示例#3
0
int BaseCostFunction::forwardUpdate(int timestep){
   Activation::forwardUpdate(timestep);

   //timestep + 2 to keep stats until writePeriod
   if((timestep + 2) % writePeriod == 0){
      //reset counts
      reset();
   }

   //Move device est and gt activity to host
   updateHostData();

   //Calculate costs and accuracy
   currCost = calcCost();
   currCorrect = calcCorrect();
   sumCost += currCost;
   numCorrect += currCorrect;
   numTests += bSize;


   if(estFilename != ""){
      writeEst();
   }
   //timestep + 1 to skip timestep 0
   if((timestep+1) % writePeriod == 0){
      if(costFilename != ""){
         costFile << timestep << "," << getAverageCost() << std::endl;
      }
      if(accuracyFilename != ""){
         accuracyFile << timestep << "," << getAccuracy() << std::endl;
         std::cout << "Timestep: " << timestep << " accuracy " << getAccuracy() << "\n";
      }
   }

   return SUCCESS;
}