public NNetwork(IActivationFunction function, int ... layers) throws NNException {
		if (layers.length < 2) {
			throw new NNException("A neural network must have at least 2 layers.");
		}
		inputLayer = new ArrayList<>(layers[0]);
		outputLayer = new ArrayList<>(layers[layers.length - 1]);
		midLayers = new ArrayList<>(layers.length - 2);
		
		for (int i = 0; i < layers[0]; i++) {
			inputLayer.add(new InputNeuron());
		}
		for (int i = 1; i < layers.length - 1; i++) {
			int layerSize = layers[i];
			List<Neuron> layer = new ArrayList<>(layerSize);
			for (int j = 0; j < layerSize; j++) {
				layer.add(new Neuron(function));
			}
			midLayers.add(layer);
		}
		for (int i = 0; i < layers[layers.length-1]; i++) {
			outputLayer.add(new OutputNeuron(function));
		}
		wireAllLayers();
	}