Skip to content

Instantly share code, notes, and snippets.

View keras_mnist.py
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()
View keras_test.py
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
}
@pannous
pannous / hello_sequence.py
Last active Mar 22, 2018
Simple "Hello World" for tensorflow seq2seq model
View hello_sequence.py
"""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
@pannous
pannous / tensorflow-densenet.py
Last active Jul 30, 2017
Implementation of DenseNet: Densely Connected Convolutional Networks https://arxiv.org/abs/1608.06993 in tensorflow
View tensorflow-densenet.py
#!/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)
@pannous
pannous / tensorflow_autoencoder.py
Created Feb 5, 2016
A simple MNIST classifer AND autoencoder in one
View tensorflow_autoencoder.py
"""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()
@pannous
pannous / tensorflow_xor_hello_world.py
Created Nov 11, 2015
A simple neural network learning the XOR function with the tensorflow framework
View tensorflow_xor_hello_world.py
#!/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 =>
You can’t perform that action at this time.