本文整理汇总了C#中Encog.ML.Data.Specific.BiPolarMLData类的典型用法代码示例。如果您正苦于以下问题:C# BiPolarMLData类的具体用法?C# BiPolarMLData怎么用?C# BiPolarMLData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BiPolarMLData类属于Encog.ML.Data.Specific命名空间,在下文中一共展示了BiPolarMLData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(IExampleInterface app)
{
this.app = app;
// Create the neural network.
BasicLayer hopfield;
var network = new HopfieldNetwork(4);
// This pattern will be trained
bool[] pattern1 = {true, true, false, false};
// This pattern will be presented
bool[] pattern2 = {true, false, false, false};
IMLData result;
var data1 = new BiPolarMLData(pattern1);
var data2 = new BiPolarMLData(pattern2);
var set = new BasicMLDataSet();
set.Add(data1);
// train the neural network with pattern1
app.WriteLine("Training Hopfield network with: "
+ FormatBoolean(data1));
network.AddPattern(data1);
// present pattern1 and see it recognized
result = network.Compute(data1);
app.WriteLine("Presenting pattern:" + FormatBoolean(data1)
+ ", and got " + FormatBoolean(result));
// Present pattern2, which is similar to pattern 1. Pattern 1
// should be recalled.
result = network.Compute(data2);
app.WriteLine("Presenting pattern:" + FormatBoolean(data2)
+ ", and got " + FormatBoolean(result));
}
示例2: ART1
public ART1(int theF1Count, int theF2Count)
{
if ((((uint) theF2Count) + ((uint) theF2Count)) <= uint.MaxValue)
{
goto Label_00FE;
}
goto Label_00F2;
Label_0026:
this.Reset();
if (-2 != 0)
{
if (0 == 0)
{
return;
}
goto Label_00FE;
}
goto Label_00F2;
Label_0031:
this._noWinner = this._f2Count;
if (((uint) theF1Count) <= uint.MaxValue)
{
goto Label_0026;
}
goto Label_00D2;
Label_0071:
this._weightsF2ToF1 = new Matrix(this._f2Count, this._f1Count);
this._inhibitF2 = new bool[this._f2Count];
this._outputF1 = new BiPolarMLData(this._f1Count);
this._outputF2 = new BiPolarMLData(this._f2Count);
goto Label_0031;
Label_00D2:
if (0 != 0)
{
goto Label_0071;
}
if (0 == 0)
{
this._weightsF1ToF2 = new Matrix(this._f1Count, this._f2Count);
if ((((uint) theF1Count) | 0xff) == 0)
{
goto Label_0031;
}
goto Label_0071;
}
goto Label_0026;
Label_00F2:
this._f1Count = theF1Count;
this._f2Count = theF2Count;
goto Label_00D2;
Label_00FE:
this._a1 = 1.0;
this._b1 = 1.5;
this._c1 = 5.0;
this._d1 = 0.9;
this._l = 3.0;
this._vigilance = 0.9;
goto Label_00F2;
}
示例3: Compute
public override sealed IMLData Compute(IMLData input)
{
int num;
BiPolarMLData data = new BiPolarMLData(input.Count);
if (0 == 0)
{
if (((uint) num) <= uint.MaxValue)
{
if (3 == 0)
{
return data;
}
goto Label_0053;
}
}
else
{
goto Label_0053;
}
Label_003B:
EngineArray.ArrayCopy(base.CurrentState.Data, data.Data);
return data;
Label_0053:
EngineArray.ArrayCopy(input.Data, base.CurrentState.Data);
this.Run();
for (num = 0; num < base.CurrentState.Count; num++)
{
data.SetBoolean(num, BiPolarUtil.Double2bipolar(base.CurrentState[num]));
}
goto Label_003B;
}
示例4: Display
public void Display(BiPolarMLData pattern1, BiPolarMLData pattern2)
{
int index1 = 0;
int index2 = 0;
for (int row = 0; row < HEIGHT; row++)
{
var line = new StringBuilder();
for (int col = 0; col < WIDTH; col++)
{
if (pattern1.GetBoolean(index1++))
line.Append('O');
else
line.Append(' ');
}
line.Append(" -> ");
for (int col = 0; col < WIDTH; col++)
{
if (pattern2.GetBoolean(index2++))
line.Append('O');
else
line.Append(' ');
}
Console.WriteLine(line.ToString());
}
}
示例5: Compute
/// <summary>
/// Note: for Hopfield networks, you will usually want to call the "run"
/// method to compute the output.
/// This method can be used to copy the input data to the current state. A
/// single iteration is then run, and the new current state is returned.
/// </summary>
///
/// <param name="input">The input pattern.</param>
/// <returns>The new current state.</returns>
public override sealed IMLData Compute(IMLData input)
{
var result = new BiPolarMLData(input.Count);
EngineArray.ArrayCopy(input.Data, CurrentState.Data);
Run();
for (int i = 0; i < CurrentState.Count; i++)
{
result.SetBoolean(i,
BiPolarUtil.Double2bipolar(CurrentState[i]));
}
EngineArray.ArrayCopy(CurrentState.Data, result.Data);
return result;
}
示例6: ComputeF1
/// <summary>
/// Compute the output from the F1 layer.
/// </summary>
///
/// <param name="input">The input to the F1 layer.</param>
private void ComputeF1(BiPolarMLData input)
{
for (int i = 0; i < _f1Count; i++)
{
double sum = _weightsF1ToF2[i, Winner]
*((_outputF2.GetBoolean(Winner)) ? 1 : 0);
double activation = (((input.GetBoolean(i)) ? 1 : 0) + _d1*sum - _b1)
/(1 + _a1
*(((input.GetBoolean(i)) ? 1 : 0) + _d1*sum) + _c1);
_outputF1.SetBoolean(i, activation > 0);
}
}
示例7: Compute
/// <summary>
/// Compute the output for the BasicNetwork class.
/// </summary>
///
/// <param name="input">The input to the network.</param>
/// <returns>The output from the network.</returns>
public IMLData Compute(IMLData input)
{
if (!(input is BiPolarMLData))
{
throw new NeuralNetworkError(
"Input to ART1 logic network must be BiPolarNeuralData.");
}
var output = new BiPolarMLData(_f1Count);
Compute((BiPolarMLData) input, output);
return output;
}
示例8: Classify
/// <summary>
/// Classify the input data to a class number.
/// </summary>
///
/// <param name="input">The input data.</param>
/// <returns>The class that the data belongs to.</returns>
public int Classify(IMLData input)
{
var input2 = new BiPolarMLData(_f1Count);
var output = new BiPolarMLData(_f2Count);
if (input.Count != input2.Count)
{
throw new NeuralNetworkError("Input array size does not match.");
}
for (int i = 0; i < input2.Count; i++)
{
input2.SetBoolean(i, input[i] > 0);
}
Compute(input2, output);
return HasWinner ? Winner : -1;
}
示例9: ThermalNetwork
/// <summary>
/// Construct the network with the specicified neuron count.
/// </summary>
///
/// <param name="neuronCount">The number of neurons.</param>
protected ThermalNetwork(int neuronCount)
{
_neuronCount = neuronCount;
_weights = new double[neuronCount*neuronCount];
_currentState = new BiPolarMLData(neuronCount);
}
示例10: StringToBipolar
public BiPolarMLData StringToBipolar(String str)
{
var result = new BiPolarMLData(str.Length*BITS_PER_CHAR);
int currentIndex = 0;
for (int i = 0; i < str.Length; i++)
{
char ch = char.ToUpper(str[i]);
int idx = ch - FIRST_CHAR;
int place = 1;
for (int j = 0; j < BITS_PER_CHAR; j++)
{
bool value = (idx & place) > 0;
result.SetBoolean(currentIndex++, value);
place *= 2;
}
}
return result;
}
示例11: Compute
public override sealed IMLData Compute(IMLData input)
{
BiPolarMLData data = new BiPolarMLData(input.Count);
EngineArray.ArrayCopy(input.Data, base.CurrentState.Data);
this.Run();
EngineArray.ArrayCopy(base.CurrentState.Data, data.Data);
return data;
}
示例12: DisplayTour
private String DisplayTour(BiPolarMLData data)
{
var result = new StringBuilder();
int n1, n2;
bool first;
for (n1 = 0; n1 < NUM_CITIES; n1++)
{
first = true;
result.Append("[");
for (n2 = 0; n2 < NUM_CITIES; n2++)
{
if (data.GetBoolean(n1*NUM_CITIES + n2))
{
if (first)
{
first = false;
result.Append(n2);
}
else
{
result.Append(", " + n2);
}
}
}
result.Append("]");
if (n1 != NUM_CITIES - 1)
{
result.Append(" -> ");
}
}
return result.ToString();
}
示例13: LengthOfTour
public double LengthOfTour(BiPolarMLData data)
{
double result;
int n1, n2, n3;
result = 0;
for (n1 = 0; n1 < NUM_CITIES; n1++)
{
for (n2 = 0; n2 < NUM_CITIES; n2++)
{
if (data.GetBoolean(((n1)%NUM_CITIES)*NUM_CITIES + n2))
break;
}
for (n3 = 0; n3 < NUM_CITIES; n3++)
{
if (data.GetBoolean(((n1 + 1)%NUM_CITIES)*NUM_CITIES + n3))
break;
}
result += distance[n2][n3];
}
return result;
}
示例14: IsValidTour
public bool IsValidTour(BiPolarMLData data)
{
int cities, stops;
for (int n1 = 0; n1 < NUM_CITIES; n1++)
{
cities = 0;
stops = 0;
for (int n2 = 0; n2 < NUM_CITIES; n2++)
{
if (data.GetBoolean(n1*NUM_CITIES + n2))
{
if (++cities > 1)
return false;
}
if (data.GetBoolean(n2*NUM_CITIES + n1))
{
if (++stops > 1)
return false;
}
}
if ((cities != 1) || (stops != 1))
return false;
}
return true;
}
示例15: Execute
public void Execute(IExampleInterface app)
{
this.app = app;
SetupInput();
var pattern = new ART1Pattern();
pattern.InputNeurons = INPUT_NEURONS;
pattern.OutputNeurons = OUTPUT_NEURONS;
var network = (ART1) pattern.Generate();
for (int i = 0; i < PATTERN.Length; i++)
{
var dataIn = new BiPolarMLData(input[i]);
var dataOut = new BiPolarMLData(OUTPUT_NEURONS);
network.Compute(dataIn, dataOut);
if (network.HasWinner)
{
app.WriteLine(PATTERN[i] + " - " + network.Winner);
}
else
{
app.WriteLine(PATTERN[i] + " - new Input and all Classes exhausted");
}
}
}