-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "remove example which is now redunant because of tutorial"
This reverts commit 5ad2cc8.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python | ||
|
||
from theano import tensor | ||
|
||
from blocks.algorithms import GradientDescent, SteepestDescent | ||
from blocks.bricks import MLP, Tanh, Identity | ||
from blocks.bricks.cost import CategoricalCrossEntropy | ||
from blocks.datasets import DataStream | ||
from blocks.datasets.mnist import MNIST | ||
from blocks.datasets.schemes import SequentialScheme | ||
from blocks.extensions import FinishAfter, Printing | ||
from blocks.main_loop import MainLoop | ||
|
||
|
||
def main(): | ||
mlp = MLP([Tanh(), Identity()], [784, 100, 10]) | ||
x = tensor.matrix('features') | ||
y = tensor.lmatrix('targets') | ||
cost = CategoricalCrossEntropy().apply(y.flatten() - 1, mlp.apply(x)) | ||
|
||
mnist = MNIST("train") | ||
|
||
main_loop = MainLoop( | ||
mlp, | ||
DataStream(mnist, | ||
iteration_scheme=SequentialScheme(mnist.num_examples, 20)), | ||
GradientDescent(cost=cost, | ||
step_rule=SteepestDescent(learning_rate=0.1)), | ||
extensions=[FinishAfter(after_n_epochs=2), | ||
Printing()]) | ||
main_loop.run() | ||
|
||
if __name__ == "__main__": | ||
main() |
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