Created
April 4, 2016 21:48
-
-
Save mertyildiran/47c535998c327ae501876a293f0e8a90 to your computer and use it in GitHub Desktop.
Basic Neural Network example with PyBrain
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
from pybrain.tools.shortcuts import buildNetwork | |
from pybrain.datasets import SupervisedDataSet | |
from pybrain.supervised.trainers import BackpropTrainer | |
net = buildNetwork(3, 1, 1, bias=False) | |
ds = SupervisedDataSet(3, 1) | |
ds.addSample((0, 0, 1), (1,)) | |
ds.addSample((0, 1, 1), (1,)) | |
ds.addSample((1, 0, 1), (1,)) | |
ds.addSample((1, 1, 0), (0,)) | |
trainer = BackpropTrainer(net, ds) | |
trainer.trainUntilConvergence() | |
print net.activate([0, 0, 1]) | |
print net.activate([0, 1, 1]) | |
print net.activate([1, 0, 1]) | |
print net.activate([1, 1, 0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment