ConvNet  1.0
A GPU-based C++ implementation of Convolutional Neural Nets
 All Classes Namespaces Functions Variables
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Edge Class Referenceabstract

This class is intended to be used as a base class for implementing edges. More...

#include <edge.h>

Inheritance diagram for Edge:
DownSampleEdge EdgeWithWeight MaxPoolEdge ResponseNormEdge RGBToYUVEdge UpSampleEdge ConvEdge ConvOneToOneEdge FCEdge LocalEdge

Public Member Functions

 Edge (const config::Edge &edge_config)
 Instatntiate an Edge from the config. More...
 
virtual void AllocateMemory (bool fprop_only)
 Allocate memory for the model. More...
 
virtual void Initialize ()
 Initialize the weights and biases. More...
 
virtual void SaveParameters (hid_t file)
 Write the weights and biases in an hdf5 file. More...
 
virtual void LoadParameters (hid_t file)
 Load the weights and biases from an hdf5 file. More...
 
virtual void InsertPolyak ()
 
virtual void BackupCurrent ()
 
virtual void LoadCurrentOnGPU ()
 
virtual void LoadPolyakOnGPU ()
 
virtual float GetRMSWeight ()
 Returns the root mean square weight value. More...
 
virtual void ReduceLearningRate (float factor)
 Reduce the learning rate by factor. More...
 
virtual bool HasNoParameters () const
 Returns whether the edge has any parameters. More...
 
virtual int GetNumModules () const
 Returns the number of modules. More...
 
virtual void DisplayWeights ()
 Displays the weights. More...
 
virtual void DisplayWeightStats ()
 Displays the statistics of the weights. More...
 
virtual void SetTiedTo (Edge *e)
 Sets the edge to be tied to another edge. More...
 
virtual void ComputeUp (Matrix &input, Matrix &output, bool overwrite)=0
 Computes the output layer state given the input. More...
 
virtual void ComputeDown (Matrix &deriv_output, Matrix &input, Matrix &output, Matrix &deriv_input, bool overwrite)=0
 Computes the derivative w.r.t the inputs of this edge given the derivative w.r.t the outputs of this edge. More...
 
virtual void ComputeOuter (Matrix &input, Matrix &deriv_output)
 Computes the gradient for the weights and biases. More...
 
virtual void UpdateWeights ()
 Update the weights. More...
 
virtual void SetImageSize (int image_size)
 Set the spatial size of the input to this edge. More...
 
bool IsBackPropBlocked () const
 Returns whether back prop is blocked through this edge. More...
 
void SetSource (Layer *source)
 
void SetDest (Layer *dest)
 
LayerGetSource ()
 
LayerGetDest ()
 
const string & GetSourceName ()
 
const string & GetDestName ()
 
const string & GetName ()
 
void SetInputChannels (int a)
 Set the number of input channels. More...
 
void SetOutputChannels (int a)
 Set the number of output channels. More...
 
void SetMark ()
 
bool HasMark ()
 
string GetTiedEdgeName ()
 
bool IsTied ()
 
int GetGPUId () const
 
void ComputeStart (Matrix &mat)
 
void ComputeEnd (Matrix &mat)
 

Static Public Member Functions

static EdgeChooseEdgeClass (const config::Edge &edge_config)
 Selects the appropriate derived class for the edge config. More...
 

Protected Attributes

Layersource_
 
Layerdest_
 The source layer for this edge. More...
 
const string source_node_
 The destination layer for this edge. More...
 
const string dest_node_
 
const string name_
 
const string tied_edge_name_
 
Edgetied_edge_
 
int num_input_channels_
 
int num_output_channels_
 
int image_size_
 
int num_modules_
 
bool mark_
 
const bool block_backprop_
 A marker. More...
 
const bool is_tied_
 
ImageDisplayerimg_display_
 
const int gpu_id_
 

Detailed Description

This class is intended to be used as a base class for implementing edges.

This is an abstract class - ComputeUp and ComputeDown methods must be implemented by derived classes.

Constructor & Destructor Documentation

Edge::Edge ( const config::Edge &  edge_config)

Instatntiate an Edge from the config.

Member Function Documentation

void Edge::AllocateMemory ( bool  fprop_only)
virtual

Allocate memory for the model.

Parameters
fprop_onlyIf true, does not allocate memory needed for optimization.

Reimplemented in ResponseNormEdge, ConvOneToOneEdge, MaxPoolEdge, ConvEdge, FCEdge, and LocalEdge.

Edge * Edge::ChooseEdgeClass ( const config::Edge &  edge_config)
static

Selects the appropriate derived class for the edge config.

virtual void Edge::ComputeDown ( Matrix deriv_output,
Matrix input,
Matrix output,
Matrix deriv_input,
bool  overwrite 
)
pure virtual

Computes the derivative w.r.t the inputs of this edge given the derivative w.r.t the outputs of this edge.

Parameters
deriv_outputDerivative w.r.t outputs of this edge.(In)
inputThe input to this edge.(In)
outputThe output of this edge.(In)
deriv_inputDerivative w.r.t inputs of this edge.(Out)

Implemented in ResponseNormEdge, ConvOneToOneEdge, DownSampleEdge, MaxPoolEdge, UpSampleEdge, ConvEdge, FCEdge, LocalEdge, and RGBToYUVEdge.

void Edge::ComputeOuter ( Matrix input,
Matrix deriv_output 
)
virtual

Computes the gradient for the weights and biases.

Parameters
inputThe input to this edge.
deriv_outputThe derivative w.r.t the output of this edge.

Reimplemented in ConvOneToOneEdge, ConvEdge, FCEdge, and LocalEdge.

virtual void Edge::ComputeUp ( Matrix input,
Matrix output,
bool  overwrite 
)
pure virtual

Computes the output layer state given the input.

Applies the weights and adds bias.

Implemented in ResponseNormEdge, ConvOneToOneEdge, DownSampleEdge, MaxPoolEdge, UpSampleEdge, ConvEdge, FCEdge, LocalEdge, and RGBToYUVEdge.

void Edge::DisplayWeights ( )
virtual

Displays the weights.

Supportsinput layer weights only.

Reimplemented in EdgeWithWeight, ConvEdge, and LocalEdge.

void Edge::DisplayWeightStats ( )
virtual

Displays the statistics of the weights.

Reimplemented in EdgeWithWeight.

int Edge::GetNumModules ( ) const
virtual

Returns the number of modules.

This is relevant for convolution-like edges.

Reimplemented in EdgeWithWeight, LocalEdge, ConvEdge, ConvOneToOneEdge, MaxPoolEdge, and RGBToYUVEdge.

float Edge::GetRMSWeight ( )
virtual

Returns the root mean square weight value.

Reimplemented in EdgeWithWeight.

bool Edge::HasNoParameters ( ) const
virtual

Returns whether the edge has any parameters.

Reimplemented in EdgeWithWeight.

void Edge::Initialize ( )
virtual

Initialize the weights and biases.

Reimplemented in EdgeWithWeight.

bool Edge::IsBackPropBlocked ( ) const
inline

Returns whether back prop is blocked through this edge.

void Edge::LoadParameters ( hid_t  file)
virtual

Load the weights and biases from an hdf5 file.

Parameters
fileThe file handle. The file has been opened for reading. Do not close it.

Reimplemented in EdgeWithWeight.

void Edge::ReduceLearningRate ( float  factor)
virtual

Reduce the learning rate by factor.

Reimplemented in EdgeWithWeight.

void Edge::SaveParameters ( hid_t  file)
virtual

Write the weights and biases in an hdf5 file.

Parameters
fileThe file handle. The file has been opened for writing. Do not close it.

Reimplemented in EdgeWithWeight.

void Edge::SetImageSize ( int  image_size)
virtual

Set the spatial size of the input to this edge.

Reimplemented in LocalEdge, ConvEdge, ConvOneToOneEdge, MaxPoolEdge, ResponseNormEdge, DownSampleEdge, and UpSampleEdge.

void Edge::SetInputChannels ( int  a)

Set the number of input channels.

void Edge::SetOutputChannels ( int  a)

Set the number of output channels.

void Edge::SetTiedTo ( Edge e)
virtual

Sets the edge to be tied to another edge.

Reimplemented in EdgeWithWeight, ConvEdge, LocalEdge, ResponseNormEdge, and MaxPoolEdge.

void Edge::UpdateWeights ( )
virtual

Update the weights.

Reimplemented in EdgeWithWeight.

Member Data Documentation

const bool Edge::block_backprop_
protected

A marker.

Used for topological sorting.

Layer* Edge::dest_
protected

The source layer for this edge.

const string Edge::source_node_
protected

The destination layer for this edge.


The documentation for this class was generated from the following files: