public static void serializeWeights(NNetwork network, File file) {
		try {
			JsonWriter writer = new JsonWriter(new FileWriter(file));
			writer.setIndent("  ");
			writer.beginArray();
			LayerIterator iter = new LayerIterator(network);
			List<? extends Neuron> curLayer = null;
			List<? extends Neuron> nextLayer = null;
			while (true) {
				if (iter.hasNext() && nextLayer == null) {
					nextLayer = iter.next();
				}
				if (iter.hasNext()) {
					curLayer = nextLayer;
					nextLayer = iter.next();
				} else {
					break;
				}
				writer.beginArray();
				for (Neuron outNeuron : nextLayer) {
					writer.beginArray();
					for (Neuron inNeuron : curLayer) {
						writer.value(outNeuron.getInputWeight(inNeuron));
					}
					writer.endArray();
				}
				writer.endArray();
			}
			writer.endArray();
			writer.close();
		} catch (IOException e) {
			System.out.println("Failed to write to file " + file + ": " + e.toString());
		}
	}