You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have multiples inputs , but most of them are List array and i dont know how can i configure my neural network to accept list array as an input.
Here i have a example XOR(but the inputs are just floats and i cant change to List array):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Encog.Engine.Network.Activation;
using Encog.Neural.Networks;
using Encog.Neural.Networks.Layers;
using Encog.Neural.Networks.Structure;
using Encog.Neural.Networks.Training.Propagation.Back;
using Encog.ML.Data.Basic;
using Encog.ML.Data.Versatile;
using Encog.ML.Data;
namespace Encog
{
class Program
{
static void Main(string[] args)
{
#region Create DataSet
//previsao soma 0.5+0.5 para gerar saida 1.0
double[][] x =
{
new double []{0.1, 0.2},
new double []{0.4, 0.3},
new double []{0.0, 0.0},
new double []{0.15, 0.25}
};
double[][] y =
{
new double []{0.3}, // soma do 1 array
new double []{0.7},
new double []{0.0},
new double []{0.4}
};
IMLDataSet dataset = new BasicMLDataSet(x, y); // criar interface dataset
#endregion
#region Create neuralNetwork
BasicNetwork network = new BasicNetwork();
//Adiconar camadas
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 2)); // contador de neuronios - ultimo parametro. temos 2 numeros na 1ª camada de entrada
//camada oculta, com mais neuronios que a camada principal
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
//camada de saida so com 1 neuronio
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 1));
network.Structure.FinalizeStructure();
network.Reset();//randomizar os pesos
#endregion
#region Create BackPropagation instance(tem outros algoritmos de treinamento sem ser backpropagation)
// classe para treinamento
Backpropagation train = new Backpropagation(network, dataset, 0.5, 0.1);
#endregion
#region Train the network
// precisamos de 2 variaveis para treinar ou
int epoch = 0;
do
{
train.Iteration();
//mostrar erro a cada 100 epoch
if (epoch % 100 == 0)
Console.WriteLine("Error: {0} Epoch: {1}", train.Error, epoch);
epoch++; // sentinela , contador
}
while (epoch < 6000);
#endregion
#region Test Network
//vamos gerar 2 numeros
for (int i = 0; i <= 10; i++) // 0.1 0.1 ->resultado: 0.2
// 0.2 0.2 ->resultado: 0.4 etc...
{
//converter o n para double
double num = 1.0 / (double)i;
//entrada para rede neuronal
double[] d = new double[] { num, num };
IMLData input = new BasicMLData(d); // so aceita double
IMLData output = network.Compute(input);
// resultado
double[] result = new double[output.Count];
output.CopyTo(result, 0, output.Count);
Console.WriteLine("{0} + {1} = {2}", num, num, result[0]);
}
Console.ReadKey();
#endregion
}
}
}
The text was updated successfully, but these errors were encountered:
I have multiples inputs , but most of them are List array and i dont know how can i configure my neural network to accept list array as an input.
Here i have a example XOR(but the inputs are just floats and i cant change to List array):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Encog.Engine.Network.Activation;
using Encog.Neural.Networks;
using Encog.Neural.Networks.Layers;
using Encog.Neural.Networks.Structure;
using Encog.Neural.Networks.Training.Propagation.Back;
using Encog.ML.Data.Basic;
using Encog.ML.Data.Versatile;
using Encog.ML.Data;
namespace Encog
{
class Program
{
static void Main(string[] args)
{
#region Create DataSet
//previsao soma 0.5+0.5 para gerar saida 1.0
double[][] x =
{
new double []{0.1, 0.2},
new double []{0.4, 0.3},
new double []{0.0, 0.0},
new double []{0.15, 0.25}
};
}
The text was updated successfully, but these errors were encountered: