|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANN.Perceptron.ArchiveSerialization;
using ANN.Perceptron.Common;
using ANN.Perceptron.Neurons;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
namespace ANN.Perceptron.Layers
{
public class InputLayer:CommonLayer
{
public InputLayer(String sLabel, Size inputSize)
{
label = sLabel;
prevLayer = null;
weights = null;
featureMapSize = inputSize;
nFeatureMaps = 1;
weightCount = 0;
floatingPointWarning = false;
ParallelOption = new ParallelOptions();
ParallelOption.TaskScheduler = null;
_maxDegreeOfParallelism = Environment.ProcessorCount;
ParallelOption.MaxDegreeOfParallelism = _maxDegreeOfParallelism;
type = LayerTypes.Input;
}
public override void Initialize()
{
floatingPointWarning = false;
CreateLayer();
}
protected override void CreateLayer()
{
var rdm = new Random();
if (neuronCount > 0 || neurons != null)
{ //clear neurons
neurons = null;
neuronCount = 0;
}
if (weightCount > 0 || weights != null)
{
//clear weights;
weights = null;
weightCount = 0;
}
#region input layer type
//
// the input layer.
// Create neurons: exactly the same number of neurons as the input
// vector of 29x29=841 pixels, and no weights/connections
prevLayer = null;
neuronCount = nFeatureMaps * featureMapSize.Width * featureMapSize.Height;
neurons = new Neuron[NeuronCount];
weightCount = 0;
weights = null;
for (int ii = 0; ii < neuronCount; ii++)
{
String lb = String.Format("Layer {0}, Neuron {0}", label, ii);
neurons[ii] = new Neuron(lb);
}
#endregion
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.