Skip to content

Instantly share code, notes, and snippets.

@ningyuwhut
ningyuwhut / TensorFlow-Best-Practices-Q1-2018.md
Created December 13, 2018 08:17 — forked from blepfo/TensorFlow-Best-Practices-Q1-2018.md
TensorFlow Best Practices as of Q1 2018

TensorFlow Best Practices as of Q1 2018

By Adam Anderson

adam.b.anderson.96@gmail.com

Preface

This write-up assumes you have an general understanding of the TensorFlow programming model, but maybe you haven't kept up to date with the latest library features/standard practices.

@ningyuwhut
ningyuwhut / batch_run_multiple_days
Created September 5, 2018 03:09
run a shell job multiple days
sdate=$1 #`date -d'-1 days' +"%Y%m%d"`
edate=$2 #`date -d'+0 days' +"%Y%m%d"`
date=$sdate
declare -a date_array=()
#先生成日期数组,然后依次遍历数组中的日期
while [ $date -ne $edate ];do
echo "date", $date
date_array=("${date_array[@]}" $date)
date=`date -d"$date 1 day" '+%Y%m%d'`
done
@ningyuwhut
ningyuwhut / auc.py
Created September 4, 2018 06:33 — forked from wepe/auc.py
AUC计算: 精确方法与近似方法
# coding=utf-8
# auc值的大小可以理解为: 随机抽一个正样本和一个负样本,正样本预测值比负样本大的概率
# 根据这个定义,我们可以自己实现计算auc
import random
import time
def timeit(func):
"""
装饰器,计算函数执行时间
#https://stackoverflow.com/questions/48238113/tensorflow-dynamic-rnn-state
import numpy as np
import tensorflow as tf
n_steps = 2
n_inputs = 3
n_neurons = 5
X = tf.placeholder(dtype=tf.float32, shape=[None, n_steps, n_inputs])
#encoding=utf8
import copy, numpy as np
import sys
np.random.seed(0)
#RNN code from http://iamtrask.github.io/2015/11/15/anyone-can-code-lstm/
# compute sigmoid nonlinearity
def sigmoid(x):
output = 1/(1+np.exp(-x))
return output
#执行前先进入root权限
#安装前要看一下python2.7是否已安装
#如何判断是否已安装
#python2.7
echo "start install python2.7"
rm -r Python-2.7.10
rm -rf /usr/local/lib/python2.7
tar xzvf Python-2.7.10.tgz
#encoding=gbk
import random
import math
#读取数据集
def load_data(filename):
dataset = file(filename)
x_input=[]
y_output=[]
for line in dataset:
@ningyuwhut
ningyuwhut / permutation_with_repeated_item.c
Last active January 4, 2016 08:19
可重集的排列
#include <stdio.h>
#include <stdlib.h>
static void print_permutation_r(char S[], int n, int cur, char P[])
{
int i, j;
if (cur == n) { // 收敛条件
for (i = 0; i < n; i++)
printf("%c ", P[i]);
printf("\n");