Программы на C++. Форум разработчиков
Anonymous
Почему бы не переместить указатель файла набора данных в заголовок при обучении набора данных fashion-mnist после каждой
Сообщение
Anonymous » 12 дек 2024, 03:18
Я реализую искусственную нейронную сеть (ИНС) на C++, используя набор данных fashion-mnist на основе этого исходного кода.
Это обучающий код:
Код: Выделить всё
#include
#include
using namespace std;
ifstream image;
ifstream label;
double input[784];
double expected[10];
void next_sample()
{
char number;
//read the next image
for (int i = 0; i < 28; i++){
for (int j = 0;j < 28; j++){
image.read(&number, sizeof(char));
input[i * 28 + j]=number / 255.0;
}
}
//read the next label
label.read(&number, sizeof(char));
for (int i = 0; i < 10; ++i) {
expected[i] = 0.0;
}
expected[number] = 1.0;
}
int main()
{
image.open("train-images-idx3-ubyte", ios::in | ios::binary); // Binary image file
label.open("train-labels-idx1-ubyte", ios::in | ios::binary ); // Binary label file
char number;
for (int i = 0; i < 16; i++) { //read the header in the image file
image.read(&number, sizeof(char));
}
for (int i = 0; i < 8; i++) { //read the header in the label file
label.read(&number, sizeof(char));
}
for (int e = 0;e < 5;e++){
for (int sample = 1; sample
Подробнее здесь: [url]https://stackoverflow.com/questions/79272252/why-dont-move-the-dataset-file-pointer-to-the-header-when-training-the-fashion[/url]
1733962690
Anonymous
Я реализую искусственную нейронную сеть (ИНС) на C++, используя набор данных fashion-mnist на основе этого исходного кода. Это обучающий код: [code]#include #include using namespace std; ifstream image; ifstream label; double input[784]; double expected[10]; void next_sample() { char number; //read the next image for (int i = 0; i < 28; i++){ for (int j = 0;j < 28; j++){ image.read(&number, sizeof(char)); input[i * 28 + j]=number / 255.0; } } //read the next label label.read(&number, sizeof(char)); for (int i = 0; i < 10; ++i) { expected[i] = 0.0; } expected[number] = 1.0; } int main() { image.open("train-images-idx3-ubyte", ios::in | ios::binary); // Binary image file label.open("train-labels-idx1-ubyte", ios::in | ios::binary ); // Binary label file char number; for (int i = 0; i < 16; i++) { //read the header in the image file image.read(&number, sizeof(char)); } for (int i = 0; i < 8; i++) { //read the header in the label file label.read(&number, sizeof(char)); } for (int e = 0;e < 5;e++){ for (int sample = 1; sample Подробнее здесь: [url]https://stackoverflow.com/questions/79272252/why-dont-move-the-dataset-file-pointer-to-the-header-when-training-the-fashion[/url]