Layer layer = network.getLayers().get(layerIndex);
for (Neuron neuron : layer.getNeurons()) {
for (Connection connection : neuron.getInputConnections()) {
if (index >= weights.length)
throw new EncogEngineError("Weight size mismatch.");
Weight weight = connection.getWeight();
FlatWeight flatWeight = new FlatWeight(weights, index++);
flatWeight.setValue(weight.getValue());
connection.setWeight(flatWeight);