nnlib
GPU-accelerated, C/C++ neural network library.
Classes | Functions
network.cpp File Reference

Source file defining methods of the Network class. More...

#include "../../include/network.h"
#include "../gpu/allocation_gpu.cuh"
#include "runtime.h"
#include <algorithm>
#include <chrono>
#include <cmath>
#include <ctime>
#include <exceptions/size_mismatch_exception.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <utils/printing.h>
#include <verify.cuh>

Classes

struct  EpochProgress
 Structure to contain information about the current epoch. More...
 

Functions

std::ostream & operator<< (std::ostream &stream, const EpochProgress &epochProgress)
 A toString() method for EpochProgress. More...
 
std::vector< sTensor > splitIntoBatches (const sTensor &data, size_t batchSize)
 Split the input matrix into batches. More...
 

Detailed Description

Source file defining methods of the Network class.

Author
Jan Warchocki
Date
03 March 2022

Function Documentation

◆ operator<<()

std::ostream& operator<< ( std::ostream &  stream,
const EpochProgress epochProgress 
)

A toString() method for EpochProgress.

Parameters
streamThe stream to append the string representation of EpochProgress to.
epochProgressThe EpochProgress object to display.
Returns
The string representation of the desired EpochProgress object.

◆ splitIntoBatches()

std::vector<sTensor> splitIntoBatches ( const sTensor &  data,
size_t  batchSize 
)

Split the input matrix into batches.

It is assumed that the data samples are row-aligned. Therefore, to split into batches, the input matrix is divided along the row axis, so that the data samples are not split.

For example, when splitting the following matrix using batchSize = 2:

[[1, 1],
[2, 2],
[3, 3],
[4, 4]]

We get as the result a vector of the following two matrices:

[[1, 1],
[2, 2]]
[[3, 3],
[4, 4]]

If the size of data is not divisible by batchSize, the last batch will be smaller than the rest.

Parameters
dataThe matrix to split into batches.
batchSizeThe size of the batch to split on.
Returns
The vector of batches.