MagmaDNN  1.0
c++NeuralNetworkFramework
tensor_io.h File Reference
#include <string>
#include <fstream>
#include <sstream>
#include "types.h"
#include "tensor.h"
Include dependency graph for tensor_io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
magmadnn_error_t magmadnn::io::read_csv_to_tensor (Tensor< T > &t, const std::string &file_name, char delim)
 
template<typename T >
magmadnn_error_t magmadnn::io::write_tensor_to_csv (const Tensor< T > &t, const std::string &file_name, char delim, bool create)
 

Detailed Description

Author
Daniel Nichols
Version
1.0
Date
2019-04-05

Function Documentation

◆ read_csv_to_tensor()

template<typename T >
magmadnn_error_t magmadnn::io::read_csv_to_tensor ( Tensor< T > &  t,
const std::string &  file_name,
char  delim = ',' 
)

Reads from "file_name" into the tensor t. It interprets the data as having the flattened shape of the input tensor. Returns 0 if successfull, otherwise something else.

See also
write_tensor_to_csv
Template Parameters
Tdata type
Parameters
ttensor to read values into
file_namefile name of csv file (should be a text file, not binary)
delimthe delimiter of the csv (assumed to be a comma)
Returns
magmadnn_error_t 0 if successful, otherwise anything else

◆ write_tensor_to_csv()

template<typename T >
magmadnn_error_t magmadnn::io::write_tensor_to_csv ( const Tensor< T > &  t,
const std::string &  file_name,
char  delim = ',',
bool  create = true 
)

Writes the tensor t to the file "file_name". It writes a flattened version of the file that is readable by read_csv_to_tensor.

See also
read_csv_to_tensor .
Template Parameters
Tdata type
Parameters
ttensor to write out
file_namecsv file to be written into. Created if it does not exist.
delimcharacter to delimit values
createcreate file if it does not exist.
Returns
magmadnn_error_t returns 0 if successful, otherwise something else