Pure_Optical_CUDA / utils.cpp
Agnuxo's picture
Upload 36 files
db3c893 verified
raw
history blame contribute delete
912 Bytes
#include "utils.hpp"
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <iomanip>
void check_cuda(cudaError_t st, const char* msg) {
if (st != cudaSuccess) {
std::cerr << "[CUDA ERROR] " << msg << ": " << cudaGetErrorString(st) << "\n";
std::exit(1);
}
}
void write_submission_csv(const std::string& path,
const std::vector<std::string>& ids,
const std::vector<float>& probabilities) {
std::ofstream ofs(path);
if (!ofs.is_open()) {
throw std::runtime_error("Cannot open submission file: " + path);
}
ofs << "id,label\n";
ofs << std::fixed << std::setprecision(8);
for (size_t i = 0; i < ids.size(); ++i) {
ofs << ids[i] << "," << probabilities[i] << "\n";
}
ofs.close();
std::cout << "[INFO] Submission saved to: " << path << " (" << ids.size() << " rows)\n";
}