本文整理汇总了C#中IMLMethod类的典型用法代码示例。如果您正苦于以下问题:C# IMLMethod类的具体用法?C# IMLMethod怎么用?C# IMLMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMLMethod类属于命名空间,在下文中一共展示了IMLMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Create a SVM trainer.
/// </summary>
///
/// <param name="method">The method to use.</param>
/// <param name="training">The training data to use.</param>
/// <param name="argsStr">The arguments to use.</param>
/// <returns>The newly created trainer.</returns>
public IMLTrain Create(IMLMethod method,
IMLDataSet training, String argsStr)
{
if (!(method is SupportVectorMachine))
{
throw new EncogError(
"SVM Train training cannot be used on a method of type: "
+ method.GetType().FullName);
}
double defaultGamma = 1.0d/((SupportVectorMachine) method).InputCount;
double defaultC = 1.0d;
IDictionary<String, String> args = ArchitectureParse.ParseParams(argsStr);
var holder = new ParamsHolder(args);
double gamma = holder.GetDouble(MLTrainFactory.PropertyGamma,
false, defaultGamma);
double c = holder.GetDouble(MLTrainFactory.PropertyC, false,
defaultC);
var result = new SVMTrain((SupportVectorMachine) method, training);
result.Gamma = gamma;
result.C = c;
return result;
}
示例2: Create
/// <summary>
/// Create an annealing trainer.
/// </summary>
/// <param name="method">The method to use.</param>
/// <param name="training">The training data to use.</param>
/// <param name="argsStr">The arguments to use.</param>
/// <returns>The newly created trainer.</returns>
public IMLTrain Create(IMLMethod method,
IMLDataSet training, String argsStr)
{
if (!(method is BasicNetwork))
{
throw new TrainingError(
"Invalid method type, requires BasicNetwork");
}
ICalculateScore score = new TrainingSetScore(training);
IDictionary<String, String> args = ArchitectureParse.ParseParams(argsStr);
var holder = new ParamsHolder(args);
int populationSize = holder.GetInt(
MLTrainFactory.PropertyPopulationSize, false, 5000);
IMLTrain train = new MLMethodGeneticAlgorithm( () => {
IMLMethod result = (IMLMethod) ObjectCloner.DeepCopy(method);
((IMLResettable)result).Reset();
return result;
}, score, populationSize);
return train;
}
示例3: Create
/// <summary>
/// Create an annealing trainer.
/// </summary>
///
/// <param name="method">The method to use.</param>
/// <param name="training">The training data to use.</param>
/// <param name="argsStr">The arguments to use.</param>
/// <returns>The newly created trainer.</returns>
public IMLTrain Create(IMLMethod method,
IMLDataSet training, String argsStr)
{
if (!(method is BasicNetwork))
{
throw new TrainingError(
"Invalid method type, requires BasicNetwork");
}
ICalculateScore score = new TrainingSetScore(training);
IDictionary<String, String> args = ArchitectureParse.ParseParams(argsStr);
var holder = new ParamsHolder(args);
int populationSize = holder.GetInt(
MLTrainFactory.PropertyPopulationSize, false, 5000);
double mutation = holder.GetDouble(
MLTrainFactory.PropertyMutation, false, 0.1d);
double mate = holder.GetDouble(MLTrainFactory.PropertyMate,
false, 0.25d);
IMLTrain train = new NeuralGeneticAlgorithm((BasicNetwork) method,
new RangeRandomizer(-1, 1), score, populationSize, mutation,
mate);
return train;
}
示例4: Randomize
public override sealed void Randomize(IMLMethod method)
{
if (!(method is BasicNetwork))
{
throw new EncogError("Ngyyen Widrow only works on BasicNetwork.");
}
BasicNetwork network = (BasicNetwork) method;
Label_00B3:
new RangeRandomizer(base.Min, base.Max).Randomize(network);
int num = 0;
int l = 1;
while (true)
{
if (l >= (network.LayerCount - 1))
{
if ((num >= 1) && ((((uint) num) + ((uint) l)) <= uint.MaxValue))
{
this._x43f451310e815b76 = network.InputCount;
this._xd7d571ecee49d1e4 = 0.7 * Math.Pow((double) num, 1.0 / ((double) network.InputCount));
base.Randomize(network);
return;
}
return;
}
num += network.GetLayerTotalNeuronCount(l);
if (((uint) l) < 0)
{
goto Label_00B3;
}
l++;
}
}
示例5: CrossTraining
/// <summary>
/// Construct a cross trainer.
/// </summary>
///
/// <param name="network">The network.</param>
/// <param name="training">The training data.</param>
protected CrossTraining(IMLMethod network, FoldedDataSet training)
: base(TrainingImplementationType.Iterative)
{
_network = network;
Training = training;
_folded = training;
}
示例6: Randomize
/// <summary>
/// The Nguyen-Widrow initialization algorithm is the following :
///
/// 1. Initialize all weight of hidden layers with (ranged) random values
/// 2. For each hidden layer
/// 2.1 calculate beta value, 0.7/// Nth(#neurons of input layer) root of
/// #neurons of current layer
/// 2.2 for each synapse
/// 2.1.1 for each weight
/// 2.1.2 Adjust weight by dividing by norm of weight for neuron and
/// multiplying by beta value
/// </summary>
/// <param name="method">The network to randomize.</param>
public override sealed void Randomize(IMLMethod method)
{
if (!(method is BasicNetwork))
{
throw new EncogError("Ngyyen Widrow only works on BasicNetwork.");
}
var network = (BasicNetwork) method;
new RangeRandomizer(Min, Max).Randomize(network);
int hiddenNeurons = 0;
for (int i = 1; i < network.LayerCount - 1; i++)
{
hiddenNeurons += network.GetLayerTotalNeuronCount(i);
}
// can't really do much, use regular randomization
if (hiddenNeurons < 1)
{
return;
}
_inputCount = network.InputCount;
_beta = 0.7d*Math.Pow(hiddenNeurons, 1.0d/network.InputCount);
base.Randomize(network);
}
示例7: Encode
public IGenome Encode(IMLMethod phenotype)
{
var rbfNet = (RBFNetwork) phenotype;
var result = new DoubleArrayGenome(Size);
Array.Copy(rbfNet.LongTermMemory, 0, result.Data, 0, _size);
return result;
}
示例8: Create
public IMLTrain Create(IMLMethod method, IMLDataSet training, string argsStr)
{
if (!(method is SupportVectorMachine))
{
throw new EncogError("SVM Train training cannot be used on a method of type: " + method.GetType().FullName);
}
double defaultValue = 1.0 / ((double) ((SupportVectorMachine) method).InputCount);
while (true)
{
double num4;
SVMTrain train;
double num2 = 1.0;
IDictionary<string, string> theParams = ArchitectureParse.ParseParams(argsStr);
ParamsHolder holder = new ParamsHolder(theParams);
double num3 = holder.GetDouble("GAMMA", false, defaultValue);
do
{
num4 = holder.GetDouble("C", false, num2);
train = new SVMTrain((SupportVectorMachine) method, training) {
Gamma = num3
};
}
while (((uint) defaultValue) > uint.MaxValue);
if ((((uint) num2) + ((uint) num3)) <= uint.MaxValue)
{
train.C = num4;
return train;
}
}
}
示例9: CalculateScore
public double CalculateScore(IMLMethod network)
{
var pilot = new NeuralRobot((BasicNetwork)network, false, RobotContol.SourceLocation, RobotContol.DestLocation);
int score = pilot.ScorePilot();
//RobotContol.Scores.Add(score);
return score;
}
示例10: CrossTraining
protected CrossTraining(IMLMethod network, FoldedDataSet training)
: base(TrainingImplementationType.Iterative)
{
this._x87a7fc6a72741c2e = network;
this.Training = training;
this._x3952df2eab48841c = training;
}
示例11: Create
/// <summary>
/// Create an annealing trainer.
/// </summary>
///
/// <param name="method">The method to use.</param>
/// <param name="training">The training data to use.</param>
/// <param name="argsStr">The arguments to use.</param>
/// <returns>The newly created trainer.</returns>
public IMLTrain Create(IMLMethod method,
IMLDataSet training, String argsStr)
{
if (!(method is BasicNetwork))
{
throw new TrainingError(
"Invalid method type, requires BasicNetwork");
}
ICalculateScore score = new TrainingSetScore(training);
IDictionary<String, String> args = ArchitectureParse.ParseParams(argsStr);
var holder = new ParamsHolder(args);
double startTemp = holder.GetDouble(
MLTrainFactory.PropertyTemperatureStart, false, 10);
double stopTemp = holder.GetDouble(
MLTrainFactory.PropertyTemperatureStop, false, 2);
int cycles = holder.GetInt(MLTrainFactory.Cycles, false, 100);
IMLTrain train = new NeuralSimulatedAnnealing(
(BasicNetwork) method, score, startTemp, stopTemp, cycles);
return train;
}
示例12: Create
public IMLTrain Create(IMLMethod method, IMLDataSet training, string args)
{
if (!(method is RBFNetwork))
{
throw new EncogError("RBF-SVD training cannot be used on a method of type: " + method.GetType().FullName);
}
return new SVDTraining((RBFNetwork) method, training);
}
示例13: NetworkSize
public static int NetworkSize(IMLMethod network)
{
if (!(network is IMLEncodable))
{
throw new NeuralNetworkError("This machine learning method cannot be encoded:" + network.GetType().FullName);
}
return ((IMLEncodable) network).EncodedArrayLength();
}
示例14: ArrayToNetwork
public static void ArrayToNetwork(double[] array, IMLMethod network)
{
if (!(network is IMLEncodable))
{
throw new NeuralNetworkError("This machine learning method cannot be encoded:" + network.GetType().FullName);
}
((IMLEncodable) network).DecodeFromArray(array);
}
示例15: CalculateScore
/// <inheritdoc />
public double CalculateScore(IMLMethod genome)
{
var prg = (EncogProgram) genome;
var pop = (PrgPopulation) prg.Population;
IMLData inputData = new BasicMLData(pop.Context.DefinedVariables.Count);
prg.Compute(inputData);
return 0;
}