private boolean initLayerFunctions(boolean optimizing, StringBuffer msg) {
        if (numLayers < 1) {
            msg.append(MessageFormat.format("invalid number of layers: ''{0}'' (should be > 0)", numLayers));
            return false;
        }
        if (layers == null) {
            msg.append("no layers defined");
            return false;
        }
        if (_inputLayerIndex < 0 || _inputLayerIndex >= numLayers) {
            msg.append(MessageFormat.format("invalid input 0-based layer index: ''{0}'' (should be >= 0 and < {1})", _inputLayerIndex, numLayers));
            return false;
        }
        if (_outputLayerIndex < 0 || _outputLayerIndex >= numLayers) {
            msg.append(MessageFormat.format("invalid output 0-based layer index: ''{0}'' (should be >= 0 and < {1})", _outputLayerIndex, numLayers));
            return false;
        }

        for (int i = 0; i < layers.length; i++) {
            if (layers[i] != null) {
                if (!layers[i].initFunctions(optimizing, msg)) {
                    return false;
                }
            } else {
                msg.append(MessageFormat.format("no layer defined at 0-based index: ''{0}''", i));
                return false;
            }
        }
        return true;
    }