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

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

#include "../../include/layer.h"
#include "../gpu/allocation_gpu.cuh"
#include "runtime.h"
#include "verify.cuh"
#include <utility>

Functions

float getRandom ()
 Generate a random float value. More...
 
sTensor initializeBiases (size_t outSize)
 Initialize the biases of the layer. More...
 
sTensor initializeWeights (size_t inSize, size_t outSize)
 Initialize the weights of the layer. More...
 

Detailed Description

Source file defining methods of the Layer class.

Author
Jan Warchocki
Date
03 March 2022

Function Documentation

◆ getRandom()

float getRandom ( )

Generate a random float value.

Currently the method only returns uniformly distributed numbers in the range (-0.2, 0.2).

Returns
A random value.

◆ initializeBiases()

sTensor initializeBiases ( size_t  outSize)

Initialize the biases of the layer.

This creates a vector of random numbers using the getRandomValue() method.

Parameters
outSizeThe size of the vector to generate. It is also the output size of the layer.
Returns
The random vector of biases.

◆ initializeWeights()

sTensor initializeWeights ( size_t  inSize,
size_t  outSize 
)

Initialize the weights of the layer.

This creates a matrix of random numbers using the getRandomValue() method.

Parameters
inSizeThe number of rows of the matrix. It is also the input size to the layer.
outSizeThe number of columns of the matrix. It is also the output size of the layer.
Returns
The random matrix of weights.