Encog 使用自定义网络加载 CSV 文件

Encog load CSV file with customized network

我想像这样从 CSV 文件加载数据:

var format = new CSVFormat('.', ' '); 
IVersatileDataSource source = new CSVDataSource(filename, false, format);
var data = new VersatileMLDataSet(source); ...

那我有两个选择:

使用 EncogModel

var model = new EncogModel(data);
model.SelectMethod(data, MLMethodFactory.TypeFeedforward); ...

建立自己的网络

var network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true, 11));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 8));
network.AddLayer(new BasicLayer(new ActivationTANH(), true, 5)); 
...
IMLDataSet trainingSet = new BasicMLDataSet(input, output);

我不知道如何使用第一个选项(Encog 模型)设置层数、神经元和激活函数。我得到的只是一些只有一个隐藏层的默认前馈网络。


我不知道如何从 VersatileMLDataSet 轻松地为我自己的网络(第二个选项)分别获取输入和输出数组。我可以获得整个数组(输入+输出),但必须有一种方法可以只获取输入数组或输出数组。

我在文档中找到了答案(Encog 方法和培训工厂,第 75 页),使用 EncogModel 可以像这样自定义网络:

var methodFactory = new MLMethodFactory();
var method = methodFactory . Create(
MLMethodFactory .TYPEFEEDFORWARD,
”?:B−>SIGMOID−>4:B−>SIGMOID−>?”,
2,
1);

The above code creates a neural network with two input neurons and one output neuron. There are four hidden neurons. Bias neurons are placed on the input and hidden layers. As is typical for neural networks, there are no bias neurons on the output layer. The sigmoid activation function is used between both the input and hidden neuron, as well between the hidden and output layer. You may notice the two question marks in the neural network architecture string. These will be filled in by the input and output layer sizes specified in the create method and are optional. You can hard-code the input and output sizes. In this case the numbers specified in the create call will be ignored.