public boolean equals(FeedforwardNetwork other) {
        Iterator<FeedForwardLayer> otherLayers = other.getLayers().iterator();

        for (FeedForwardLayer layer : this.getLayers()) {
            FeedForwardLayer otherLayer = otherLayers.next();

            if (layer.getNeuronCount() != otherLayer.getNeuronCount()) {
                return false;
            }

            // make sure they either both have or do not have
            // a weight matrix.
            if ((layer.getMatrix() == null) && (otherLayer.getMatrix() != null)) {
                return false;
            }

            if ((layer.getMatrix() != null) && (otherLayer.getMatrix() == null)) {
                return false;
            }

            // if they both have a matrix, then compare the matrices
            if ((layer.getMatrix() != null) && (otherLayer.getMatrix() != null)) {
                if (!layer.getMatrix().equals(otherLayer.getMatrix())) {
                    return false;
                }
            }
        }

        return true;
    }