Skip to content

Instantly share code, notes, and snippets.

def load_from_dir(imgs_dir, height, width):
img_names = os.listdir(imgs_dir)
res = []
filenames = []
for img_name in img_names:
if img_name == '.DS_Store': continue
img_dir = imgs_dir + '/' + img_name
x = image.load_img(img_dir, target_size=(height, width))
x = image.img_to_array(x)
@chelicerae
chelicerae / deep_MNIST_for_experts.py
Created September 9, 2018 15:17 — forked from saitodev/deep_MNIST_for_experts.py
Tensorflow tutorial "Deep MNIST for Experts"
from __future__ import print_function
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
import tensorflow as tf
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
@chelicerae
chelicerae / tf.py
Created September 6, 2018 11:05 — forked from koaning/tf.py
tensorflow layer example
import tensorflow as tf
import numpy as np
import uuid
x = tf.placeholder(shape=[None, 3], dtype=tf.float32)
nn = tf.layers.dense(x, 3, activation=tf.nn.sigmoid)
nn = tf.layers.dense(nn, 5, activation=tf.nn.sigmoid)
encoded = tf.layers.dense(nn, 2, activation=tf.nn.sigmoid)
nn = tf.layers.dense(encoded, 5, activation=tf.nn.sigmoid)
nn = tf.layers.dense(nn, 3, activation=tf.nn.sigmoid)