Minor fixes. Use CUDA 10.0

pull/2034/head
AlexeyAB 7 years ago
parent 14ed6fcb6e
commit 9f7d7c58b5
  1. 4
      build/darknet/darknet.vcxproj
  2. 4
      build/darknet/yolo_cpp_dll.vcxproj
  3. 34
      src/convolutional_kernels.cu
  4. 14
      src/image.c

@ -52,7 +52,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.1.props" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 10.0.props" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
@ -288,6 +288,6 @@
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.1.targets" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 10.0.targets" />
</ImportGroup> </ImportGroup>
</Project> </Project>

@ -52,7 +52,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.1.props" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 10.0.props" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
@ -291,6 +291,6 @@
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.1.targets" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 10.0.targets" />
</ImportGroup> </ImportGroup>
</Project> </Project>

@ -695,17 +695,29 @@ void update_convolutional_layer_gpu(convolutional_layer layer, int batch, float
adam_gpu(size, layer.weights_gpu, layer.m_gpu, layer.v_gpu, layer.B1, layer.B2, learning_rate/batch, layer.eps, layer.t+1); adam_gpu(size, layer.weights_gpu, layer.m_gpu, layer.v_gpu, layer.B1, layer.B2, learning_rate/batch, layer.eps, layer.t+1);
fill_ongpu(size, 0, layer.weight_updates_gpu, 1); fill_ongpu(size, 0, layer.weight_updates_gpu, 1);
}else{ }else{
// update weights: axpy_ongpu(size, -decay*batch, layer.weights_gpu, 1, layer.weight_updates_gpu, 1); // wu = wu - w*decay*batch
// weights_gpu = weights_gpu*(1 - decay*lr) + weight_updates_gpu*lr / (batch*subdivision) = axpy_ongpu(size, learning_rate/batch, layer.weight_updates_gpu, 1, layer.weights_gpu, 1); // w = w + wu*lr/batch
// weights_gpu*(1 - 0.0005*0.001) + weight_updates_gpu*0.001/(64*8) = scal_ongpu(size, momentum, layer.weight_updates_gpu, 1); // wu = wu*momentum // wu = (wu - w*decay*batch)*momentum
// weights_gpu * 0.999 999 5 + weight_updates_gpu * 0.000 001 953125 // w = w + (wu - w*decay*batch)*lr/batch = w + wu*lr/batch - w*decay*lr = w*(1-decay*lr) + wu*lr/batch
// //wu_prev = (wu_old - w_old*decay*batch)*momentum
// weight_updates_gpu = (weight_updates_gpu - weights_gpu*decay*batch*subdivision)*momentum =
// (weight_updates_gpu - weights_gpu * 0.0005 * 64 * 8) * 0.9 =
// weight_updates_gpu*0.9 - weights_gpu*0.2304 //weights_update = weights_update_new + (weights_update_old - weights_old*decay*batch)*momentum - weights_new*decay*batch =
axpy_ongpu(size, -decay*batch, layer.weights_gpu, 1, layer.weight_updates_gpu, 1); // = weights_update_new + weights_update_old*momentum - weights_old*decay*batch*momentum - weights_new*decay*batch
axpy_ongpu(size, learning_rate/batch, layer.weight_updates_gpu, 1, layer.weights_gpu, 1); // = weights_update_new + weights_update_old*momentum - (weights_old*momentum + weights_new)*decay*batch
scal_ongpu(size, momentum, layer.weight_updates_gpu, 1);
//------------- RESULT --------------
// weights_update = weights_update_new + weights_update_old*momentum - (weights_old*momentum + weights_new)*decay*batch
//-----------------------------------
// weights_newest = weights_new + (weights_update_new + weights_update_old*momentum - (weights_old*momentum + weights_new)*decay*batch)*lr/batch
// = weights_new + weights_update_new*lr/batch + weights_update_old*momentum*lr/batch - weights_old*momentum*decay*batch*lr/batch - weights_new*decay*batch*lr/batch
// = weights_new + weights_update_new*lr/batch + weights_update_old*momentum*lr/batch - weights_old*momentum*decay*lr - weights_new*decay*lr
// = weights_new*(1 - decay*lr) - weights_old*momentum*decay*lr + (weights_update_new + weights_update_old*momentum)*lr/batch
//------------- RESULT --------------
// weights_newest = weights_new*(1 - decay*lr) - weights_old*momentum*(decay*lr) + (weights_update_new + weights_update_old*momentum)*lr/batch
//-----------------------------------
} }
} }

@ -705,6 +705,9 @@ IplImage* draw_train_chart(float max_img_loss, int max_batches, int number_of_li
} }
} }
cvPutText(img, "Iteration number", cvPoint(draw_size / 2, img_size - 10), &font, CV_RGB(0, 0, 0)); cvPutText(img, "Iteration number", cvPoint(draw_size / 2, img_size - 10), &font, CV_RGB(0, 0, 0));
char max_batches_buff[100];
sprintf(max_batches_buff, "in cfg max_batches=%d", max_batches);
cvPutText(img, max_batches_buff, cvPoint(draw_size - 195, img_size - 10), &font, CV_RGB(0, 0, 0));
cvPutText(img, "Press 's' to save: chart.jpg", cvPoint(5, img_size - 10), &font, CV_RGB(0, 0, 0)); cvPutText(img, "Press 's' to save: chart.jpg", cvPoint(5, img_size - 10), &font, CV_RGB(0, 0, 0));
printf(" If error occurs - run training with flag: -dont_show \n"); printf(" If error occurs - run training with flag: -dont_show \n");
cvNamedWindow("average loss", CV_WINDOW_NORMAL); cvNamedWindow("average loss", CV_WINDOW_NORMAL);
@ -728,15 +731,20 @@ void draw_train_loss(IplImage* img, int img_size, float avg_loss, float max_img_
if (pt1.y < 0) pt1.y = 1; if (pt1.y < 0) pt1.y = 1;
cvCircle(img, pt1, 1, CV_RGB(0, 0, 255), CV_FILLED, 8, 0); cvCircle(img, pt1, 1, CV_RGB(0, 0, 255), CV_FILLED, 8, 0);
sprintf(char_buff, "current avg loss = %2.4f", avg_loss); sprintf(char_buff, "current avg loss = %2.4f iteration = %d", avg_loss, current_batch);
pt1.x = img_size / 2, pt1.y = 30; pt1.x = img_size / 2, pt1.y = 30;
pt2.x = pt1.x + 250, pt2.y = pt1.y + 20; pt2.x = pt1.x + 460, pt2.y = pt1.y + 20;
cvRectangle(img, pt1, pt2, CV_RGB(255, 255, 255), CV_FILLED, 8, 0); cvRectangle(img, pt1, pt2, CV_RGB(255, 255, 255), CV_FILLED, 8, 0);
pt1.y += 15; pt1.y += 15;
cvPutText(img, char_buff, pt1, &font, CV_RGB(0, 0, 0)); cvPutText(img, char_buff, pt1, &font, CV_RGB(0, 0, 0));
cvShowImage("average loss", img); cvShowImage("average loss", img);
int k = cvWaitKey(20); int k = cvWaitKey(20);
if (k == 's' || current_batch == (max_batches-1)) cvSaveImage("chart.jpg", img, 0); if (k == 's' || current_batch == (max_batches - 1)) {
cvSaveImage("chart.jpg", img, 0);
cvPutText(img, "- Saved", cvPoint(250, img_size - 10), &font, CV_RGB(255, 0, 0));
}
else
cvPutText(img, "- Saved", cvPoint(250, img_size - 10), &font, CV_RGB(255, 255, 255));
} }
#endif // OPENCV #endif // OPENCV

Loading…
Cancel
Save