Created
October 18, 2013 12:17
-
-
Save AlexanderFabisch/7040705 to your computer and use it in GitHub Desktop.
XOR with ELM (Extreme Learning Machine)
This file contains hidden or 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
from openann import * | |
import numpy | |
if __name__ == "__main__": | |
# Create dataset | |
X = numpy.array([[0, 1], [0, 0], [1, 1], [1, 0]]) | |
Y = numpy.array([[1], [0], [0], [1]]) | |
D = X.shape[1] | |
F = Y.shape[1] | |
N = X.shape[0] | |
dataset = Dataset(X, Y) | |
# Make the result repeatable | |
RandomNumberGenerator().seed(0) | |
# Create network | |
net = Net() | |
net.input_layer(D) | |
net.extreme_layer(3, Activation.LOGISTIC) | |
net.output_layer(F, Activation.LOGISTIC) | |
# Train network | |
stop_dict = {"minimal_value_differences" : 1e-10} | |
lma = LMA(stop_dict) | |
lma.optimize(net, dataset) | |
# Use network | |
Y = net.predict(X) | |
for n in xrange(X.shape[0]): | |
print(str(X[n]) + " -> " + str(Y[n])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OpenANN is required to execute this script.