//*******************************************************************************
// CSC 143 Computer Programming II Spring 1999 Instructor: Keith Hughes
//
// Homework 3
// File : \\Venus\katy\CIS143\Homework3\AdalineNetwork\layer.h
//
// Purpose : Declaration for NeuronLayer and LinkLayer classes.
//
// Author : Hsin-yi F. Berg
// Date : 5/9/1999 Sun.
// Last Update: 5/28/1999 Fri.
// Update Note: Modification of the documentation
// NeuralNet has been moved to NeuralNet.h
//*******************************************************************************
#ifndef LAYER_H
#define LAYER_H
#include "base.h"
#include <iostream.h>
#include <fstream.h>
typedef int ID;
// WEIGHT is the weight of the link, already declared in base.h
extern const double WEIGHT;
class Neuron;
class Link;
class NeuronLayer
{
public:
/*
NeuronLayer::NeuronLayer()
Default constructor for a NeuronLayer. NeuronLayer is created empty.
*/
NeuronLayer();
/*
NeuronLayer::~NeuronLayer()
Default destructor for a NeuronLayer.
*/
~NeuronLayer();
/*
void NeuronLayer::SetHowManyNeurons(int n)
Set how many Neurons are there in the layer (default is 0).
This function can only be called once.
*/
void SetHowManyNeurons(int n);
/*
void NeuronLayer::SetNeuronValue(int whichNeuron, double Value)
Set the value of a specified Neuron
*/
void SetNeuronValue(int whichNeuron, double Value);
/*
double NeuronLayer::GetNeuronValue(int whichNeuron) const
Return the value of a specified Neuron
*/
double GetNeuronValue(int whichNeuron) const;
/*
void NeuronLayer::SetError(int whichNeuron, double newError)
Set the error of a specific Neuron
*/
void NeuronLayer::SetError(int whichNeuron, double newError);
/*
double NeuronLayer::GetError(int whichNeuron) const
Get the error of a specific Neuron.
*/
double NeuronLayer::GetError(int whichNeuron) const;
/*
int NeuronLayer::GetNumNeuron(void) const
Return how many Neurons are already in the Neuron
*/
int GetNumNeuron(void) const;
/*
Neuron *&NeuronLayer::GetNeurons(void)
Return the reference of Neurons
*/
Neuron *&GetNeurons(void);
/*
void NeuronLayer::Print(ostream& out) const
print out the internal state of all the Neurons
in the NeuronLayer to client supplied ostream
*/
void Print(ostream& out) const;
/*
void Neuron::Fire(void)
fire the entire NeuronLayer
*/
void Fire(void);
/*
void NeuronLayer::ReadFromFile(istream &in)
Read data into this NeuronLayer instance from file specified by "in"
*/
void NeuronLayer::ReadFromFile(istream &in);
/*
void NeuronLayer::WriteToFile(ostream &out)
Write data of this NeuronLayer instance to file specified by "out"
*/
void NeuronLayer::WriteToFile(ostream &out);
private:
// id_count keeps track of how many NeuronLayers that have been created
static int id_count;
// each NeuronLayer automatically gets an unique id when it's created
ID id;
// number of Neurons in the layer
int numNeuron;
// neurons stores the collection of Neurons
Neuron *neurons;
};
class LinkLayer
{
public:
/*
LinkLayer::LinkLayer()
Default constructor for a LinkLayer. LinkLayer is created empty.
*/
LinkLayer();
/*
LinkLayer::~LinkLayer()
Destructor for a LinkLayer.
*/
~LinkLayer();
/*
void LinkLayer::SetHowManyLinks(int n)
set how many links there are in the layer.
*/
void SetHowManyLinks(int n);
/*
void LinkLayer::SetLinkWeight(double Weight)
Set how many links there are in the layer.
Set the weight of all links in the layer (all get the same value)
*/
void SetLinkWeight(double Weight);
/*
int LinkLayer::GetNumLink(void) const
Get how many links there are in the layer.
*/
int GetNumLink(void) const;
/*
Link *&LinkLayer::GetLinks(void)
Get how many links there are in the layer.
*/
Link *&GetLinks(void);
/*
void LinkLayer::Print(ostream &out) const
Print out the internal state of all the Links in the LinkLayer to
the client supplied ostream.
*/
void Print(ostream &out) const;
/*
void LinkLayer::ReadFromFile(istream &in)
Read data into this LinkLayer instance from file specified by "in"
*/
void LinkLayer::ReadFromFile(istream &in);
/*
void LinkLayer::WriteToFile(ostream &out)
Write data of this linkLayer instance to file specified by "out"
*/
void LinkLayer::WriteToFile(ostream &out);
private:
// id_count keeps track of how many LinkLayers that have been created
static int id_count;
// each LinkLayer automatically gets an unique id when it's created
ID id;
// number of Links in the layer
int numLink;
// links stores the collection of Links
Link *links;
};
#endif
Back Top