Created
August 4, 2015 06:18
-
-
Save abramhindle/71e3dd1d37363851c80b to your computer and use it in GitHub Desktop.
Demo of saving not working for theanets commit 33775e7c96adbe2924cadb13f0061fd648a74c46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
'''Example using the theanets package for learning the XOR relation.''' | |
import climate | |
import logging | |
import numpy as np | |
import theanets | |
climate.enable_default_logging() | |
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], dtype='f') | |
Y = np.array([[0], [1], [1], [0]], dtype='f') | |
net = theanets.Regressor([2, 20, 1]) | |
net.train([X, Y], algo='rprop', patience=10, batch_size=4) | |
logging.info("Input:\n%s", X) | |
logging.info("XOR output:\n%s", Y) | |
logging.info("NN XOR predictions:\n%s", net.predict(X.astype('f')).round(2)) | |
net.save("xor-net-save") | |
netsaved = net.load("xor-net-save") | |
logging.info("Saved NN XOR predictions:\n%s", netsaved.predict(X.astype('f')).round(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment