|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ANN.Perceptron;
using ANN.Perceptron.Layers;
namespace NNControl.NNTraining
{
public partial class OutputLayerForm : Form
{
OutputLayer layer;
CommonLayer preLayer;
List<Char> outputLetters;
bool isUnknownOutput;
public bool IsUnknownOutput
{
get
{
return isUnknownOutput;
}
}
public List<Char> OutputLetters
{
get
{
return outputLetters;
}
}
public OutputLayer Layer
{
get
{
return layer;
}
}
public OutputLayerForm(CommonLayer prelayer)
{
InitializeComponent();
layer = null;
preLayer = prelayer;
outputLetters = null;
}
private void btAdd_Click(object sender, EventArgs e)
{
if (GetOutputLetters(tbOutputLetters.Text))
{
string label = tbLabel.Text;
int nNeurons = (int)outputLetters.Count;
isUnknownOutput = cbUnknownOutput.Checked;
layer = new OutputLayer(label, preLayer, nNeurons, cbUnknownOutput.Checked);
layer.Initialize();
this.DialogResult = DialogResult.OK;
this.Close();
}
else
{
MessageBox.Show("Error in output letter string!", "Output letters String error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// Get output letter to a neural network
/// </summary>
/// <param name="text">output letter string</param>
bool GetOutputLetters(String text)
{
if (outputLetters != null)
{
outputLetters = null;
}
outputLetters = new List<char>();
try
{
string temp = text;
while (true)
{
int index = temp.IndexOf(',');
if (index > 0)
{
string character = temp.Substring(0, index).Trim();
Char c = Convert.ToChar(character);
outputLetters.Add(c);
temp = temp.Substring(index + 1).Trim();
}
else
{
if (temp.Length > 0)
{
Char c = Convert.ToChar(temp.Trim());
outputLetters.Add(c);
}
break;
}
}
}
catch (Exception ex)
{
return false;
}
return true;
}
}
}
|
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.