Skip to content

Commit e054e64

Browse files
committed
Added check to MNIST learn example. If provided images/labels file does not exist, exception will be thrown: KasperskyLab#161
1 parent f96c9f7 commit e054e64

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

examples/mnist-learn/dataset.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828

2929
Dataset process_dataset(ModelDescription const& model_desc)
3030
{
31+
// Check if files exist.
32+
if (!std::filesystem::exists(model_desc.images_file_path_))
33+
throw std::runtime_error("Provided images file does not exists.");
34+
else if (!std::filesystem::exists(model_desc.labels_file_path_))
35+
throw std::runtime_error("Provided labels file does not exists.");
36+
3137
// Create streams for images and labels.
3238
std::ifstream images_stream(model_desc.images_file_path_, std::ios::binary);
3339
std::ifstream labels_stream(model_desc.labels_file_path_, std::ios::in);

0 commit comments

Comments
 (0)