def train_network(sample_set): """ Perform training on network from sample set.""" net = HopfieldNet(sample_set.sample_size) net.initialize() for sample in sample_set: net.train(sample) return net
def train_network(samples_filename, weights_filename): """ Perform training on network from file and saved weights. """ sample_set = SampleSet() sample_set.init_from_file(samples_filename) net = HopfieldNet(sample_set.sample_size) net.initialize() for sample in sample_set: net.train(sample) save_weights_to_file(net.weights, weights_filename)