""" Handles the saving and loading of objects """ import pickle def save_network(obj, filename): """ Store the network in a save file """ with open(filename, 'wb') as outp: # Overwrites any existing file. pickle.dump(obj, outp, pickle.HIGHEST_PROTOCOL) def load_network(filename): """ Retrieve the network from a save file """ with open(filename, 'rb') as inp: # Overwrites any existing file. network = pickle.load(inp) return network