                                 theta2Rows * theta2Cols );
 
   tempMatrix = (floatType_t *) malloc( sizeof(floatType_t) *
-                               ( Xexamples * (theta1Rows+1) + 
-                                 Xexamples * (theta1Rows+1) +
-                                 Xexamples * (theta2Rows+1) + 
-                                 theta2Cols + 11) );
+                               ( Xexamples * (theta1Rows+1) + //z2 
+                                 Xexamples * (theta1Rows+1) + //a2
+                                 Xexamples * (theta2Rows+1) + //a3
+                                 Xexamples * (theta1Rows+1) + //delta2
+                                 Xexamples * 11 ) );            //delta3
 
   for( int i = 0; i < Xexamples; i++ ) 
     X[INDX(0,i,Xfeatures)] = (floatType_t) 1.0;

  checkCUDNN( cudnnCreate( &cudnnHandle ) );
  checkCUDNN( cudnnCreateTensorDescriptor( &srcTensorDesc ) );
  checkCUDNN( cudnnCreateTensorDescriptor( &destTensorDesc ) );
  checkCUBLAS( cublasCreate( &cublasHandle ) );

  theta1Grad = (floatType_t *) malloc( sizeof(floatType_t) * 


cudnnHandle_t cudnnHandle;
cudnnTensorDescriptor_t srcTensorDesc, destTensorDesc;
cudnnTensorDescriptor_t srcDiffTensorDesc, destDiffTensorDesc;
cublasHandle_t cublasHandle;

__global__ void  setYVec( floatType_t       *delta3, 
                          floatType_t const *Y, 
                          floatType_t const *a3,
                          int         const  Xexamples )
{
  int tid = blockDim.x * blockIdx.x + threadIdx.x;
  if( tid < Xexamples )
  {
    delta3[INDX((int)Y[tid],tid,11)] = (floatType_t) 1.0;
    for( int j = 0; j < 10; j++ )
    {
      delta3[INDX(j+1,tid,11)] = a3[INDX(tid,j,Xexamples)]
                               - delta3[INDX(j+1,tid,11)];
    } /* end for j */
  }
  return;
} /* end setYVec */

__global__ void setVals( int rows, floatType_t *array )
{
