for (int i = 1; i < layers.length; i++) {
RBM rbm = new RBM();
rbm.setProperties(new Properties());
rbm.getProperties().setParameter(Constants.CONNECTION_FACTORY, cf);
rbm.addConnections(cf.fullyConnected(result.getOutputLayer(), new Layer(), layers[i - 1], layers[i]));
if (addBias) {
rbm.addConnections(cf.fullyConnected(new Layer(), rbm.getVisibleLayer(), 1, layers[i - 1]));
rbm.addConnections(cf.fullyConnected(new Layer(), rbm.getHiddenLayer(), 1, layers[i]));
}