ATLAS Offline Software
EvaluateUtils.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #include "EvaluateUtils.h"
4 
5 #include <fstream>
6 #include <arpa/inet.h>
7 
8 namespace EvaluateUtils {
9  //*******************************************************************
10  // for reading MNIST images
11  std::vector<std::vector<std::vector<float>>> read_mnist_pixel_notFlat(const std::string &full_path)
12  {
13  std::vector<std::vector<std::vector<float>>> input_tensor_values;
14  input_tensor_values.resize(10000, std::vector<std::vector<float> >(28,std::vector<float>(28)));
15  std::ifstream file (full_path.c_str(), std::ios::binary);
16  int magic_number=0;
17  int number_of_images=0;
18  int n_rows=0;
19  int n_cols=0;
20  file.read((char*)&magic_number,sizeof(magic_number));
21  magic_number= ntohl(magic_number);
22  file.read((char*)&number_of_images,sizeof(number_of_images));
23  number_of_images= ntohl(number_of_images);
24  file.read((char*)&n_rows,sizeof(n_rows));
25  n_rows= ntohl(n_rows);
26  file.read((char*)&n_cols,sizeof(n_cols));
27  n_cols= ntohl(n_cols);
28  for(int i=0;i<number_of_images;++i)
29  {
30  for(int r=0;r<n_rows;++r)
31  {
32  for(int c=0;c<n_cols;++c)
33  {
34  unsigned char temp=0;
35  file.read((char*)&temp,sizeof(temp));
36  input_tensor_values[i][r][c]= float(temp)/255;
37  }
38  }
39  }
40  return input_tensor_values;
41  }
42 }
beamspotman.r
def r
Definition: beamspotman.py:676
EvaluateUtils.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
file
TFile * file
Definition: tile_monitor.h:29
EvaluateUtils::read_mnist_pixel_notFlat
std::vector< std::vector< std::vector< float > > > read_mnist_pixel_notFlat(const std::string &full_path)
Definition: EvaluateUtils.cxx:11
EvaluateUtils
Definition: EvaluateUtils.cxx:8
python.compressB64.c
def c
Definition: compressB64.py:93
readCCLHist.float
float
Definition: readCCLHist.py:83