Skip to content

Instantly share code, notes, and snippets.

View rish-16's full-sized avatar
🤖
backpropagating through memories

Rishabh Anand rish-16

🤖
backpropagating through memories
View GitHub Profile
import numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)
n_h1 = 500
n_h2 = 500
n_classes = 10
batch_size = 128
@rish-16
rish-16 / model.py
Last active November 21, 2017 03:07
import numpy as np
from keras.models import Sequential
from keras.datasets import mnist
from keras.layers import Dense
from keras.utils import np_utils
n_classes = 10
batch_size = 128
(X_train, y_train), (X_test, y_test) = mnist.load_data()
@rish-16
rish-16 / model.py
Last active November 21, 2017 03:20
import tflearn
from tflearn.layers.core import input_data, fully_connected
from tflearn.layers.estimator import regression
import tflearn.datasets.mnist as mnist
X_train, y_train, X_test, y_test = mnist.load_data(one_hot=True)
X_train = X_train.reshape([-1, 1])
X_test = X_test.reshape([-1, 1])
@rish-16
rish-16 / index.html
Last active April 8, 2018 03:26
Basic HTML template
<html>
<head>
<title>TensorFlow Demo!</title>
<meta charset='uft-8'>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.8.0"></script>
<script src="TF.js"></script>
<head>
<body>
import * as tf from '@tensorflow/tfjs';
// A sequential model is a container which you can add layers to.
const model = tf.sequential();
// Add a dense layer with 1 output unit.
model.add(tf.layers.dense({units: 10,
inputShape: [1],
activation='relu'
}));
import tflearn
import numpy as np
x = np.array([[1], [2], [3], [4], [5], [6], [7]], dtype=np.float32)
y = np.array([[1], [3], [5], [7], [9], [11], [13]], dtype=np.float32)
n = tflearn.input_data(shape=[None, 1])
n = tflearn.fully_connected(n, 1, activation='softmax')
n = tflearn.regression(n, optimizer=tflearn.SGD(), loss='categorical_crossentropy')
// A sequential model is a container which you can add layers to.
const model = tf.sequential();
// Add a dense layer with 1 output unit.
model.add(tf.layers.dense({units: 1,
inputShape: [1],
activation: 'softmax'
}));
// Specify the loss type and optimizer for training.
@rish-16
rish-16 / cat_utils.py
Last active May 19, 2018 12:55
Cat Faces dataset preprocessing function
import numpy as np
from sklearn.model_selection import train_test_split
def load_cats():
cats = np.load("./cats.npy")
print (cats.shape)
Y = []
for i in range(cats.shape[0]):
Y.append([1,0])
Y = np.array(Y)
class PAgent():
def __init__(self, length):
self.string = ''.join(random.choice(string.ascii_letters) for _ in range(length))
self.fitness = -1
class SAgent():
def __init__(self, in_str):
self.in_str = in_str
self.in_str_len = len(in_str)
self.average_score_fitness = -1
self.number_successful = 0
self.population = random.randint(1, 21)
self.generations = random.randint(1, 5000)
self.threshold = 90