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
import keras | |
from keras.datasets import mnist | |
from keras.models import Sequential | |
from keras.layers import Dense, Dropout, Flatten | |
from keras.layers import Conv2D, MaxPooling2D | |
num_classes = 10 | |
width, height = 28, 28 | |
(x_train, y_train), (x_test, y_test) = mnist.load_data() |
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
import numpy as np | |
from keras.models import Sequential | |
from keras.layers.core import Dense, Activation | |
xoder={ | |
(0,0):0, | |
(0,1):1, | |
(1,0):1, | |
(1,1):0 | |
} |
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
"""Sequence-to-sequence model with an attention mechanism.""" | |
# see https://www.tensorflow.org/versions/r0.10/tutorials/seq2seq/index.html | |
# compare https://github.com/tflearn/tflearn/blob/master/examples/nlp/seq2seq_example.py | |
from __future__ import print_function | |
import numpy as np | |
import tensorflow as tf | |
vocab_size=256 # We are lazy, so we avoid fency mapping and just use one *class* per character/byte | |
target_vocab_size=vocab_size | |
learning_rate=0.1 |
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/python | |
from __future__ import print_function | |
import os | |
import numpy as np | |
import tensorflow as tf | |
from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets | |
# mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) | |
mnist = read_data_sets("/tmp/data/", one_hot=True) |
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
"""A simple MNIST classifer AND autoencoder in one | |
""" | |
# Import data | |
import input_data | |
mnist = input_data.read_data_sets("/data/mnist/", one_hot=True) | |
import tensorflow as tf | |
sess = tf.InteractiveSession() |
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 PYTHONIOENCODING="utf-8" python | |
""" | |
A simple neural network learning the XOR function | |
""" | |
import tensorflow as tf | |
sess = tf.InteractiveSession() | |
# Desired input output mapping of XOR function: | |
x_ = [[0, 0], [0, 1], [1, 0], [1, 1]] # input | |
#labels=[0, 1, 1, 0] # output => |