Skip to content

Instantly share code, notes, and snippets.

View jychstar's full-sized avatar
🎯
Focusing

Yuchao Jiang jychstar

🎯
Focusing
View GitHub Profile
import tensorflow as tf
mu = 0
sigma = 0.1
rate = 0.001
x = tf.placeholder(tf.float32, (None, 32, 32, 1), name = "input")
y = tf.placeholder(tf.int32, (None),name = "label")
one_hot_y = tf.one_hot(y, 10)
with tf.name_scope("conv1"): # Layer 1: Convolutional. Input = 32x32x1. Output = 28x28x6.
import tensorflow as tf
x = tf.placeholder(tf.float32, shape=[None, 784], name = "input")
y_ = tf.placeholder(tf.float32, shape=[None, 10], name = "label") # labels
# Weight Initialization
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial, name = "weight")
@jychstar
jychstar / tensorboard_beginner.py
Created June 5, 2017 00:06
simple example to show how to use `tf.summary` to record image, scalar, histogram and graph for display in tensorboard
import argparse
import sys
from tensorflow.examples.tutorials.mnist import input_data
from time import time
t0 = time()
import tensorflow as tf
tf.summary.FileWriterCache.clear()
@jychstar
jychstar / hive.java
Created May 23, 2017 05:41
HIve JDBC example codes
package etl;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
public class etl {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
@jychstar
jychstar / sliding_window.py
Created April 14, 2017 03:36
create sliding windows to identify objects
import numpy as np
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
% matplotlib inline
image = mpimg.imread('bbox-example-image.jpg')
def draw_boxes(img, bboxes, color=(0, 0, 255), thick=6):
imcopy = np.copy(img)
for bbox in bboxes:
@jychstar
jychstar / vhs space.py
Created April 13, 2017 15:48
pixels in 3D plot, rgb space vs vhs space
import cv2
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def plot3d(pixels, colors_rgb,
axis_labels=list("RGB"), axis_limits=[(0, 255), (0, 255), (0, 255)]):
"""Plot pixels in 3D."""
# Create figure and 3D axes
@jychstar
jychstar / miniflow.py
Created March 24, 2017 01:37
miniflow in Udacity nanodegree
import numpy as np
class Node(object):
"""
Base class for nodes in the network.
Arguments:
`inbound_nodes`: A list of nodes with edges into this node.
"""
def __init__(self, inbound_nodes=[]):
@jychstar
jychstar / fullyconnected.py
Last active January 20, 2017 00:39
deep learning,assignment2
batch_size = 128
hidden_size = 1024
graph = tf.Graph()
with graph.as_default():
# place holder for train set, constant for other set
X_train = tf.placeholder(tf.float32,shape=(None, 784))
y_train = tf.placeholder(tf.float32, shape=(None, 10))
# Variables.