📄 layer.h
字号:
/*
*
* Copyright 2004-2006 Ghassan OREIBY
*
* This file is part of Neurality.
*
* Neurality is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Neurality is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Neurality; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/
#pragma once
#ifndef __LAYER__
#define __LAYER__
#include "NeuralNetwork.h"
#define WEIGHTRANGE 5.0f
CLASSEXPORT class CLASS_DECLSPEC CLayer;
struct NodeStructureWithoutWeight //Same as NodeStruct but without the weight parameter
{
CNode *Node;
NodeStructureWithoutWeight *Next;
};
struct LayerStruct //A linked list type of layer (to store the list of layers)
{
CLayer *pLayer;
LayerStruct *Next;
};
//This Class represents a classic layer (a set of node) that connects to other layers,...
class CLayer
{
friend class CNetwork;
public:
CLayer(void);
~CLayer(void);
CLayer(int nNodeNum);
//private:
protected:
//The List of Layers that are back connected to this layer
LayerStruct *pbackLayerList;
protected:
//A linked list that contains the list of neurones associated to the layer
NodeStructureWithoutWeight *pNodeStruct; //not sure if should be public!! and not sure if it should be of this type since it got the weight member that i dont need it here
//Create a back connection between this layer and the pbackLayer
bool MakeConnection(CLayer* pbackLayer);
//Compute the output of each node in the layer
void ComputeLayer(void);
// Reset errors for all the nodes inside the layer
void ResetError(void);
// Back Progapagate error on each node of the layer
void backPropagateError(void) const;
// Connects the elements of layer to a node (usually the threshold node)
void MakeConnection(CNode* ThresholdNode);
// Correct weights after backpropagating (batch mode)
void CorrectWeights(void);
// Returns the number of nodes inside this layer
int GetNodeNumber(void);
private:
// The total number of nodes inside this layer
int nNodeNumber;
protected:
// Returns the weights for the node contained in this layer
int GetWeights(real **reWeights) const;
// Same as GetWeights(real**) but with more params in it (to resume learning later)
int GetWeights(WeightStruct** NodeParams) const;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -