Skip to content

Instantly share code, notes, and snippets.

View mlzxy's full-sized avatar

Xinyu Zhang mlzxy

View GitHub Profile
I use the first
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
"""
make trainable
"""
def make_trainable(net, val):
pass
net.trainable = val
for l in net.layers:
l.trainable = val
@mlzxy
mlzxy / what-forces-layout.md
Created January 9, 2017 01:57 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
/**
* 1. install nodejs from https://nodejs.org/en/download/
* 2. run `npm install -g serve-static filehandler serve-index` in terminal
* 3. run `node mediaserver.js`
*/
var http = require('http'),
fs = require('fs'),
util = require('util'),
url = require('url'),
path = require('path'),
export http_proxy='http://127.0.0.1:8123'
export https_proxy='http://127.0.0.1:8123'
export http_proxy='http://127.0.0.1:8123'
export https_proxy='http://127.0.0.1:8123'
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
# Define custom py_func which takes also a grad op as argument:
def py_func(func, inp, Tout, stateful=True, name=None, grad=None):
# Need to generate a unique name to avoid duplicates:
rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8))
@mlzxy
mlzxy / gan.py
Created November 25, 2016 19:28
gan.py
from util import *
from tf_util import *
from matplotlib import pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
# %matplotlib inline
"""
Parameter Sections
"""
model_name = 'basic_gan_mnist'
@mlzxy
mlzxy / tf_util.py
Created November 25, 2016 19:25
my tensorflow wrapper for neural network dev
import tensorflow as tf
from util import model_save_temp_folder__, join, isfile, datetime, list_prod, to_list, mkdir, tqdm
from tensorflow.python.ops import seq2seq as s2s
from tensorflow.contrib import layers
import numpy as np
import random
PADDING_SAME = 'SAME'
PADDING_VALID = 'VALID'
tf_sigmoid = tf.nn.sigmoid
import tensorflow as tf
import numpy as np
if __name__ == '__main__':
np.random.seed(1)
# the size of the hidden state for the lstm (notice the lstm uses 2x of this amount so actually lstm will have state of size 2)
size = 1
# 2 different sequences total
batch_size= 2
# the maximum steps for both sequences is 10